mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: clean up code format
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
90a5da18cf
commit
51af6a062f
@ -160,12 +160,12 @@ func NewStore(lg *zap.Logger, server doer, timeout time.Duration) Store {
|
|||||||
// passwordStore implements PasswordStore using bcrypt to hash user passwords
|
// passwordStore implements PasswordStore using bcrypt to hash user passwords
|
||||||
type passwordStore struct{}
|
type passwordStore struct{}
|
||||||
|
|
||||||
func (_ passwordStore) CheckPassword(user User, password string) bool {
|
func (passwordStore) CheckPassword(user User, password string) bool {
|
||||||
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ passwordStore) HashPassword(password string) (string, error) {
|
func (passwordStore) HashPassword(password string) (string, error) {
|
||||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
return string(hash), err
|
return string(hash), err
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
type fakeDoer struct{}
|
type fakeDoer struct{}
|
||||||
|
|
||||||
func (_ fakeDoer) Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error) {
|
func (fakeDoer) Do(context.Context, etcdserverpb.Request) (etcdserver.Response, error) {
|
||||||
return etcdserver.Response{}, nil
|
return etcdserver.Response{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,11 +372,11 @@ func TestEnsure(t *testing.T) {
|
|||||||
type fastPasswordStore struct {
|
type fastPasswordStore struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ fastPasswordStore) CheckPassword(user User, password string) bool {
|
func (fastPasswordStore) CheckPassword(user User, password string) bool {
|
||||||
return user.Password == password
|
return user.Password == password
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ fastPasswordStore) HashPassword(password string) (string, error) { return password, nil }
|
func (fastPasswordStore) HashPassword(password string) (string, error) { return password, nil }
|
||||||
|
|
||||||
func TestCreateAndUpdateUser(t *testing.T) {
|
func TestCreateAndUpdateUser(t *testing.T) {
|
||||||
olduser := `{"user": "cat", "roles" : ["animal"]}`
|
olduser := `{"user": "cat", "roles" : ["animal"]}`
|
||||||
|
@ -216,9 +216,8 @@ func (s *store) Set(nodePath string, dir bool, value string, expireOpts TTLOptio
|
|||||||
if getErr != nil {
|
if getErr != nil {
|
||||||
err = getErr
|
err = getErr
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
value = n.Value
|
|
||||||
}
|
}
|
||||||
|
value = n.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new value
|
// Set new value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user