summaryrefslogtreecommitdiffstats
path: root/tests/integration
diff options
context:
space:
mode:
authorEarl Warren <109468362+earl-warren@users.noreply.github.com>2023-11-13 15:31:38 +0100
committerGitHub <noreply@github.com>2023-11-13 15:31:38 +0100
commit340055ab6c579fccc9a370527ee2768bfb1466ba (patch)
tree8cd182ec66fe57c6d1b69b7ed4cc00e626cc0c0f /tests/integration
parentf2ea31de36ec777a84f32dfdb242da2a3d9f1fc8 (diff)
downloadgitea-340055ab6c579fccc9a370527ee2768bfb1466ba.tar.gz
gitea-340055ab6c579fccc9a370527ee2768bfb1466ba.zip
Enable system users search via the API (#28013)
Refs: https://codeberg.org/forgejo/forgejo/issues/1403 (cherry picked from commit dd4d17c159eaf8b642aa9e6105b0532e25972bb7)
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/api_user_search_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/integration/api_user_search_test.go b/tests/integration/api_user_search_test.go
index c5b202b319..ddfeb25234 100644
--- a/tests/integration/api_user_search_test.go
+++ b/tests/integration/api_user_search_test.go
@@ -56,6 +56,28 @@ func TestAPIUserSearchNotLoggedIn(t *testing.T) {
}
}
+func TestAPIUserSearchSystemUsers(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+ for _, systemUser := range []*user_model.User{
+ user_model.NewGhostUser(),
+ user_model.NewActionsUser(),
+ } {
+ t.Run(systemUser.Name, func(t *testing.T) {
+ req := NewRequestf(t, "GET", "/api/v1/users/search?uid=%d", systemUser.ID)
+ resp := MakeRequest(t, req, http.StatusOK)
+
+ var results SearchResults
+ DecodeJSON(t, resp, &results)
+ assert.NotEmpty(t, results.Data)
+ if assert.EqualValues(t, 1, len(results.Data)) {
+ user := results.Data[0]
+ assert.EqualValues(t, user.UserName, systemUser.Name)
+ assert.EqualValues(t, user.ID, systemUser.ID)
+ }
+ })
+ }
+}
+
func TestAPIUserSearchAdminLoggedInUserHidden(t *testing.T) {
defer tests.PrepareTestEnv(t)()
adminUsername := "user1"