-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdserver: restructure auth.Store and auth.User #3762
Conversation
Alternative to #3389 |
@@ -30,6 +29,7 @@ import ( | |||
const testTimeout = time.Millisecond | |||
|
|||
func TestMergeUser(t *testing.T) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove this empty line?
5c3e9d7
to
8f28cce
Compare
@jonboulle One disadvantage of this approach is that we expose a public interface just for testing. I am not of a fan of that. But I do not have any better suggestion right now. Seems to be OK. |
|
||
type PasswordStore interface { | ||
CheckPassword(user User, password string) bool | ||
HashPassword(password string) (string, error) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this under Store interface? So all interfaces are at the head of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
LGTM |
This attempts to decouple password-related functions, which previously existed both in the Store and User structs, by splitting them out into a separate interface, PasswordStore. This means that they can be more easily swapped out during testing. This also changes the relevant tests to use mock password functions instead of the bcrypt-backed implementations; as a result, the tests are much faster. Before: ``` github.com/coreos/etcd/etcdserver/auth 31.495s github.com/coreos/etcd/etcdserver/etcdhttp 91.205s ``` After: ``` github.com/coreos/etcd/etcdserver/auth 1.207s github.com/coreos/etcd/etcdserver/etcdhttp 1.207s ```
Will merge on green. |
etcdserver: restructure auth.Store and auth.User
This attempts to decouple password-related functions, which previously
existed both in the Store and User structs, by splitting them out into a
separate interface, PasswordStore. This means that they can be more
easily swapped out during testing.
This also changes the relevant tests to use mock password functions
instead of the bcrypt-backed implementations; as a result, the tests are
much faster.
Before:
After: