aboutsummaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-03-01 01:47:30 +0100
committerGitHub <noreply@github.com>2021-03-01 01:47:30 +0100
commita4148c0f12fe5a93d2c9a40f24d4813bcfef4ff8 (patch)
tree92edf61ff2447e067a676832844a129050b4ec0f /integrations
parente0900310c4354311362ef69d15c302c215eaa2a2 (diff)
downloadgitea-a4148c0f12fe5a93d2c9a40f24d4813bcfef4ff8.tar.gz
gitea-a4148c0f12fe5a93d2c9a40f24d4813bcfef4ff8.zip
Repository transfer has to be confirmed, if user can not create repo for new owner (#14792)
* make repo as "pending transfer" if on transfer start doer has no right to create repo in new destination * if new pending transfer ocured, create UI & Mail notifications
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_repo_test.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go
index b6d41fe1e0..3404e050cf 100644
--- a/integrations/api_repo_test.go
+++ b/integrations/api_repo_test.go
@@ -444,12 +444,22 @@ func TestAPIRepoTransfer(t *testing.T) {
teams *[]int64
expectedStatus int
}{
- {ctxUserID: 1, newOwner: "user2", teams: nil, expectedStatus: http.StatusAccepted},
- {ctxUserID: 2, newOwner: "user1", teams: nil, expectedStatus: http.StatusAccepted},
- {ctxUserID: 2, newOwner: "user6", teams: nil, expectedStatus: http.StatusForbidden},
- {ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity},
+ // Disclaimer for test story: "user1" is an admin, "user2" is normal user and part of in owner team of org "user3"
+
+ // Transfer to a user with teams in another org should fail
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
+ // Transfer to a user with non-existent team IDs should fail
+ {ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity},
+ // Transfer should go through
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted},
+ // Let user transfer it back to himself
+ {ctxUserID: 2, newOwner: "user2", expectedStatus: http.StatusAccepted},
+ // And revert transfer
+ {ctxUserID: 2, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted},
+ // Cannot start transfer to an existing repo
+ {ctxUserID: 2, newOwner: "user3", teams: nil, expectedStatus: http.StatusUnprocessableEntity},
+ // Start transfer, repo is now in pending transfer mode
+ {ctxUserID: 2, newOwner: "user6", teams: nil, expectedStatus: http.StatusCreated},
}
defer prepareTestEnv(t)()