-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,27 +365,23 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes | |
ctx := NewAPITestContext(t, baseCtx.Username, baseCtx.Reponame, auth_model.AccessTokenScopeWriteRepository) | ||
|
||
// Protect branch without any whitelisting | ||
t.Run("ProtectBranchNoWhitelist", func(t *testing.T) { | ||
doProtectBranch(ctx, "protected", "", "", "", "") | ||
}) | ||
t.Run("ProtectBranchNoWhitelist", doProtectBranch(ctx, "protected", "", "", "", "")) | ||
|
||
// Try to push without permissions, which should fail | ||
t.Run("TryPushWithoutPermissions", func(t *testing.T) { | ||
_, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "[email protected]", "User Two", "branch-data-file-") | ||
assert.NoError(t, err) | ||
doGitPushTestRepositoryFail(dstPath, "origin", "protected") | ||
doGitPushTestRepositoryFail(dstPath, "origin", "protected")(t) | ||
}) | ||
|
||
// Set up permissions for normal push but not force push | ||
t.Run("SetupNormalPushPermissions", func(t *testing.T) { | ||
doProtectBranch(ctx, "protected", baseCtx.Username, "", "", "") | ||
}) | ||
t.Run("SetupNormalPushPermissions", doProtectBranch(ctx, "protected", baseCtx.Username, "", "", "")) | ||
|
||
// Normal push should work | ||
t.Run("NormalPushWithPermissions", func(t *testing.T) { | ||
_, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "[email protected]", "User Two", "branch-data-file-") | ||
assert.NoError(t, err) | ||
doGitPushTestRepository(dstPath, "origin", "protected") | ||
doGitPushTestRepository(dstPath, "origin", "protected")(t) | ||
}) | ||
|
||
// Try to force push without force push permissions, which should fail | ||
|
@@ -395,28 +391,20 @@ func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *tes | |
_, err := generateCommitWithNewData(testFileSizeSmall, dstPath, "[email protected]", "User Two", "branch-data-file-new") | ||
assert.NoError(t, err) | ||
}) | ||
doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected") | ||
doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected")(t) | ||
}) | ||
|
||
// Set up permissions for force push but not normal push | ||
t.Run("SetupForcePushPermissions", func(t *testing.T) { | ||
doProtectBranch(ctx, "protected", "", baseCtx.Username, "", "") | ||
}) | ||
t.Run("SetupForcePushPermissions", doProtectBranch(ctx, "protected", "", baseCtx.Username, "", "")) | ||
|
||
// Try to force push without normal push permissions, which should fail | ||
t.Run("ForcePushWithoutNormalPermissions", func(t *testing.T) { | ||
doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected") | ||
}) | ||
t.Run("ForcePushWithoutNormalPermissions", doGitPushTestRepositoryFail(dstPath, "-f", "origin", "protected")) | ||
|
||
// Set up permissions for normal and force push (both are required to force push) | ||
t.Run("SetupNormalAndForcePushPermissions", func(t *testing.T) { | ||
doProtectBranch(ctx, "protected", baseCtx.Username, baseCtx.Username, "", "") | ||
}) | ||
t.Run("SetupNormalAndForcePushPermissions", doProtectBranch(ctx, "protected", baseCtx.Username, baseCtx.Username, "", "")) | ||
|
||
// Force push should now work | ||
t.Run("ForcePushWithPermissions", func(t *testing.T) { | ||
doGitPushTestRepository(dstPath, "-f", "origin", "protected") | ||
}) | ||
t.Run("ForcePushWithPermissions", doGitPushTestRepository(dstPath, "-f", "origin", "protected")) | ||
|
||
t.Run("ProtectProtectedBranchNoWhitelist", doProtectBranch(ctx, "protected", "", "", "", "")) | ||
t.Run("PushToUnprotectedBranch", doGitPushTestRepository(dstPath, "origin", "protected:unprotected")) | ||
|