Skip to content

Commit

Permalink
server: add a unit test case for authStore.Reocver() with empty range…
Browse files Browse the repository at this point in the history
…PermCache

Signed-off-by: Hitoshi Mitake <h.mitake@gmail.com>
  • Loading branch information
mitake authored and tjungblu committed Jul 26, 2023
1 parent 6db9f48 commit faf4e87
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,30 @@ func TestRecover(t *testing.T) {
}
}

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

as.enabled = false
as.rangePermCache = map[string]*unifiedRangePermissions{}
as.Recover(as.be)

if !as.IsAuthEnabled() {
t.Fatalf("expected auth enabled got disabled")
}

if len(as.rangePermCache) != 2 {
t.Fatalf("rangePermCache should have permission information for 2 users (\"root\" and \"foo\"), but has %d information", len(as.rangePermCache))
}
if _, ok := as.rangePermCache["root"]; !ok {
t.Fatal("user \"root\" should be created by setupAuthStore() but doesn't exist in rangePermCache")
}
if _, ok := as.rangePermCache["foo"]; !ok {
t.Fatal("user \"foo\" should be created by setupAuthStore() but doesn't exist in rangePermCache")
}
}

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

0 comments on commit faf4e87

Please sign in to comment.