Skip to content

Commit

Permalink
auth: add a unit test for creating a user with no password
Browse files Browse the repository at this point in the history
  • Loading branch information
mitake committed Apr 30, 2019
1 parent 0049575 commit d8ea60d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,21 @@ func testAuthInfoFromCtxWithRoot(t *testing.T, opts string) {
t.Errorf("expected user name 'root', got %+v", ai)
}
}

func TestUserNoPasswordAdd(t *testing.T) {
as, tearDown := setupAuthStore(t)
defer tearDown(t)

username := "usernopass"
ua := &pb.AuthUserAddRequest{Name: username, Options: &authpb.UserAddOptions{NoPassword: true}}
_, err := as.UserAdd(ua)
if err != nil {
t.Fatal(err)
}

ctx := context.WithValue(context.WithValue(context.TODO(), AuthenticateParamIndex{}, uint64(1)), AuthenticateParamSimpleTokenPrefix{}, "dummy")
_, err = as.Authenticate(ctx, username, "")
if err != ErrAuthFailed {
t.Fatalf("expected %v, got %v", ErrAuthFailed, err)
}
}

0 comments on commit d8ea60d

Please sign in to comment.