Skip to content

Commit

Permalink
sever/auth: fix addUserWithNoOption of store_test
Browse files Browse the repository at this point in the history
Signed-off-by: engow <[email protected]>
  • Loading branch information
engow committed Mar 30, 2023
1 parent dcb1bf6 commit f7ac9df
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions server/auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ func setupAuthStore(t *testing.T) (store *authStore, teardownfunc func(t *testin

// The UserAdd function cannot generate old etcd version user data (user's option is nil)
// add special users through the underlying interface
addUserWithNoOption(as)
err = addUserWithNoOption(as)
if err != nil {
t.Fatal(err)
}

tearDown := func(_ *testing.T) {
b.Close()
Expand All @@ -135,16 +138,12 @@ func setupAuthStore(t *testing.T) (store *authStore, teardownfunc func(t *testin
return as, tearDown
}

func addUserWithNoOption(as *authStore) {
tx := as.be.BatchTx()
tx.Lock()
defer tx.Unlock()
tx.UnsafePutUser(&authpb.User{
Name: []byte("foo-no-user-options"),
Password: []byte("bar"),
})
as.commitRevision(tx)
as.refreshRangePermCache(tx)
func addUserWithNoOption(as *authStore) error {
_, err := as.UserAdd(&pb.AuthUserAddRequest{Name: "foo-no-user-options", Password: "bar"})
if err != nil {
return err
}
return nil
}

func enableAuthAndCreateRoot(as *authStore) error {
Expand Down

0 comments on commit f7ac9df

Please sign in to comment.