From a4148c0f12fe5a93d2c9a40f24d4813bcfef4ff8 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 1 Mar 2021 01:47:30 +0100 Subject: 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 --- integrations/api_repo_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'integrations') 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)() -- cgit v1.2.3