diff options
Diffstat (limited to 'integrations/api_admin_test.go')
-rw-r--r-- | integrations/api_admin_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index b8dded9c11..a7bbde4c53 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -106,3 +106,26 @@ func TestAPISudoUserForbidden(t *testing.T) { req := NewRequest(t, "GET", urlStr) session.MakeRequest(t, req, http.StatusForbidden) } + +func TestAPIListUsers(t *testing.T) { + prepareTestEnv(t) + adminUsername := "user1" + session := loginUser(t, adminUsername) + token := getTokenForLoggedInUser(t, session) + + urlStr := fmt.Sprintf("/api/v1/admin/users?token=%s", token) + req := NewRequest(t, "GET", urlStr) + resp := session.MakeRequest(t, req, http.StatusOK) + var users []api.User + DecodeJSON(t, resp, &users) + + found := false + for _, user := range users { + if user.UserName == adminUsername { + found = true + } + } + assert.True(t, found) + numberOfUsers := models.GetCount(t, &models.User{}, "type = 0") + assert.Equal(t, numberOfUsers, len(users)) +} |