Skip to content

Commit

Permalink
Merge pull request #7257 from Rushit/auth_test
Browse files Browse the repository at this point in the history
auth: unit-test for authStore.AuthDisable()
  • Loading branch information
xiang90 authored Feb 1, 2017
2 parents 89bb904 + 46cac6f commit 0df1822
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0df1822

Please sign in to comment.