mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	[GITEA] enable system users search via the API
Refs: https://codeberg.org/forgejo/forgejo/issues/1403 (cherry picked from commit87bd40411e) Conflicts: routers/api/v1/user/user.go https://codeberg.org/forgejo/forgejo/pulls/1469 (cherry picked from commit74f70ca873) (cherry picked from commit673a75bb43) (cherry picked from commitfcd4535ac6)
This commit is contained in:
		
					parent
					
						
							
								f7f723628c
							
						
					
				
			
			
				commit
				
					
						56b229f22e
					
				
			
		
					 3 changed files with 51 additions and 13 deletions
				
			
		|  | @ -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" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue