Skip to content
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

Merged
merged 1 commit into from
Oct 30, 2015

Conversation

jonboulle
Copy link
Contributor

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

@jonboulle
Copy link
Contributor Author

Alternative to #3389

@@ -30,6 +29,7 @@ import (
const testTimeout = time.Millisecond

func TestMergeUser(t *testing.T) {

Copy link
Contributor

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?

@xiang90
Copy link
Contributor

xiang90 commented Oct 27, 2015

@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)
}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@yichengq
Copy link
Contributor

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
```
@jonboulle
Copy link
Contributor Author

Will merge on green.

jonboulle added a commit that referenced this pull request Oct 30, 2015
etcdserver: restructure auth.Store and auth.User
@jonboulle jonboulle merged commit f787e79 into etcd-io:master Oct 30, 2015
@jonboulle jonboulle deleted the auth branch October 30, 2015 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants