aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_admin_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-02-18 09:25:35 +0100
committerGitHub <noreply@github.com>2021-02-18 16:25:35 +0800
commit8d5c795cc4cc6b254a897461a860f25b0708ee14 (patch)
tree691eec6fd0abe6824f84e6eb64f4d2f086918a3a /integrations/api_admin_test.go
parentce0346448ff6c8e92f794e7b724f3d4333412a9b (diff)
downloadgitea-8d5c795cc4cc6b254a897461a860f25b0708ee14.tar.gz
gitea-8d5c795cc4cc6b254a897461a860f25b0708ee14.zip
[API] Add Restricted Field to User (#14630)
* Expose Restricted field for User * Add Option to Change Restricted on User via adminEditUser API * Add test who change restricted & test if it changed it ... * make generate-swagger Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'integrations/api_admin_test.go')
-rw-r--r--integrations/api_admin_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go
index 79fdc4a9f7..fdcfc40789 100644
--- a/integrations/api_admin_test.go
+++ b/integrations/api_admin_test.go
@@ -192,4 +192,18 @@ func TestAPIEditUser(t *testing.T) {
errMap := make(map[string]interface{})
json.Unmarshal(resp.Body.Bytes(), &errMap)
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
+
+ user2 := models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User)
+ assert.Equal(t, false, user2.IsRestricted)
+ bTrue := true
+ req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
+ // required
+ LoginName: "user2",
+ SourceID: 0,
+ // to change
+ Restricted: &bTrue,
+ })
+ session.MakeRequest(t, req, http.StatusOK)
+ user2 = models.AssertExistsAndLoadBean(t, &models.User{LoginName: "user2"}).(*models.User)
+ assert.Equal(t, true, user2.IsRestricted)
}