diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-09-14 16:16:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-14 16:16:22 +0800 |
commit | 1739e84ac02c0384c04576a00abab9348293f9c7 (patch) | |
tree | 1015e68f36421f274d2e883ff3ddb0cb29b6af71 /integrations/editor_test.go | |
parent | be3319b3d545289b772d7a92b4b62205863954d9 (diff) | |
download | gitea-1739e84ac02c0384c04576a00abab9348293f9c7.tar.gz gitea-1739e84ac02c0384c04576a00abab9348293f9c7.zip |
improve protected branch to add whitelist support (#2451)
* improve protected branch to add whitelist support
* fix lint
* fix style check
* fix tests
* fix description on UI and import
* fix test
* bug fixed
* fix tests and languages
* move isSliceInt64Eq to util pkg; improve function names & typo
Diffstat (limited to 'integrations/editor_test.go')
-rw-r--r-- | integrations/editor_test.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/integrations/editor_test.go b/integrations/editor_test.go index 79b6bb790a..cc94edfd3f 100644 --- a/integrations/editor_test.go +++ b/integrations/editor_test.go @@ -43,16 +43,15 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { csrf := GetCSRF(t, session, "/user2/repo1/settings/branches") // Change master branch to protected - req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches?action=protected_branch", map[string]string{ - "_csrf": csrf, - "branchName": "master", - "canPush": "true", + req := NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{ + "_csrf": csrf, + "protected": "on", }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusFound) // Check if master branch has been locked successfully flashCookie := session.GetCookie("macaron_flash") assert.NotNil(t, flashCookie) - assert.EqualValues(t, flashCookie.Value, "success%3Dmaster%2BLocked%2Bsuccessfully") + assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bchanged%2Bsuccessfully.", flashCookie.Value) // Request editor page req = NewRequest(t, "GET", "/user2/repo1/_new/master/") @@ -74,6 +73,20 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) // Check body for error message assert.Contains(t, string(resp.Body), "Can not commit to protected branch 'master'.") + + // remove the protected branch + csrf = GetCSRF(t, session, "/user2/repo1/settings/branches") + // Change master branch to protected + req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/branches/master", map[string]string{ + "_csrf": csrf, + "protected": "off", + }) + resp = session.MakeRequest(t, req, http.StatusFound) + // Check if master branch has been locked successfully + flashCookie = session.GetCookie("macaron_flash") + assert.NotNil(t, flashCookie) + assert.EqualValues(t, "success%3DBranch%2Bmaster%2Bprotect%2Boptions%2Bremoved%2Bsuccessfully", flashCookie.Value) + } func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath string) *TestResponse { |