aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_admin_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-04-15 17:36:59 +0100
committertechknowlogick <matti@mdranta.net>2019-04-15 12:36:59 -0400
commit837116875efc8f27265e884499ecca69ef554014 (patch)
tree78f6b246216be0f98ac32c3e2b35b831cd840eac /integrations/api_admin_test.go
parent74fc63682c4c14b5c19c46f9d41af1cf4212766f (diff)
downloadgitea-837116875efc8f27265e884499ecca69ef554014.tar.gz
gitea-837116875efc8f27265e884499ecca69ef554014.zip
Return a UserList from /api/v1/admin/users (#6629)
Diffstat (limited to 'integrations/api_admin_test.go')
-rw-r--r--integrations/api_admin_test.go23
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))
+}