diff options
author | Lauris BH <lauris@nix.lv> | 2018-07-05 02:51:02 +0300 |
---|---|---|
committer | Jonas Franz <info@jonasfranz.software> | 2018-07-05 01:51:02 +0200 |
commit | 69e2ab161109eef667cd22a96711e4a8ee9d01d2 (patch) | |
tree | c69499946dfb2e61390fb1c57a4afe42d9c362f0 /integrations/api_repo_test.go | |
parent | 4eae810d63cb48977d7c0b96c90877592ec3d7b2 (diff) | |
download | gitea-69e2ab161109eef667cd22a96711e4a8ee9d01d2.tar.gz gitea-69e2ab161109eef667cd22a96711e4a8ee9d01d2.zip |
Allow administrator to create repository for any organization (#4368)
Diffstat (limited to 'integrations/api_repo_test.go')
-rw-r--r-- | integrations/api_repo_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index c789cc9ee4..aec8c8f81b 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -262,3 +262,26 @@ func TestAPIRepoMigrate(t *testing.T) { session.MakeRequest(t, req, testCase.expectedStatus) } } + +func TestAPIOrgRepoCreate(t *testing.T) { + testCases := []struct { + ctxUserID int64 + orgName, repoName string + expectedStatus int + }{ + {ctxUserID: 1, orgName: "user3", repoName: "repo-admin", expectedStatus: http.StatusCreated}, + {ctxUserID: 2, orgName: "user3", repoName: "repo-own", expectedStatus: http.StatusCreated}, + {ctxUserID: 2, orgName: "user6", repoName: "repo-bad-org", expectedStatus: http.StatusForbidden}, + } + + prepareTestEnv(t) + for _, testCase := range testCases { + user := models.AssertExistsAndLoadBean(t, &models.User{ID: testCase.ctxUserID}).(*models.User) + session := loginUser(t, user.Name) + + req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/org/%s/repos", testCase.orgName), &api.CreateRepoOption{ + Name: testCase.repoName, + }) + session.MakeRequest(t, req, testCase.expectedStatus) + } +} |