summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-04-20 08:19:13 +0900
committerGitHub <noreply@github.com>2023-04-19 19:19:13 -0400
commitda6e9f63df7411ecbe630178fd4bb694e537c453 (patch)
tree75c69ecf2d2a834d24d8fe0e6db4a25393ed922d /tests
parent94210633ae64dcd1f5f9bdb046f888be526fe2da (diff)
downloadgitea-da6e9f63df7411ecbe630178fd4bb694e537c453.tar.gz
gitea-da6e9f63df7411ecbe630178fd4bb694e537c453.zip
Add owner team permission check test (#24096)
Add test for https://github.com/go-gitea/gitea/pull/23675 Should be merged after #24117 --------- Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_org_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/integration/api_org_test.go b/tests/integration/api_org_test.go
index 84166861a7..3d1c3b2494 100644
--- a/tests/integration/api_org_test.go
+++ b/tests/integration/api_org_test.go
@@ -11,6 +11,10 @@ import (
"testing"
auth_model "code.gitea.io/gitea/models/auth"
+ "code.gitea.io/gitea/models/db"
+ org_model "code.gitea.io/gitea/models/organization"
+ "code.gitea.io/gitea/models/perm"
+ unit_model "code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
@@ -51,6 +55,22 @@ func TestAPIOrgCreate(t *testing.T) {
FullName: org.FullName,
})
+ // Check owner team permission
+ ownerTeam, _ := org_model.GetOwnerTeam(db.DefaultContext, apiOrg.ID)
+
+ for _, ut := range unit_model.AllRepoUnitTypes {
+ up := perm.AccessModeOwner
+ if ut == unit_model.TypeExternalTracker || ut == unit_model.TypeExternalWiki {
+ up = perm.AccessModeRead
+ }
+ unittest.AssertExistsAndLoadBean(t, &org_model.TeamUnit{
+ OrgID: apiOrg.ID,
+ TeamID: ownerTeam.ID,
+ Type: ut,
+ AccessMode: up,
+ })
+ }
+
req = NewRequestf(t, "GET", "/api/v1/orgs/%s?token=%s", org.UserName, token)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiOrg)