mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7257 from Rushit/auth_test
auth: unit-test for authStore.AuthDisable()
This commit is contained in:
commit
0df1822212
@ -448,6 +448,25 @@ func TestAuthInfoFromCtx(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthDisable(t *testing.T) {
|
||||
as, tearDown := setupAuthStore(t)
|
||||
defer tearDown(t)
|
||||
|
||||
as.AuthDisable()
|
||||
ctx := context.WithValue(context.WithValue(context.TODO(), "index", uint64(2)), "simpleToken", "dummy")
|
||||
_, err := as.Authenticate(ctx, "foo", "bar")
|
||||
if err != ErrAuthNotEnabled {
|
||||
t.Errorf("expected %v, got %v", ErrAuthNotEnabled, err)
|
||||
}
|
||||
|
||||
// Disabling disabled auth to make sure it can return safely if store is already disabled.
|
||||
as.AuthDisable()
|
||||
_, err = as.Authenticate(ctx, "foo", "bar")
|
||||
if err != ErrAuthNotEnabled {
|
||||
t.Errorf("expected %v, got %v", ErrAuthNotEnabled, err)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(array []string, str string) bool {
|
||||
for _, s := range array {
|
||||
if s == str {
|
||||
|
Loading…
x
Reference in New Issue
Block a user