mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
Update HTTP status codes to modern codes (#18063)
* 2xx/3xx/4xx/5xx -> http.Status... * http.StatusFound -> http.StatusTemporaryRedirect * http.StatusMovedPermanently -> http.StatusPermanentRedirect
This commit is contained in:
@@ -46,7 +46,7 @@ func TestAdminEditUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSuccessfullEdit(t *testing.T, formData user_model.User) {
|
||||
makeRequest(t, formData, http.StatusFound)
|
||||
makeRequest(t, formData, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func makeRequest(t *testing.T, formData user_model.User, headerCode int) {
|
||||
|
@@ -37,7 +37,7 @@ func testAPIGetBranchProtection(t *testing.T, branchName string, expectedHTTPSta
|
||||
req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo1/branch_protections/%s?token=%s", branchName, token)
|
||||
resp := session.MakeRequest(t, req, expectedHTTPStatus)
|
||||
|
||||
if resp.Code == 200 {
|
||||
if resp.Code == http.StatusOK {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.BranchName)
|
||||
@@ -52,7 +52,7 @@ func testAPICreateBranchProtection(t *testing.T, branchName string, expectedHTTP
|
||||
})
|
||||
resp := session.MakeRequest(t, req, expectedHTTPStatus)
|
||||
|
||||
if resp.Code == 201 {
|
||||
if resp.Code == http.StatusCreated {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.BranchName)
|
||||
@@ -65,7 +65,7 @@ func testAPIEditBranchProtection(t *testing.T, branchName string, body *api.Bran
|
||||
req := NewRequestWithJSON(t, "PATCH", "/api/v1/repos/user2/repo1/branch_protections/"+branchName+"?token="+token, body)
|
||||
resp := session.MakeRequest(t, req, expectedHTTPStatus)
|
||||
|
||||
if resp.Code == 200 {
|
||||
if resp.Code == http.StatusOK {
|
||||
var branchProtection api.BranchProtection
|
||||
DecodeJSON(t, resp, &branchProtection)
|
||||
assert.EqualValues(t, branchName, branchProtection.BranchName)
|
||||
|
@@ -227,7 +227,7 @@ func doAPICreatePullRequest(ctx APITestContext, owner, repo, baseBranch, headBra
|
||||
Title: fmt.Sprintf("create a pr from %s to %s", headBranch, baseBranch),
|
||||
})
|
||||
|
||||
expected := 201
|
||||
expected := http.StatusCreated
|
||||
if ctx.ExpectedCode != 0 {
|
||||
expected = ctx.ExpectedCode
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func doAPIGetPullRequest(ctx APITestContext, owner, repo string, index int64) fu
|
||||
owner, repo, index, ctx.Token)
|
||||
req := NewRequest(t, http.MethodGet, urlStr)
|
||||
|
||||
expected := 200
|
||||
expected := http.StatusOK
|
||||
if ctx.ExpectedCode != 0 {
|
||||
expected = ctx.ExpectedCode
|
||||
}
|
||||
@@ -287,7 +287,7 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
|
||||
|
||||
expected := ctx.ExpectedCode
|
||||
if expected == 0 {
|
||||
expected = 200
|
||||
expected = http.StatusOK
|
||||
}
|
||||
|
||||
if !assert.EqualValues(t, expected, resp.Code,
|
||||
@@ -310,7 +310,7 @@ func doAPIManuallyMergePullRequest(ctx APITestContext, owner, repo, commitID str
|
||||
ctx.Session.MakeRequest(t, req, ctx.ExpectedCode)
|
||||
return
|
||||
}
|
||||
ctx.Session.MakeRequest(t, req, 200)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ func TestAPICreatePullSuccess(t *testing.T) {
|
||||
Base: "master",
|
||||
Title: "create a failure pr",
|
||||
})
|
||||
session.MakeRequest(t, req, 201)
|
||||
session.MakeRequest(t, req, http.StatusCreated)
|
||||
session.MakeRequest(t, req, http.StatusUnprocessableEntity) // second request should fail
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestAPICreatePullWithFieldsSuccess(t *testing.T) {
|
||||
|
||||
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls?token=%s", owner10.Name, repo10.Name, token), opts)
|
||||
|
||||
res := session.MakeRequest(t, req, 201)
|
||||
res := session.MakeRequest(t, req, http.StatusCreated)
|
||||
pull := new(api.PullRequest)
|
||||
DecodeJSON(t, res, pull)
|
||||
|
||||
@@ -165,7 +165,7 @@ func TestAPIEditPull(t *testing.T) {
|
||||
Title: "create a success pr",
|
||||
})
|
||||
pull := new(api.PullRequest)
|
||||
resp := session.MakeRequest(t, req, 201)
|
||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, pull)
|
||||
assert.EqualValues(t, "master", pull.Base.Name)
|
||||
|
||||
@@ -173,12 +173,12 @@ func TestAPIEditPull(t *testing.T) {
|
||||
Base: "feature/1",
|
||||
Title: "edit a this pr",
|
||||
})
|
||||
resp = session.MakeRequest(t, req, 201)
|
||||
resp = session.MakeRequest(t, req, http.StatusCreated)
|
||||
DecodeJSON(t, resp, pull)
|
||||
assert.EqualValues(t, "feature/1", pull.Base.Name)
|
||||
|
||||
req = NewRequestWithJSON(t, http.MethodPatch, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d?token=%s", owner10.Name, repo10.Name, pull.Index, token), &api.EditPullRequestOption{
|
||||
Base: "not-exist",
|
||||
})
|
||||
session.MakeRequest(t, req, 404)
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ func TestRepoLanguages(t *testing.T) {
|
||||
"content": "package main",
|
||||
"commit_choice": "direct",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// let gitea calculate language stats
|
||||
time.Sleep(time.Second)
|
||||
|
@@ -59,7 +59,7 @@ func createAttachment(t *testing.T, session *TestSession, repoURL, filename stri
|
||||
func TestCreateAnonymousAttachment(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
session := emptyTestSession(t)
|
||||
createAttachment(t, session, "user2/repo1", "image.png", generateImg(), http.StatusFound)
|
||||
createAttachment(t, session, "user2/repo1", "image.png", generateImg(), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func TestCreateIssueAttachment(t *testing.T) {
|
||||
@@ -83,7 +83,7 @@ func TestCreateIssueAttachment(t *testing.T) {
|
||||
}
|
||||
|
||||
req = NewRequestWithValues(t, "POST", link, postData)
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
test.RedirectURL(resp) // check that redirect URL exists
|
||||
|
||||
// Validate that attachment is available
|
||||
|
@@ -135,7 +135,7 @@ func addAuthSourceLDAP(t *testing.T, sshKeyAttribute string, groupMapParams ...s
|
||||
"group_team_map_removal": groupTeamMapRemoval,
|
||||
"user_uid": "DN",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func TestLDAPUserSignin(t *testing.T) {
|
||||
@@ -202,7 +202,7 @@ func TestLDAPAuthChange(t *testing.T) {
|
||||
"is_sync_enabled": "on",
|
||||
"is_active": "on",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequest(t, "GET", href)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
|
@@ -28,7 +28,7 @@ func TestChangeDefaultBranch(t *testing.T) {
|
||||
"action": "default_branch",
|
||||
"branch": "DefaultBranch",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
csrf = GetCSRF(t, session, branchesURL)
|
||||
req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
|
||||
|
@@ -110,7 +110,7 @@ func TestSessionFileCreation(t *testing.T) {
|
||||
"user_name": "user2",
|
||||
"password": userPassword,
|
||||
})
|
||||
resp = MakeRequest(t, req, http.StatusFound)
|
||||
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||
sessionID = getSessionID(t, resp)
|
||||
|
||||
assert.FileExists(t, sessionFile(tmpDir, sessionID))
|
||||
|
@@ -36,7 +36,7 @@ func TestUserDeleteAccount(t *testing.T) {
|
||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
||||
"_csrf": csrf,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
assertUserDeleted(t, 8)
|
||||
unittest.CheckConsistencyFor(t, &user_model.User{})
|
||||
@@ -51,7 +51,7 @@ func TestUserDeleteAccountStillOwnRepos(t *testing.T) {
|
||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
||||
"_csrf": csrf,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// user should not have been deleted, because the user still owns repos
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
|
@@ -34,7 +34,7 @@ func TestCreateFile(t *testing.T) {
|
||||
"content": "Content",
|
||||
"commit_choice": "direct",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
"_csrf": csrf,
|
||||
"protected": "on",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
// Check if master branch has been locked successfully
|
||||
flashCookie := session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
@@ -82,7 +82,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
"_csrf": csrf,
|
||||
"protected": "off",
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
// Check if master branch has been locked successfully
|
||||
flashCookie = session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
@@ -109,7 +109,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
|
||||
"commit_choice": "direct",
|
||||
},
|
||||
)
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Verify the change
|
||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
|
||||
@@ -139,7 +139,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
|
||||
"new_branch_name": targetBranch,
|
||||
},
|
||||
)
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Verify the change
|
||||
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
|
||||
|
@@ -24,31 +24,31 @@ func testGitSmartHTTP(t *testing.T, u *url.URL) {
|
||||
}{
|
||||
{
|
||||
p: "user2/repo1/info/refs",
|
||||
code: 200,
|
||||
code: http.StatusOK,
|
||||
},
|
||||
{
|
||||
p: "user2/repo1/HEAD",
|
||||
code: 200,
|
||||
code: http.StatusOK,
|
||||
},
|
||||
{
|
||||
p: "user2/repo1/objects/info/alternates",
|
||||
code: 404,
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
p: "user2/repo1/objects/info/http-alternates",
|
||||
code: 404,
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
p: "user2/repo1/../../custom/conf/app.ini",
|
||||
code: 404,
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
p: "user2/repo1/objects/info/../../../../custom/conf/app.ini",
|
||||
code: 404,
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
p: `user2/repo1/objects/info/..\..\..\..\custom\conf\app.ini`,
|
||||
code: 400,
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -435,7 +435,7 @@ func doProtectBranch(ctx APITestContext, branch, userToWhitelist, unprotectedFil
|
||||
"protected": "on",
|
||||
"unprotected_file_patterns": unprotectedFilePatterns,
|
||||
})
|
||||
ctx.Session.MakeRequest(t, req, http.StatusFound)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
} else {
|
||||
user, err := user_model.GetUserByName(userToWhitelist)
|
||||
assert.NoError(t, err)
|
||||
@@ -448,7 +448,7 @@ func doProtectBranch(ctx APITestContext, branch, userToWhitelist, unprotectedFil
|
||||
"whitelist_users": strconv.FormatInt(user.ID, 10),
|
||||
"unprotected_file_patterns": unprotectedFilePatterns,
|
||||
})
|
||||
ctx.Session.MakeRequest(t, req, http.StatusFound)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
// Check if master branch has been locked successfully
|
||||
flashCookie := ctx.Session.GetCookie("macaron_flash")
|
||||
|
@@ -380,7 +380,7 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
|
||||
"user_name": userName,
|
||||
"password": password,
|
||||
})
|
||||
resp = MakeRequest(t, req, http.StatusFound)
|
||||
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
ch := http.Header{}
|
||||
ch.Add("Cookie", strings.Join(resp.Header()["Set-Cookie"], ";"))
|
||||
@@ -408,7 +408,7 @@ func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
|
||||
"_csrf": doc.GetCSRF(),
|
||||
"name": fmt.Sprintf("api-testing-token-%d", tokenCounter),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
req = NewRequest(t, "GET", "/user/settings/applications")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
@@ -132,7 +132,7 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo, title, content
|
||||
"title": title,
|
||||
"content": content,
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
issueURL := test.RedirectURL(resp)
|
||||
req = NewRequest(t, "GET", issueURL)
|
||||
@@ -162,7 +162,7 @@ func testIssueAddComment(t *testing.T, session *TestSession, issueURL, content,
|
||||
"content": content,
|
||||
"status": status,
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequest(t, "GET", test.RedirectURL(resp))
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
@@ -334,16 +334,16 @@ func TestIssueRedirect(t *testing.T) {
|
||||
|
||||
// Test external tracker where style not set (shall default numeric)
|
||||
req := NewRequest(t, "GET", path.Join("org26", "repo_external_tracker", "issues", "1"))
|
||||
resp := session.MakeRequest(t, req, http.StatusFound)
|
||||
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "https://tracker.com/org26/repo_external_tracker/issues/1", test.RedirectURL(resp))
|
||||
|
||||
// Test external tracker with numeric style
|
||||
req = NewRequest(t, "GET", path.Join("org26", "repo_external_tracker_numeric", "issues", "1"))
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "https://tracker.com/org26/repo_external_tracker_numeric/issues/1", test.RedirectURL(resp))
|
||||
|
||||
// Test external tracker with alphanumeric style (for a pull request)
|
||||
req = NewRequest(t, "GET", path.Join("org26", "repo_external_tracker_alpha", "issues", "1"))
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "/"+path.Join("org26", "repo_external_tracker_alpha", "pulls", "1"), test.RedirectURL(resp))
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ func TestRedirectsNoLogin(t *testing.T) {
|
||||
}
|
||||
for link, redirectLink := range redirects {
|
||||
req := NewRequest(t, "GET", link)
|
||||
resp := MakeRequest(t, req, http.StatusFound)
|
||||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
|
||||
}
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ func doCreatePushMirror(ctx APITestContext, address, username, password string)
|
||||
"push_mirror_password": password,
|
||||
"push_mirror_interval": "0",
|
||||
})
|
||||
ctx.Session.MakeRequest(t, req, http.StatusFound)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
flashCookie := ctx.Session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
@@ -110,7 +110,7 @@ func doRemovePushMirror(ctx APITestContext, address, username, password string,
|
||||
"push_mirror_password": password,
|
||||
"push_mirror_interval": "0",
|
||||
})
|
||||
ctx.Session.MakeRequest(t, req, http.StatusFound)
|
||||
ctx.Session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
flashCookie := ctx.Session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
|
@@ -18,7 +18,7 @@ func testSrcRouteRedirect(t *testing.T, session *TestSession, user, repo, route,
|
||||
|
||||
// Make request
|
||||
req := NewRequest(t, "GET", path.Join(prefix, route))
|
||||
resp := session.MakeRequest(t, req, http.StatusFound)
|
||||
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Check Location header
|
||||
location := resp.HeaderMap.Get("Location")
|
||||
@@ -37,7 +37,7 @@ func setDefaultBranch(t *testing.T, session *TestSession, user, repo, branch str
|
||||
"action": "default_branch",
|
||||
"branch": branch,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func TestNonasciiBranches(t *testing.T) {
|
||||
|
@@ -7,6 +7,7 @@ package integrations
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
@@ -21,20 +22,20 @@ func TestNoClientID(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
req := NewRequest(t, "GET", "/login/oauth/authorize")
|
||||
ctx := loginUser(t, "user2")
|
||||
ctx.MakeRequest(t, req, 400)
|
||||
ctx.MakeRequest(t, req, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func TestLoginRedirect(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
req := NewRequest(t, "GET", "/login/oauth/authorize")
|
||||
assert.Contains(t, MakeRequest(t, req, 302).Body.String(), "/user/login")
|
||||
assert.Contains(t, MakeRequest(t, req, http.StatusSeeOther).Body.String(), "/user/login")
|
||||
}
|
||||
|
||||
func TestShowAuthorize(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
req := NewRequest(t, "GET", defaultAuthorize)
|
||||
ctx := loginUser(t, "user4")
|
||||
resp := ctx.MakeRequest(t, req, 200)
|
||||
resp := ctx.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
htmlDoc.AssertElement(t, "#authorize-app", true)
|
||||
@@ -45,7 +46,7 @@ func TestRedirectWithExistingGrant(t *testing.T) {
|
||||
defer prepareTestEnv(t)()
|
||||
req := NewRequest(t, "GET", defaultAuthorize)
|
||||
ctx := loginUser(t, "user1")
|
||||
resp := ctx.MakeRequest(t, req, 302)
|
||||
resp := ctx.MakeRequest(t, req, http.StatusSeeOther)
|
||||
u, err := resp.Result().Location()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "thestate", u.Query().Get("state"))
|
||||
@@ -62,7 +63,7 @@ func TestAccessTokenExchange(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
resp := MakeRequest(t, req, 200)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
type response struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
@@ -86,7 +87,7 @@ func TestAccessTokenExchangeWithoutPKCE(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
resp := MakeRequest(t, req, 200)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
type response struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
@@ -109,7 +110,7 @@ func TestAccessTokenExchangeJSON(t *testing.T) {
|
||||
"redirect_uri": "a",
|
||||
"code": "authcode",
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
@@ -123,7 +124,7 @@ func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
// invalid client secret
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
|
||||
"grant_type": "authorization_code",
|
||||
@@ -133,7 +134,7 @@ func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
// invalid redirect uri
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
|
||||
"grant_type": "authorization_code",
|
||||
@@ -143,7 +144,7 @@ func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
// invalid authorization code
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
|
||||
"grant_type": "authorization_code",
|
||||
@@ -153,7 +154,7 @@ func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
"code": "???",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
// invalid grant_type
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
|
||||
"grant_type": "???",
|
||||
@@ -163,7 +164,7 @@ func TestAccessTokenExchangeWithInvalidCredentials(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
MakeRequest(t, req, 400)
|
||||
MakeRequest(t, req, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
|
||||
@@ -175,7 +176,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
req.Header.Add("Authorization", "Basic ZGE3ZGEzYmEtOWExMy00MTY3LTg1NmYtMzg5OWRlMGIwMTM4OjRNSzhOYTZSNTVzbWRDWTBXdUNDdW1aNmhqUlBuR1k1c2FXVlJISGpKaUE9")
|
||||
resp := MakeRequest(t, req, 200)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
type response struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
@@ -196,7 +197,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
req.Header.Add("Authorization", "Basic ZGE3ZGEzYmEtOWExMy00MTY3LTg1NmYtMzg5OWRlMGIwMTM4OmJsYWJsYQ==")
|
||||
resp = MakeRequest(t, req, 400)
|
||||
resp = MakeRequest(t, req, http.StatusBadRequest)
|
||||
|
||||
// missing header
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
|
||||
@@ -205,7 +206,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
resp = MakeRequest(t, req, 400)
|
||||
resp = MakeRequest(t, req, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func TestRefreshTokenInvalidation(t *testing.T) {
|
||||
@@ -218,7 +219,7 @@ func TestRefreshTokenInvalidation(t *testing.T) {
|
||||
"code": "authcode",
|
||||
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
|
||||
})
|
||||
resp := MakeRequest(t, req, 200)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
type response struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
TokenType string `json:"token_type"`
|
||||
@@ -244,16 +245,16 @@ func TestRefreshTokenInvalidation(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
refreshReq.Body = io.NopCloser(bytes.NewReader(bs))
|
||||
MakeRequest(t, refreshReq, 200)
|
||||
MakeRequest(t, refreshReq, http.StatusOK)
|
||||
|
||||
refreshReq.Body = io.NopCloser(bytes.NewReader(bs))
|
||||
MakeRequest(t, refreshReq, 200)
|
||||
MakeRequest(t, refreshReq, http.StatusOK)
|
||||
|
||||
// test with invalidation
|
||||
setting.OAuth2.InvalidateRefreshTokens = true
|
||||
refreshReq.Body = io.NopCloser(bytes.NewReader(bs))
|
||||
MakeRequest(t, refreshReq, 200)
|
||||
MakeRequest(t, refreshReq, http.StatusOK)
|
||||
|
||||
refreshReq.Body = io.NopCloser(bytes.NewReader(bs))
|
||||
MakeRequest(t, refreshReq, 400)
|
||||
MakeRequest(t, refreshReq, http.StatusBadRequest)
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ func testPrivateActivityHelperEnablePrivateActivity(t *testing.T) {
|
||||
"language": "en-US",
|
||||
"keep_activity_private": "1",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func testPrivateActivityHelperHasVisibleActivitiesInHTMLDoc(htmlDoc *HTMLDoc) bool {
|
||||
|
@@ -38,7 +38,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, titl
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"title": title,
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func testDeleteRepository(t *testing.T, session *TestSession, ownerName, repoNam
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"repo_name": repoName,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func TestPullBranchDelete(t *testing.T) {
|
||||
@@ -139,7 +139,7 @@ func TestPullBranchDelete(t *testing.T) {
|
||||
|
||||
session := loginUser(t, "user1")
|
||||
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
|
||||
testCreateBranch(t, session, "user1", "repo1", "branch/master", "master1", http.StatusFound)
|
||||
testCreateBranch(t, session, "user1", "repo1", "branch/master", "master1", http.StatusSeeOther)
|
||||
testEditFile(t, session, "user1", "repo1", "master1", "README.md", "Hello, World (Edited)\n")
|
||||
resp := testPullCreate(t, session, "user1", "repo1", "master1", "This is a pull title")
|
||||
|
||||
|
@@ -42,7 +42,7 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"do": string(mergeStyle),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func TestCantMergeConflict(t *testing.T) {
|
||||
Base: "base",
|
||||
Title: "create a conflicting pr",
|
||||
})
|
||||
session.MakeRequest(t, req, 201)
|
||||
session.MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
// Now this PR will be marked conflict - or at least a race will do - so drop down to pure code at this point...
|
||||
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
@@ -330,7 +330,7 @@ func TestCantMergeUnrelated(t *testing.T) {
|
||||
Base: "base",
|
||||
Title: "create an unrelated pr",
|
||||
})
|
||||
session.MakeRequest(t, req, 201)
|
||||
session.MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
// Now this PR could be marked conflict - or at least a race may occur - so drop down to pure code at this point...
|
||||
gitRepo, err := git.OpenRepository(path)
|
||||
|
@@ -29,7 +29,7 @@ func TestPullCreate_CommitStatus(t *testing.T) {
|
||||
"title": "pull request from status1",
|
||||
},
|
||||
)
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequest(t, "GET", "/user1/repo1/pulls")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
@@ -108,7 +108,7 @@ func TestPullCreate_EmptyChangesWithCommits(t *testing.T) {
|
||||
"title": "pull request from status1",
|
||||
},
|
||||
)
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequest(t, "GET", "/user1/repo1/pulls/1")
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
@@ -43,7 +43,7 @@ func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title st
|
||||
}
|
||||
req = NewRequestWithValues(t, "POST", link, postData)
|
||||
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
test.RedirectURL(resp) // check that redirect URL exists
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ func TestRenameBranch(t *testing.T) {
|
||||
"to": "main",
|
||||
}
|
||||
req = NewRequestWithValues(t, "POST", "/user2/repo1/settings/rename_branch", postData)
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// check new branch link
|
||||
req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/main/README.md", postData)
|
||||
@@ -35,7 +35,7 @@ func TestRenameBranch(t *testing.T) {
|
||||
|
||||
// check old branch link
|
||||
req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/master/README.md", postData)
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
location := resp.HeaderMap.Get("Location")
|
||||
assert.Equal(t, "/user2/repo1/src/branch/main/README.md", location)
|
||||
|
||||
|
@@ -30,7 +30,7 @@ func testCreateBranch(t testing.TB, session *TestSession, user, repo, oldRefSubU
|
||||
"new_branch_name": newBranchName,
|
||||
})
|
||||
resp := session.MakeRequest(t, req, expectedStatus)
|
||||
if expectedStatus != http.StatusFound {
|
||||
if expectedStatus != http.StatusSeeOther {
|
||||
return ""
|
||||
}
|
||||
return test.RedirectURL(resp)
|
||||
@@ -51,37 +51,37 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) {
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "feature/test1",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test1"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.require_error"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "feature=test1",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature=test1"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: strings.Repeat("b", 101),
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.max_size_error", "100"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "master",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.branch_already_exists", "master"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "master/test",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.branch_name_conflict", "master/test", "master"),
|
||||
},
|
||||
{
|
||||
@@ -92,21 +92,21 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) {
|
||||
{
|
||||
OldRefSubURL: "commit/65f1bf27bc3bf70f64657658635e66094edbcb4d",
|
||||
NewBranch: "feature/test3",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test3"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "branch/master",
|
||||
NewBranch: "v1.0.0",
|
||||
CreateRelease: "v1.0.0",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.tag_collision", "v1.0.0"),
|
||||
},
|
||||
{
|
||||
OldRefSubURL: "tag/v1.0.0",
|
||||
NewBranch: "feature/test4",
|
||||
CreateRelease: "v1.0.1",
|
||||
ExpectedStatus: http.StatusFound,
|
||||
ExpectedStatus: http.StatusSeeOther,
|
||||
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test4"),
|
||||
},
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func testCreateBranches(t *testing.T, giteaURL *url.URL) {
|
||||
createNewRelease(t, session, "/user2/repo1", test.CreateRelease, test.CreateRelease, false, false)
|
||||
}
|
||||
redirectURL := testCreateBranch(t, session, "user2", "repo1", test.OldRefSubURL, test.NewBranch, test.ExpectedStatus)
|
||||
if test.ExpectedStatus == http.StatusFound {
|
||||
if test.ExpectedStatus == http.StatusSeeOther {
|
||||
req := NewRequest(t, "GET", redirectURL)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
@@ -135,7 +135,7 @@ func TestCreateBranchInvalidCSRF(t *testing.T) {
|
||||
"_csrf": "fake_csrf",
|
||||
"new_branch_name": "test",
|
||||
})
|
||||
resp := session.MakeRequest(t, req, http.StatusFound)
|
||||
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
loc := resp.Header().Get("Location")
|
||||
assert.Equal(t, setting.AppSubURL+"/", loc)
|
||||
resp = session.MakeRequest(t, NewRequest(t, "GET", loc), http.StatusOK)
|
||||
|
@@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
|
||||
"uid": fmt.Sprintf("%d", forkOwner.ID),
|
||||
"repo_name": forkRepoName,
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Step4: check the existence of the forked repo
|
||||
req = NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
|
||||
|
@@ -46,7 +46,7 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateOwnerName, tem
|
||||
"repo_name": generateRepoName,
|
||||
"git_content": "true",
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Step4: check the existence of the generated repo
|
||||
req = NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
|
||||
|
@@ -33,7 +33,7 @@ func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName str
|
||||
"repo_name": repoName,
|
||||
"service": fmt.Sprintf("%d", structs.PlainGitService),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
return resp
|
||||
}
|
||||
|
@@ -90,17 +90,17 @@ func TestSettingLandingPage(t *testing.T) {
|
||||
|
||||
setting.LandingPageURL = setting.LandingPageExplore
|
||||
req = NewRequest(t, "GET", "/")
|
||||
resp := MakeRequest(t, req, http.StatusFound)
|
||||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "/explore", resp.Header().Get("Location"))
|
||||
|
||||
setting.LandingPageURL = setting.LandingPageOrganizations
|
||||
req = NewRequest(t, "GET", "/")
|
||||
resp = MakeRequest(t, req, http.StatusFound)
|
||||
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "/explore/organizations", resp.Header().Get("Location"))
|
||||
|
||||
setting.LandingPageURL = setting.LandingPageLogin
|
||||
req = NewRequest(t, "GET", "/")
|
||||
resp = MakeRequest(t, req, http.StatusFound)
|
||||
resp = MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, "/user/login", resp.Header().Get("Location"))
|
||||
|
||||
setting.LandingPageURL = landingPage
|
||||
|
@@ -15,7 +15,7 @@ func TestSignOut(t *testing.T) {
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
req := NewRequest(t, "POST", "/user/logout")
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// try to view a private repo, should fail
|
||||
req = NewRequest(t, "GET", "/user2/repo2")
|
||||
|
@@ -29,7 +29,7 @@ func TestSignup(t *testing.T) {
|
||||
"password": "examplePassword!1",
|
||||
"retype": "examplePassword!1",
|
||||
})
|
||||
MakeRequest(t, req, http.StatusFound)
|
||||
MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// should be able to view new user's page
|
||||
req = NewRequest(t, "GET", "/exampleUser")
|
||||
@@ -48,7 +48,7 @@ func TestSignupAsRestricted(t *testing.T) {
|
||||
"password": "examplePassword!1",
|
||||
"retype": "examplePassword!1",
|
||||
})
|
||||
MakeRequest(t, req, http.StatusFound)
|
||||
MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// should be able to view new user's page
|
||||
req = NewRequest(t, "GET", "/restrictedUser")
|
||||
@@ -71,7 +71,7 @@ func TestSignupEmail(t *testing.T) {
|
||||
{"exampleUser@example.com\r\n", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
|
||||
{"exampleUser@example.com\r", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
|
||||
{"exampleUser@example.com\n", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
|
||||
{"exampleUser@example.com", http.StatusFound, ""},
|
||||
{"exampleUser@example.com", http.StatusSeeOther, ""},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
@@ -70,7 +70,7 @@ func TestUserAvatar(t *testing.T) {
|
||||
req.Header.Add("X-Csrf-Token", csrf)
|
||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) // owner of the repo3, is an org
|
||||
|
||||
|
@@ -33,7 +33,7 @@ func TestRenameUsername(t *testing.T) {
|
||||
"email": "user2@example.com",
|
||||
"language": "en-US",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "newUsername"})
|
||||
unittest.AssertNotExistsBean(t, &user_model.User{Name: "user2"})
|
||||
@@ -103,7 +103,7 @@ func TestRenameReservedUsername(t *testing.T) {
|
||||
"email": "user2@example.com",
|
||||
"language": "en-US",
|
||||
})
|
||||
resp := session.MakeRequest(t, req, http.StatusFound)
|
||||
resp := session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequest(t, "GET", test.RedirectURL(resp))
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
|
@@ -27,7 +27,7 @@ func TestXSSUserFullName(t *testing.T) {
|
||||
"email": user.Email,
|
||||
"language": "en-US",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
req = NewRequestf(t, "GET", "/%s", user.Name)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
Reference in New Issue
Block a user