From 9cffb87d8bea9548ec047e4b792b4ee45f721036 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 30 Nov 2022 15:23:02 +0800 Subject: [PATCH 1/4] Remove session in api tests --- tests/integration/api_admin_org_test.go | 6 +- tests/integration/api_admin_test.go | 62 ++++++++----------- tests/integration/api_branch_test.go | 32 ++++------ tests/integration/api_comment_test.go | 35 +++++------ tests/integration/api_gpg_keys_test.go | 12 ++-- tests/integration/api_httpsig_test.go | 4 +- tests/integration/api_issue_label_test.go | 36 +++++------ tests/integration/api_issue_milestone_test.go | 14 ++--- tests/integration/api_issue_reaction_test.go | 20 +++--- tests/integration/api_issue_stopwatch_test.go | 14 ++--- .../api_issue_subscription_test.go | 10 +-- tests/integration/api_issue_test.go | 14 ++--- .../api_issue_tracked_time_test.go | 16 ++--- tests/integration/api_keys_test.go | 20 +++--- tests/integration/api_notification_test.go | 30 ++++----- tests/integration/api_oauth2_apps_test.go | 8 +-- tests/integration/api_org_test.go | 4 +- .../api_packages_container_test.go | 4 +- tests/integration/api_pull_commits_test.go | 2 +- tests/integration/api_pull_review_test.go | 52 ++++++++-------- tests/integration/api_pull_test.go | 22 +++---- tests/integration/api_releases_test.go | 16 ++--- .../integration/api_repo_collaborator_test.go | 10 +-- tests/integration/api_repo_edit_test.go | 44 ++++++------- .../integration/api_repo_file_create_test.go | 22 +++---- .../integration/api_repo_file_delete_test.go | 20 +++--- .../integration/api_repo_file_update_test.go | 22 +++---- .../api_repo_get_contents_list_test.go | 18 +++--- .../integration/api_repo_get_contents_test.go | 18 +++--- tests/integration/api_repo_git_blobs_test.go | 16 ++--- .../integration/api_repo_git_commits_test.go | 20 +++--- tests/integration/api_repo_git_notes_test.go | 6 +- tests/integration/api_repo_git_ref_test.go | 6 +- tests/integration/api_repo_git_tags_test.go | 8 +-- tests/integration/api_repo_git_trees_test.go | 14 ++--- tests/integration/api_repo_languages_test.go | 6 +- tests/integration/api_repo_lfs_locks_test.go | 10 +-- tests/integration/api_repo_lfs_test.go | 44 ++++++------- tests/integration/api_repo_raw_test.go | 4 +- tests/integration/api_repo_tags_test.go | 12 ++-- tests/integration/api_repo_teams_test.go | 16 ++--- tests/integration/api_repo_test.go | 38 ++++++------ tests/integration/api_team_test.go | 26 ++++---- tests/integration/api_team_user_test.go | 4 +- tests/integration/api_user_email_test.go | 14 ++--- tests/integration/api_user_org_perm_test.go | 8 +-- tests/integration/api_user_orgs_test.go | 6 +- tests/integration/api_user_search_test.go | 4 +- tests/integration/api_wiki_test.go | 10 +-- 49 files changed, 417 insertions(+), 442 deletions(-) diff --git a/tests/integration/api_admin_org_test.go b/tests/integration/api_admin_org_test.go index 9710163330474..05825eff316ef 100644 --- a/tests/integration/api_admin_org_test.go +++ b/tests/integration/api_admin_org_test.go @@ -31,7 +31,7 @@ func TestAPIAdminOrgCreate(t *testing.T) { Visibility: "private", } req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var apiOrg api.Organization DecodeJSON(t, resp, &apiOrg) @@ -65,7 +65,7 @@ func TestAPIAdminOrgCreateBadVisibility(t *testing.T) { Visibility: "notvalid", } req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) } @@ -83,5 +83,5 @@ func TestAPIAdminOrgCreateNotAdmin(t *testing.T) { Visibility: "public", } req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) } diff --git a/tests/integration/api_admin_test.go b/tests/integration/api_admin_test.go index 2a487fb83ad06..53952210fd95a 100644 --- a/tests/integration/api_admin_test.go +++ b/tests/integration/api_admin_test.go @@ -30,7 +30,7 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4cn+iXnA4KvcQYSV88vGn0Yi91vG47t1P7okprVmhNTkipNRIHWr6WdCO4VDr/cvsRkuVJAsLO2enwjGWWueOO6BodiBgyAOZ/5t5nJNMCNuLGT5UIo/RI1b0WRQwxEZTRjt6mFNw6lH14wRd8ulsr9toSWBPMOGWoYs1PDeDL0JuTjL+tr1SZi/EyxCngpYszKdXllJEHyI79KQgeD0Vt3pTrkbNVTOEcCNqZePSVmUH8X8Vhugz3bnE0/iE9Pb5fkWO9c4AnM1FgI/8Bvp27Fw2ShryIXuR6kKvUqhVMTuOSDHwu6A8jLE5Owt3GAYugDpDYuwTVNGrHLXKpPzrGGPE/jPmaLCMZcsdkec95dYeU3zKODEm8UQZFhmJmDeWVJ36nGrGZHL4J5aTTaeFUJmmXDaJYiJ+K2/ioKgXqnXvltu0A9R8/LGy4nrTJRr4JMLuJFoUXvGm1gXQ70w2LSpk6yl71RNC0hCtsBe8BP8IhYCM0EP5jh7eCMQZNvM= nocomment\n", "title": "test-key", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newPublicKey api.PublicKey DecodeJSON(t, resp, &newPublicKey) @@ -43,53 +43,49 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) { req = NewRequestf(t, "DELETE", "/api/v1/admin/users/%s/keys/%d?token=%s", keyOwner.Name, newPublicKey.ID, token) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) unittest.AssertNotExistsBean(t, &asymkey_model.PublicKey{ID: newPublicKey.ID}) } func TestAPIAdminDeleteMissingSSHKey(t *testing.T) { defer tests.PrepareTestEnv(t)() - // user1 is an admin user - session := loginUser(t, "user1") - token := getTokenForLoggedInUser(t, session) + // user1 is an admin user + token := getUserToken(t, "user1") req := NewRequestf(t, "DELETE", "/api/v1/admin/users/user1/keys/%d?token=%s", unittest.NonexistentID, token) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } func TestAPIAdminDeleteUnauthorizedKey(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" normalUsername := "user2" - session := loginUser(t, adminUsername) + token := getUserToken(t, adminUsername) - token := getTokenForLoggedInUser(t, session) urlStr := fmt.Sprintf("/api/v1/admin/users/%s/keys?token=%s", adminUsername, token) req := NewRequestWithValues(t, "POST", urlStr, map[string]string{ "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4cn+iXnA4KvcQYSV88vGn0Yi91vG47t1P7okprVmhNTkipNRIHWr6WdCO4VDr/cvsRkuVJAsLO2enwjGWWueOO6BodiBgyAOZ/5t5nJNMCNuLGT5UIo/RI1b0WRQwxEZTRjt6mFNw6lH14wRd8ulsr9toSWBPMOGWoYs1PDeDL0JuTjL+tr1SZi/EyxCngpYszKdXllJEHyI79KQgeD0Vt3pTrkbNVTOEcCNqZePSVmUH8X8Vhugz3bnE0/iE9Pb5fkWO9c4AnM1FgI/8Bvp27Fw2ShryIXuR6kKvUqhVMTuOSDHwu6A8jLE5Owt3GAYugDpDYuwTVNGrHLXKpPzrGGPE/jPmaLCMZcsdkec95dYeU3zKODEm8UQZFhmJmDeWVJ36nGrGZHL4J5aTTaeFUJmmXDaJYiJ+K2/ioKgXqnXvltu0A9R8/LGy4nrTJRr4JMLuJFoUXvGm1gXQ70w2LSpk6yl71RNC0hCtsBe8BP8IhYCM0EP5jh7eCMQZNvM= nocomment\n", "title": "test-key", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newPublicKey api.PublicKey DecodeJSON(t, resp, &newPublicKey) - session = loginUser(t, normalUsername) - token = getTokenForLoggedInUser(t, session) + token = getUserToken(t, normalUsername) req = NewRequestf(t, "DELETE", "/api/v1/admin/users/%s/keys/%d?token=%s", adminUsername, newPublicKey.ID, token) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) } func TestAPISudoUser(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" normalUsername := "user2" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) urlStr := fmt.Sprintf("/api/v1/user?sudo=%s&token=%s", normalUsername, token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var user api.User DecodeJSON(t, resp, &user) @@ -101,23 +97,20 @@ func TestAPISudoUserForbidden(t *testing.T) { adminUsername := "user1" normalUsername := "user2" - session := loginUser(t, normalUsername) - token := getTokenForLoggedInUser(t, session) - + token := getUserToken(t, normalUsername) urlStr := fmt.Sprintf("/api/v1/user?sudo=%s&token=%s", adminUsername, token) req := NewRequest(t, "GET", urlStr) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) } func TestAPIListUsers(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) urlStr := fmt.Sprintf("/api/v1/admin/users?token=%s", token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var users []api.User DecodeJSON(t, resp, &users) @@ -141,17 +134,15 @@ func TestAPIListUsersNotLoggedIn(t *testing.T) { func TestAPIListUsersNonAdmin(t *testing.T) { defer tests.PrepareTestEnv(t)() nonAdminUsername := "user2" - session := loginUser(t, nonAdminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, nonAdminUsername) req := NewRequestf(t, "GET", "/api/v1/admin/users?token=%s", token) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) } func TestAPICreateUserInvalidEmail(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) urlStr := fmt.Sprintf("/api/v1/admin/users?token=%s", token) req := NewRequestWithValues(t, "POST", urlStr, map[string]string{ "email": "invalid_email@domain.com\r\n", @@ -163,14 +154,13 @@ func TestAPICreateUserInvalidEmail(t *testing.T) { "source_id": "0", "username": "invalidUser", }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) } func TestAPICreateAndDeleteUser(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) req := NewRequestWithValues( t, @@ -196,8 +186,7 @@ func TestAPICreateAndDeleteUser(t *testing.T) { func TestAPIEditUser(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) urlStr := fmt.Sprintf("/api/v1/admin/users/%s?token=%s", "user2", token) req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{ @@ -207,7 +196,7 @@ func TestAPIEditUser(t *testing.T) { // to change "full_name": "Full Name User 2", }) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) empty := "" req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{ @@ -215,7 +204,7 @@ func TestAPIEditUser(t *testing.T) { SourceID: 0, Email: &empty, }) - resp := session.MakeRequest(t, req, http.StatusUnprocessableEntity) + resp := MakeRequest(t, req, http.StatusUnprocessableEntity) errMap := make(map[string]interface{}) json.Unmarshal(resp.Body.Bytes(), &errMap) @@ -231,7 +220,7 @@ func TestAPIEditUser(t *testing.T) { // to change Restricted: &bTrue, }) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"}) assert.True(t, user2.IsRestricted) } @@ -239,8 +228,7 @@ func TestAPIEditUser(t *testing.T) { func TestAPICreateRepoForUser(t *testing.T) { defer tests.PrepareTestEnv(t)() adminUsername := "user1" - session := loginUser(t, adminUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, adminUsername) req := NewRequestWithJSON( t, diff --git a/tests/integration/api_branch_test.go b/tests/integration/api_branch_test.go index 1fa757d9d8674..c176a144ca6e9 100644 --- a/tests/integration/api_branch_test.go +++ b/tests/integration/api_branch_test.go @@ -15,10 +15,9 @@ import ( ) func testAPIGetBranch(t *testing.T, branchName string, exists bool) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo1/branches/%s?token=%s", branchName, token) - resp := session.MakeRequest(t, req, NoExpectedStatus) + resp := MakeRequest(t, req, NoExpectedStatus) if !exists { assert.EqualValues(t, http.StatusNotFound, resp.Code) return @@ -32,10 +31,9 @@ func testAPIGetBranch(t *testing.T, branchName string, exists bool) { } func testAPIGetBranchProtection(t *testing.T, branchName string, expectedHTTPStatus int) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo1/branch_protections/%s?token=%s", branchName, token) - resp := session.MakeRequest(t, req, expectedHTTPStatus) + resp := MakeRequest(t, req, expectedHTTPStatus) if resp.Code == http.StatusOK { var branchProtection api.BranchProtection @@ -45,12 +43,11 @@ func testAPIGetBranchProtection(t *testing.T, branchName string, expectedHTTPSta } func testAPICreateBranchProtection(t *testing.T, branchName string, expectedHTTPStatus int) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/repo1/branch_protections?token="+token, &api.BranchProtection{ BranchName: branchName, }) - resp := session.MakeRequest(t, req, expectedHTTPStatus) + resp := MakeRequest(t, req, expectedHTTPStatus) if resp.Code == http.StatusCreated { var branchProtection api.BranchProtection @@ -60,10 +57,9 @@ func testAPICreateBranchProtection(t *testing.T, branchName string, expectedHTTP } func testAPIEditBranchProtection(t *testing.T, branchName string, body *api.BranchProtection, expectedHTTPStatus int) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestWithJSON(t, "PATCH", "/api/v1/repos/user2/repo1/branch_protections/"+branchName+"?token="+token, body) - resp := session.MakeRequest(t, req, expectedHTTPStatus) + resp := MakeRequest(t, req, expectedHTTPStatus) if resp.Code == http.StatusOK { var branchProtection api.BranchProtection @@ -73,17 +69,15 @@ func testAPIEditBranchProtection(t *testing.T, branchName string, body *api.Bran } func testAPIDeleteBranchProtection(t *testing.T, branchName string, expectedHTTPStatus int) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestf(t, "DELETE", "/api/v1/repos/user2/repo1/branch_protections/%s?token=%s", branchName, token) - session.MakeRequest(t, req, expectedHTTPStatus) + MakeRequest(t, req, expectedHTTPStatus) } func testAPIDeleteBranch(t *testing.T, branchName string, expectedHTTPStatus int) { - session := loginUser(t, "user2") - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, "user2") req := NewRequestf(t, "DELETE", "/api/v1/repos/user2/repo1/branches/%s?token=%s", branchName, token) - session.MakeRequest(t, req, expectedHTTPStatus) + MakeRequest(t, req, expectedHTTPStatus) } func TestAPIGetBranch(t *testing.T) { @@ -160,7 +154,7 @@ func testAPICreateBranch(t testing.TB, session *TestSession, user, repo, oldBran BranchName: newBranch, OldBranchName: oldBranch, }) - resp := session.MakeRequest(t, req, status) + resp := MakeRequest(t, req, status) var branch api.Branch DecodeJSON(t, resp, &branch) diff --git a/tests/integration/api_comment_test.go b/tests/integration/api_comment_test.go index ef21d7f901864..edd4da88c11c9 100644 --- a/tests/integration/api_comment_test.go +++ b/tests/integration/api_comment_test.go @@ -30,10 +30,9 @@ func TestAPIListRepoComments(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) link, _ := url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments", repoOwner.Name, repo.Name)) req := NewRequest(t, "GET", link.String()) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiComments []*api.Comment DecodeJSON(t, resp, &apiComments) @@ -52,7 +51,7 @@ func TestAPIListRepoComments(t *testing.T) { query.Add("before", before) link.RawQuery = query.Encode() req = NewRequest(t, "GET", link.String()) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiComments) assert.Len(t, apiComments, 1) assert.EqualValues(t, 2, apiComments[0].ID) @@ -61,7 +60,7 @@ func TestAPIListRepoComments(t *testing.T) { query.Add("since", since) link.RawQuery = query.Encode() req = NewRequest(t, "GET", link.String()) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiComments) assert.Len(t, apiComments, 1) assert.EqualValues(t, 3, apiComments[0].ID) @@ -76,10 +75,9 @@ func TestAPIListIssueComments(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/%d/comments", repoOwner.Name, repo.Name, issue.Index) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var comments []*api.Comment DecodeJSON(t, resp, &comments) @@ -96,14 +94,13 @@ func TestAPICreateComment(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, repoOwner.Name) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments?token=%s", repoOwner.Name, repo.Name, issue.Index, token) req := NewRequestWithValues(t, "POST", urlStr, map[string]string{ "body": commentBody, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var updatedComment api.Comment DecodeJSON(t, resp, &updatedComment) @@ -119,12 +116,11 @@ func TestAPIGetComment(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: comment.Issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, repoOwner.Name) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d", repoOwner.Name, repo.Name, comment.ID) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiComment api.Comment DecodeJSON(t, resp, &apiComment) @@ -148,14 +144,13 @@ func TestAPIEditComment(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, repoOwner.Name) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token) req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{ "body": newCommentBody, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var updatedComment api.Comment DecodeJSON(t, resp, &updatedComment) @@ -173,11 +168,10 @@ func TestAPIDeleteComment(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}) repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, repoOwner.Name) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, repoOwner.Name) req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) unittest.AssertNotExistsBean(t, &issues_model.Comment{ID: comment.ID}) } @@ -191,10 +185,9 @@ func TestAPIListIssueTimeline(t *testing.T) { repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) // make request - session := loginUser(t, repoOwner.Name) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/%d/timeline", repoOwner.Name, repo.Name, issue.Index) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) // check if lens of list returned by API and // lists extracted directly from DB are the same diff --git a/tests/integration/api_gpg_keys_test.go b/tests/integration/api_gpg_keys_test.go index 9e1641d3b914d..162a5a4fd55e8 100644 --- a/tests/integration/api_gpg_keys_test.go +++ b/tests/integration/api_gpg_keys_test.go @@ -74,7 +74,7 @@ func TestGPGKeys(t *testing.T) { var keys []*api.GPGKey req := NewRequest(t, "GET", "/api/v1/user/gpg_keys?token="+token) // GET all keys - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &keys) assert.Len(t, keys, 1) @@ -90,7 +90,7 @@ func TestGPGKeys(t *testing.T) { var key api.GPGKey req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)+"?token="+token) // Primary key 1 - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &key) assert.EqualValues(t, "38EA3BCED732982C", key.KeyID) assert.Len(t, key.Emails, 1) @@ -98,7 +98,7 @@ func TestGPGKeys(t *testing.T) { assert.True(t, key.Emails[0].Verified) req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)+"?token="+token) // Subkey of 38EA3BCED732982C - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &key) assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID) assert.Empty(t, key.Emails) @@ -109,7 +109,7 @@ func TestGPGKeys(t *testing.T) { t.Run("NotSigned", func(t *testing.T) { var branch api.Branch req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/not-signed?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) assert.False(t, branch.Commit.Verification.Verified) }) @@ -117,7 +117,7 @@ func TestGPGKeys(t *testing.T) { t.Run("SignedWithNotValidatedEmail", func(t *testing.T) { var branch api.Branch req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign-not-yet-validated?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) assert.False(t, branch.Commit.Verification.Verified) }) @@ -125,7 +125,7 @@ func TestGPGKeys(t *testing.T) { t.Run("SignedWithValidEmail", func(t *testing.T) { var branch api.Branch req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/branches/good-sign?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &branch) assert.True(t, branch.Commit.Verification.Verified) }) diff --git a/tests/integration/api_httpsig_test.go b/tests/integration/api_httpsig_test.go index d5db5952c4173..29d961a23d0df 100644 --- a/tests/integration/api_httpsig_test.go +++ b/tests/integration/api_httpsig_test.go @@ -61,7 +61,7 @@ func TestHTTPSigPubKey(t *testing.T) { Key: keyType + " " + keyContent, } req := NewRequestWithJSON(t, "POST", keysURL, rawKeyBody) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) // parse our private key and create the httpsig request sshSigner, _ := ssh.ParsePrivateKey([]byte(httpsigPrivateKey)) @@ -98,7 +98,7 @@ func TestHTTPSigCert(t *testing.T) { "type": "principal", }) - session.MakeRequest(t, req, http.StatusSeeOther) + MakeRequest(t, req, http.StatusSeeOther) pkcert, _, _, _, err := ssh.ParseAuthorizedKey([]byte(httpsigCertificate)) if err != nil { t.Fatal(err) diff --git a/tests/integration/api_issue_label_test.go b/tests/integration/api_issue_label_test.go index 8a324a6684e14..6f0fd879135e1 100644 --- a/tests/integration/api_issue_label_test.go +++ b/tests/integration/api_issue_label_test.go @@ -33,7 +33,7 @@ func TestAPIModifyLabels(t *testing.T) { Color: "abcdef", Description: "test label", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) apiLabel := new(api.Label) DecodeJSON(t, resp, &apiLabel) dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, RepoID: repo.ID}) @@ -45,16 +45,16 @@ func TestAPIModifyLabels(t *testing.T) { Color: "#123456", Description: "jet another test label", }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{ Name: "WrongTestL", Color: "#12345g", }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // ListLabels req = NewRequest(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiLabels []*api.Label DecodeJSON(t, resp, &apiLabels) assert.Len(t, apiLabels, 2) @@ -62,7 +62,7 @@ func TestAPIModifyLabels(t *testing.T) { // GetLabel singleURLStr := fmt.Sprintf("/api/v1/repos/%s/%s/labels/%d?token=%s", owner.Name, repo.Name, dbLabel.ID, token) req = NewRequest(t, "GET", singleURLStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiLabel) assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color) @@ -74,17 +74,17 @@ func TestAPIModifyLabels(t *testing.T) { Name: &newName, Color: &newColor, }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiLabel) assert.EqualValues(t, newColor, apiLabel.Color) req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{ Color: &newColorWrong, }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // DeleteLabel req = NewRequest(t, "DELETE", singleURLStr) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) } func TestAPIAddIssueLabels(t *testing.T) { @@ -102,7 +102,7 @@ func TestAPIAddIssueLabels(t *testing.T) { req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{ Labels: []int64{1, 2}, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiLabels []*api.Label DecodeJSON(t, resp, &apiLabels) assert.Len(t, apiLabels, unittest.GetCount(t, &issues_model.IssueLabel{IssueID: issue.ID})) @@ -125,7 +125,7 @@ func TestAPIReplaceIssueLabels(t *testing.T) { req := NewRequestWithJSON(t, "PUT", urlStr, &api.IssueLabelsOption{ Labels: []int64{label.ID}, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiLabels []*api.Label DecodeJSON(t, resp, &apiLabels) if assert.Len(t, apiLabels, 1) { @@ -152,7 +152,7 @@ func TestAPIModifyOrgLabels(t *testing.T) { Color: "abcdef", Description: "test label", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) apiLabel := new(api.Label) DecodeJSON(t, resp, &apiLabel) dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, OrgID: owner.ID}) @@ -164,16 +164,16 @@ func TestAPIModifyOrgLabels(t *testing.T) { Color: "#123456", Description: "jet another test label", }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{ Name: "WrongTestL", Color: "#12345g", }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // ListLabels req = NewRequest(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiLabels []*api.Label DecodeJSON(t, resp, &apiLabels) assert.Len(t, apiLabels, 4) @@ -181,7 +181,7 @@ func TestAPIModifyOrgLabels(t *testing.T) { // GetLabel singleURLStr := fmt.Sprintf("/api/v1/orgs/%s/labels/%d?token=%s", owner.Name, dbLabel.ID, token) req = NewRequest(t, "GET", singleURLStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiLabel) assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color) @@ -193,15 +193,15 @@ func TestAPIModifyOrgLabels(t *testing.T) { Name: &newName, Color: &newColor, }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiLabel) assert.EqualValues(t, newColor, apiLabel.Color) req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{ Color: &newColorWrong, }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // DeleteLabel req = NewRequest(t, "DELETE", singleURLStr) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) } diff --git a/tests/integration/api_issue_milestone_test.go b/tests/integration/api_issue_milestone_test.go index 7adaa0a1ee63f..60766e10fdbea 100644 --- a/tests/integration/api_issue_milestone_test.go +++ b/tests/integration/api_issue_milestone_test.go @@ -37,13 +37,13 @@ func TestAPIIssuesMilestone(t *testing.T) { req := NewRequestWithJSON(t, "PATCH", urlStr, structs.EditMilestoneOption{ State: &milestoneState, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiMilestone structs.Milestone DecodeJSON(t, resp, &apiMilestone) assert.EqualValues(t, "closed", apiMilestone.State) req = NewRequest(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiMilestone2 structs.Milestone DecodeJSON(t, resp, &apiMilestone2) assert.EqualValues(t, "closed", apiMilestone2.State) @@ -53,28 +53,28 @@ func TestAPIIssuesMilestone(t *testing.T) { Description: "closed one", State: "closed", }) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, &apiMilestone) assert.Equal(t, "wow", apiMilestone.Title) assert.Equal(t, structs.StateClosed, apiMilestone.State) var apiMilestones []structs.Milestone req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones?state=%s&token=%s", owner.Name, repo.Name, "all", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiMilestones) assert.Len(t, apiMilestones, 4) req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%s?token=%s", owner.Name, repo.Name, apiMilestones[2].Title, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiMilestone) assert.EqualValues(t, apiMilestones[2], apiMilestone) req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones?state=%s&name=%s&token=%s", owner.Name, repo.Name, "all", "milestone2", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiMilestones) assert.Len(t, apiMilestones, 1) assert.Equal(t, int64(2), apiMilestones[0].ID) req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%d?token=%s", owner.Name, repo.Name, apiMilestone.ID, token)) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) } diff --git a/tests/integration/api_issue_reaction_test.go b/tests/integration/api_issue_reaction_test.go index 85a39fffea3a7..ec239d7627d68 100644 --- a/tests/integration/api_issue_reaction_test.go +++ b/tests/integration/api_issue_reaction_test.go @@ -38,28 +38,28 @@ func TestAPIIssuesReactions(t *testing.T) { req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{ Reaction: "wrong", }) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // Delete not allowed reaction req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{ Reaction: "zzz", }) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Add allowed reaction req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{ Reaction: "rocket", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var apiNewReaction api.Reaction DecodeJSON(t, resp, &apiNewReaction) // Add existing reaction - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // Get end result of reaction list of issue #1 req = NewRequestf(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiReactions []*api.Reaction DecodeJSON(t, resp, &apiReactions) expectResponse := make(map[int]api.Reaction) @@ -98,28 +98,28 @@ func TestAPICommentReactions(t *testing.T) { req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{ Reaction: "wrong", }) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // Delete none existing reaction req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{ Reaction: "eyes", }) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Add allowed reaction req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{ Reaction: "+1", }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var apiNewReaction api.Reaction DecodeJSON(t, resp, &apiNewReaction) // Add existing reaction - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // Get end result of reaction list of issue #1 req = NewRequestf(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiReactions []*api.Reaction DecodeJSON(t, resp, &apiReactions) expectResponse := make(map[int]api.Reaction) diff --git a/tests/integration/api_issue_stopwatch_test.go b/tests/integration/api_issue_stopwatch_test.go index 4539d0ff62abb..d1a3e86fdad26 100644 --- a/tests/integration/api_issue_stopwatch_test.go +++ b/tests/integration/api_issue_stopwatch_test.go @@ -27,7 +27,7 @@ func TestAPIListStopWatches(t *testing.T) { session := loginUser(t, owner.Name) token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "GET", "/api/v1/user/stopwatches?token=%s", token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiWatches []*api.StopWatch DecodeJSON(t, resp, &apiWatches) stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID}) @@ -54,8 +54,8 @@ func TestAPIStopStopWatches(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/stop?token=%s", owner.Name, issue.Repo.Name, issue.Index, token) - session.MakeRequest(t, req, http.StatusCreated) - session.MakeRequest(t, req, http.StatusConflict) + MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusConflict) } func TestAPICancelStopWatches(t *testing.T) { @@ -70,8 +70,8 @@ func TestAPICancelStopWatches(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/stopwatch/delete?token=%s", owner.Name, issue.Repo.Name, issue.Index, token) - session.MakeRequest(t, req, http.StatusNoContent) - session.MakeRequest(t, req, http.StatusConflict) + MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusConflict) } func TestAPIStartStopWatches(t *testing.T) { @@ -86,6 +86,6 @@ func TestAPIStartStopWatches(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/start?token=%s", owner.Name, issue.Repo.Name, issue.Index, token) - session.MakeRequest(t, req, http.StatusCreated) - session.MakeRequest(t, req, http.StatusConflict) + MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusConflict) } diff --git a/tests/integration/api_issue_subscription_test.go b/tests/integration/api_issue_subscription_test.go index 68b29f364173c..a32b51e6fcb96 100644 --- a/tests/integration/api_issue_subscription_test.go +++ b/tests/integration/api_issue_subscription_test.go @@ -37,7 +37,7 @@ func TestAPIIssueSubscriptions(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/subscriptions/check?token=%s", issueRepo.OwnerName, issueRepo.Name, issue.Index, token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) wi := new(api.WatchInfo) DecodeJSON(t, resp, wi) @@ -57,20 +57,20 @@ func TestAPIIssueSubscriptions(t *testing.T) { issue1Repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue1.RepoID}) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/subscriptions/%s?token=%s", issue1Repo.OwnerName, issue1Repo.Name, issue1.Index, owner.Name, token) req := NewRequest(t, "DELETE", urlStr) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) testSubscription(issue1, false) req = NewRequest(t, "DELETE", urlStr) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) testSubscription(issue1, false) issue5Repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue5.RepoID}) urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/subscriptions/%s?token=%s", issue5Repo.OwnerName, issue5Repo.Name, issue5.Index, owner.Name, token) req = NewRequest(t, "PUT", urlStr) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) testSubscription(issue5, true) req = NewRequest(t, "PUT", urlStr) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) testSubscription(issue5, true) } diff --git a/tests/integration/api_issue_test.go b/tests/integration/api_issue_test.go index 095ebb1773061..2074bbee7ca7a 100644 --- a/tests/integration/api_issue_test.go +++ b/tests/integration/api_issue_test.go @@ -33,7 +33,7 @@ func TestAPIListIssues(t *testing.T) { link, _ := url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/issues", owner.Name, repo.Name)) link.RawQuery = url.Values{"token": {token}, "state": {"all"}}.Encode() - resp := session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) + resp := MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) var apiIssues []*api.Issue DecodeJSON(t, resp, &apiIssues) assert.Len(t, apiIssues, unittest.GetCount(t, &issues_model.Issue{RepoID: repo.ID})) @@ -43,7 +43,7 @@ func TestAPIListIssues(t *testing.T) { // test milestone filter link.RawQuery = url.Values{"token": {token}, "state": {"all"}, "type": {"all"}, "milestones": {"ignore,milestone1,3,4"}}.Encode() - resp = session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) + resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) DecodeJSON(t, resp, &apiIssues) if assert.Len(t, apiIssues, 2) { assert.EqualValues(t, 3, apiIssues[0].Milestone.ID) @@ -51,21 +51,21 @@ func TestAPIListIssues(t *testing.T) { } link.RawQuery = url.Values{"token": {token}, "state": {"all"}, "created_by": {"user2"}}.Encode() - resp = session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) + resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) DecodeJSON(t, resp, &apiIssues) if assert.Len(t, apiIssues, 1) { assert.EqualValues(t, 5, apiIssues[0].ID) } link.RawQuery = url.Values{"token": {token}, "state": {"all"}, "assigned_by": {"user1"}}.Encode() - resp = session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) + resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) DecodeJSON(t, resp, &apiIssues) if assert.Len(t, apiIssues, 1) { assert.EqualValues(t, 1, apiIssues[0].ID) } link.RawQuery = url.Values{"token": {token}, "state": {"all"}, "mentioned_by": {"user4"}}.Encode() - resp = session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) + resp = MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK) DecodeJSON(t, resp, &apiIssues) if assert.Len(t, apiIssues, 1) { assert.EqualValues(t, 1, apiIssues[0].ID) @@ -87,7 +87,7 @@ func TestAPICreateIssue(t *testing.T) { Title: title, Assignee: owner.Name, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var apiIssue api.Issue DecodeJSON(t, resp, &apiIssue) assert.Equal(t, body, apiIssue.Body) @@ -135,7 +135,7 @@ func TestAPIEditIssue(t *testing.T) { // ToDo change more }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var apiIssue api.Issue DecodeJSON(t, resp, &apiIssue) diff --git a/tests/integration/api_issue_tracked_time_test.go b/tests/integration/api_issue_tracked_time_test.go index aacf1e0fd026b..3080b5e194e14 100644 --- a/tests/integration/api_issue_tracked_time_test.go +++ b/tests/integration/api_issue_tracked_time_test.go @@ -30,7 +30,7 @@ func TestAPIGetTrackedTimes(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/%d/times?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiTimes api.TrackedTimeList DecodeJSON(t, resp, &apiTimes) expect, err := issues_model.GetTrackedTimes(db.DefaultContext, &issues_model.FindTrackedTimesOptions{IssueID: issue2.ID}) @@ -53,7 +53,7 @@ func TestAPIGetTrackedTimes(t *testing.T) { before := "2000-01-01T00%3A00%3A12%2B00%3A00" // 946684812 req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/%d/times?since=%s&before=%s&token=%s", user2.Name, issue2.Repo.Name, issue2.Index, since, before, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var filterAPITimes api.TrackedTimeList DecodeJSON(t, resp, &filterAPITimes) assert.Len(t, filterAPITimes, 2) @@ -74,13 +74,13 @@ func TestAPIDeleteTrackedTime(t *testing.T) { // Deletion not allowed req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/times/%d?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, time6.ID, token) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) time3 := unittest.AssertExistsAndLoadBean(t, &issues_model.TrackedTime{ID: 3}) req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/times/%d?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, time3.ID, token) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) // Delete non existing time - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Reset time of user 2 on issue 2 trackedSeconds, err := issues_model.GetTrackedSeconds(db.DefaultContext, issues_model.FindTrackedTimesOptions{IssueID: 2, UserID: 2}) @@ -88,8 +88,8 @@ func TestAPIDeleteTrackedTime(t *testing.T) { assert.Equal(t, int64(3661), trackedSeconds) req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/times?token=%s", user2.Name, issue2.Repo.Name, issue2.Index, token) - session.MakeRequest(t, req, http.StatusNoContent) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNotFound) trackedSeconds, err = issues_model.GetTrackedSeconds(db.DefaultContext, issues_model.FindTrackedTimesOptions{IssueID: 2, UserID: 2}) assert.NoError(t, err) @@ -114,7 +114,7 @@ func TestAPIAddTrackedTimes(t *testing.T) { User: user2.Name, Created: time.Unix(947688818, 0), }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiNewTime api.TrackedTime DecodeJSON(t, resp, &apiNewTime) diff --git a/tests/integration/api_keys_test.go b/tests/integration/api_keys_test.go index e70fa4a4eabe0..d24db2bd160f5 100644 --- a/tests/integration/api_keys_test.go +++ b/tests/integration/api_keys_test.go @@ -61,7 +61,7 @@ func TestCreateReadOnlyDeployKey(t *testing.T) { ReadOnly: true, } req := NewRequestWithJSON(t, "POST", keysURL, rawKeyBody) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newDeployKey api.DeployKey DecodeJSON(t, resp, &newDeployKey) @@ -86,7 +86,7 @@ func TestCreateReadWriteDeployKey(t *testing.T) { Key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4cn+iXnA4KvcQYSV88vGn0Yi91vG47t1P7okprVmhNTkipNRIHWr6WdCO4VDr/cvsRkuVJAsLO2enwjGWWueOO6BodiBgyAOZ/5t5nJNMCNuLGT5UIo/RI1b0WRQwxEZTRjt6mFNw6lH14wRd8ulsr9toSWBPMOGWoYs1PDeDL0JuTjL+tr1SZi/EyxCngpYszKdXllJEHyI79KQgeD0Vt3pTrkbNVTOEcCNqZePSVmUH8X8Vhugz3bnE0/iE9Pb5fkWO9c4AnM1FgI/8Bvp27Fw2ShryIXuR6kKvUqhVMTuOSDHwu6A8jLE5Owt3GAYugDpDYuwTVNGrHLXKpPzrGGPE/jPmaLCMZcsdkec95dYeU3zKODEm8UQZFhmJmDeWVJ36nGrGZHL4J5aTTaeFUJmmXDaJYiJ+K2/ioKgXqnXvltu0A9R8/LGy4nrTJRr4JMLuJFoUXvGm1gXQ70w2LSpk6yl71RNC0hCtsBe8BP8IhYCM0EP5jh7eCMQZNvM= nocomment\n", } req := NewRequestWithJSON(t, "POST", keysURL, rawKeyBody) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newDeployKey api.DeployKey DecodeJSON(t, resp, &newDeployKey) @@ -112,7 +112,7 @@ func TestCreateUserKey(t *testing.T) { Key: keyType + " " + keyContent, } req := NewRequestWithJSON(t, "POST", keysURL, rawKeyBody) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newPublicKey api.PublicKey DecodeJSON(t, resp, &newPublicKey) @@ -130,7 +130,7 @@ func TestCreateUserKey(t *testing.T) { fingerprintURL := fmt.Sprintf("/api/v1/user/keys?token=%s&fingerprint=%s", token, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var fingerprintPublicKeys []api.PublicKey DecodeJSON(t, resp, &fingerprintPublicKeys) @@ -141,7 +141,7 @@ func TestCreateUserKey(t *testing.T) { fingerprintURL = fmt.Sprintf("/api/v1/users/%s/keys?token=%s&fingerprint=%s", user.Name, token, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Equal(t, newPublicKey.Fingerprint, fingerprintPublicKeys[0].Fingerprint) @@ -152,7 +152,7 @@ func TestCreateUserKey(t *testing.T) { fingerprintURL = fmt.Sprintf("/api/v1/user/keys?token=%s&fingerprint=%sA", token, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Len(t, fingerprintPublicKeys, 0) @@ -160,7 +160,7 @@ func TestCreateUserKey(t *testing.T) { // Fail searching for wrong users key fingerprintURL = fmt.Sprintf("/api/v1/users/%s/keys?token=%s&fingerprint=%s", "user2", token, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Len(t, fingerprintPublicKeys, 0) @@ -172,7 +172,7 @@ func TestCreateUserKey(t *testing.T) { // Should find key even though not ours, but we shouldn't know whose it is fingerprintURL = fmt.Sprintf("/api/v1/user/keys?token=%s&fingerprint=%s", token2, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Equal(t, newPublicKey.Fingerprint, fingerprintPublicKeys[0].Fingerprint) @@ -183,7 +183,7 @@ func TestCreateUserKey(t *testing.T) { fingerprintURL = fmt.Sprintf("/api/v1/users/%s/keys?token=%s&fingerprint=%s", user.Name, token2, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Equal(t, newPublicKey.Fingerprint, fingerprintPublicKeys[0].Fingerprint) @@ -193,7 +193,7 @@ func TestCreateUserKey(t *testing.T) { // Fail when searching for key if it is not ours fingerprintURL = fmt.Sprintf("/api/v1/users/%s/keys?token=%s&fingerprint=%s", "user2", token2, newPublicKey.Fingerprint) req = NewRequest(t, "GET", fingerprintURL) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fingerprintPublicKeys) assert.Len(t, fingerprintPublicKeys, 0) diff --git a/tests/integration/api_notification_test.go b/tests/integration/api_notification_test.go index 2ee4778ab5eeb..cd230d6883c99 100644 --- a/tests/integration/api_notification_test.go +++ b/tests/integration/api_notification_test.go @@ -33,7 +33,7 @@ func TestAPINotification(t *testing.T) { // test filter since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801 req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?since=%s&token=%s", since, token)) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiNL []api.NotificationThread DecodeJSON(t, resp, &apiNL) @@ -44,7 +44,7 @@ func TestAPINotification(t *testing.T) { before := "2000-01-01T01%3A06%3A59%2B00%3A00" // 946688819 req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?all=%s&before=%s&token=%s", "true", before, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 3) @@ -60,7 +60,7 @@ func TestAPINotification(t *testing.T) { // -- GET /repos/{owner}/{repo}/notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?status-types=unread&token=%s", user2.Name, repo1.Name, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 1) @@ -68,7 +68,7 @@ func TestAPINotification(t *testing.T) { // -- GET /repos/{owner}/{repo}/notifications -- multiple status-types req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?status-types=unread&status-types=pinned&token=%s", user2.Name, repo1.Name, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 2) @@ -82,11 +82,11 @@ func TestAPINotification(t *testing.T) { // -- GET /notifications/threads/{id} -- // get forbidden req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", 1, token)) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // get own req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var apiN api.NotificationThread DecodeJSON(t, resp, &apiN) @@ -104,28 +104,28 @@ func TestAPINotification(t *testing.T) { // -- check notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &new) assert.True(t, new.New > 0) // -- mark notifications as read -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?status-types=unread&token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 2) lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801 <- only Notification 4 is in this filter ... req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token)) - session.MakeRequest(t, req, http.StatusResetContent) + MakeRequest(t, req, http.StatusResetContent) req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?status-types=unread&token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 1) // -- PATCH /notifications/threads/{id} -- req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token)) - session.MakeRequest(t, req, http.StatusResetContent) + MakeRequest(t, req, http.StatusResetContent) assert.Equal(t, activities_model.NotificationStatusUnread, thread5.Status) thread5 = unittest.AssertExistsAndLoadBean(t, &activities_model.Notification{ID: 5}) @@ -133,7 +133,7 @@ func TestAPINotification(t *testing.T) { // -- check notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &new) assert.True(t, new.New == 0) } @@ -149,7 +149,7 @@ func TestAPINotificationPUT(t *testing.T) { // Check notifications are as expected req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?all=true&token=%s", token)) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiNL []api.NotificationThread DecodeJSON(t, resp, &apiNL) @@ -172,7 +172,7 @@ func TestAPINotificationPUT(t *testing.T) { // change it to unread. // req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/notifications?status-types=read&status-type=pinned&to-status=unread&token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusResetContent) + resp = MakeRequest(t, req, http.StatusResetContent) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 1) assert.EqualValues(t, 2, apiNL[0].ID) @@ -183,7 +183,7 @@ func TestAPINotificationPUT(t *testing.T) { // Now nofication ID 2 is the first in the list and is unread. // req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?all=true&token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiNL) assert.Len(t, apiNL, 4) diff --git a/tests/integration/api_oauth2_apps_test.go b/tests/integration/api_oauth2_apps_test.go index 59be697a14771..d2a85992ac0d6 100644 --- a/tests/integration/api_oauth2_apps_test.go +++ b/tests/integration/api_oauth2_apps_test.go @@ -68,7 +68,7 @@ func testAPIListOAuth2Applications(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2?token=%s", token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var appList api.OAuth2ApplicationList DecodeJSON(t, resp, &appList) @@ -95,13 +95,13 @@ func testAPIDeleteOAuth2Application(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", oldApp.ID, token) req := NewRequest(t, "DELETE", urlStr) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) unittest.AssertNotExistsBean(t, &auth.OAuth2Application{UID: oldApp.UID, Name: oldApp.Name}) // Delete again will return not found req = NewRequest(t, "DELETE", urlStr) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } func testAPIGetOAuth2Application(t *testing.T) { @@ -120,7 +120,7 @@ func testAPIGetOAuth2Application(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", existApp.ID, token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var app api.OAuth2Application DecodeJSON(t, resp, &app) diff --git a/tests/integration/api_org_test.go b/tests/integration/api_org_test.go index 5cd138eee2fb7..0be0c170d69ec 100644 --- a/tests/integration/api_org_test.go +++ b/tests/integration/api_org_test.go @@ -88,7 +88,7 @@ func TestAPIOrgEdit(t *testing.T) { Visibility: "private", } req := NewRequestWithJSON(t, "PATCH", "/api/v1/orgs/user3?token="+token, &org) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiOrg api.Organization DecodeJSON(t, resp, &apiOrg) @@ -115,7 +115,7 @@ func TestAPIOrgEditBadVisibility(t *testing.T) { Visibility: "badvisibility", } req := NewRequestWithJSON(t, "PATCH", "/api/v1/orgs/user3?token="+token, &org) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) } diff --git a/tests/integration/api_packages_container_test.go b/tests/integration/api_packages_container_test.go index 851021da1b7cb..1faf19a2d9bd9 100644 --- a/tests/integration/api_packages_container_test.go +++ b/tests/integration/api_packages_container_test.go @@ -660,7 +660,7 @@ func TestPackageContainer(t *testing.T) { "email": "user2@example.com", "language": "en-US", }) - session.MakeRequest(t, req, http.StatusSeeOther) + MakeRequest(t, req, http.StatusSeeOther) t.Run(fmt.Sprintf("Catalog[%s]", newOwnerName), checkCatalog(newOwnerName)) @@ -670,6 +670,6 @@ func TestPackageContainer(t *testing.T) { "email": "user2@example.com", "language": "en-US", }) - session.MakeRequest(t, req, http.StatusSeeOther) + MakeRequest(t, req, http.StatusSeeOther) }) } diff --git a/tests/integration/api_pull_commits_test.go b/tests/integration/api_pull_commits_test.go index 3068ca2dd68ff..6449cc29c7d25 100644 --- a/tests/integration/api_pull_commits_test.go +++ b/tests/integration/api_pull_commits_test.go @@ -25,7 +25,7 @@ func TestAPIPullCommits(t *testing.T) { session := loginUser(t, "user2") req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/commits", repo.OwnerName, repo.Name, pr.Index) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var commits []*api.Commit DecodeJSON(t, resp, &commits) diff --git a/tests/integration/api_pull_review_test.go b/tests/integration/api_pull_review_test.go index ac7982773d0c2..4b9c60178343c 100644 --- a/tests/integration/api_pull_review_test.go +++ b/tests/integration/api_pull_review_test.go @@ -29,7 +29,7 @@ func TestAPIPullReview(t *testing.T) { session := loginUser(t, "user2") token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var reviews []*api.PullReview DecodeJSON(t, resp, &reviews) @@ -54,20 +54,20 @@ func TestAPIPullReview(t *testing.T) { // test GetPullReview req = NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, reviews[3].ID, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var review api.PullReview DecodeJSON(t, resp, &review) assert.EqualValues(t, *reviews[3], review) req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, reviews[5].ID, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, *reviews[5], review) // test GetPullReviewComments comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 7}) req = NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d/comments?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, 10, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var reviewComments []*api.PullReviewComment DecodeJSON(t, resp, &reviewComments) assert.Len(t, reviewComments, 1) @@ -100,7 +100,7 @@ func TestAPIPullReview(t *testing.T) { }, }, }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) assert.EqualValues(t, "PENDING", review.State) @@ -111,7 +111,7 @@ func TestAPIPullReview(t *testing.T) { Event: "APPROVED", Body: "just two nits", }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) assert.EqualValues(t, "APPROVED", review.State) @@ -121,14 +121,14 @@ func TestAPIPullReview(t *testing.T) { req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/dismissals?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token), &api.DismissPullReviewOptions{ Message: "test", }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) assert.True(t, review.Dismissed) // test dismiss review req = NewRequest(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/undismissals?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, 6, review.ID) assert.False(t, review.Dismissed) @@ -138,12 +138,12 @@ func TestAPIPullReview(t *testing.T) { Body: "just a comment", Event: "COMMENT", }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &review) assert.EqualValues(t, "COMMENT", review.State) assert.EqualValues(t, 0, review.CodeCommentsCount) req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) // test CreatePullReview Comment without body but with comments req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{ @@ -165,7 +165,7 @@ func TestAPIPullReview(t *testing.T) { }) var commentReview api.PullReview - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &commentReview) assert.EqualValues(t, "COMMENT", commentReview.State) assert.EqualValues(t, 2, commentReview.CodeCommentsCount) @@ -180,7 +180,7 @@ func TestAPIPullReview(t *testing.T) { Comments: []api.CreatePullReviewComment{}, }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &commentReview) assert.EqualValues(t, "COMMENT", commentReview.State) assert.EqualValues(t, 0, commentReview.CodeCommentsCount) @@ -193,7 +193,7 @@ func TestAPIPullReview(t *testing.T) { Event: "COMMENT", Comments: []api.CreatePullReviewComment{}, }) - resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity) + resp = MakeRequest(t, req, http.StatusUnprocessableEntity) errMap := make(map[string]interface{}) json.Unmarshal(resp.Body.Bytes(), &errMap) assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string)) @@ -205,7 +205,7 @@ func TestAPIPullReview(t *testing.T) { repo3 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: pullIssue12.RepoID}) req = NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &reviews) assert.EqualValues(t, 11, reviews[0].ID) assert.EqualValues(t, "REQUEST_REVIEW", reviews[0].State) @@ -234,19 +234,19 @@ func TestAPIPullReviewRequest(t *testing.T) { req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.PullReviewRequestOptions{ Reviewers: []string{"user4@example.com", "user8"}, }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) // poster of pr can't be reviewer req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.PullReviewRequestOptions{ Reviewers: []string{"user1"}, }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // test user not exist req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.PullReviewRequestOptions{ Reviewers: []string{"testOther"}, }) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test Remove Review Request session2 := loginUser(t, "user4") @@ -255,18 +255,18 @@ func TestAPIPullReviewRequest(t *testing.T) { req = NewRequestWithJSON(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token2), &api.PullReviewRequestOptions{ Reviewers: []string{"user4"}, }) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) // doer is not admin req = NewRequestWithJSON(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token2), &api.PullReviewRequestOptions{ Reviewers: []string{"user8"}, }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) req = NewRequestWithJSON(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.PullReviewRequestOptions{ Reviewers: []string{"user8"}, }) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) // Test team review request pullIssue12 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 12}) @@ -277,30 +277,30 @@ func TestAPIPullReviewRequest(t *testing.T) { req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{ TeamReviewers: []string{"team1", "owners"}, }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) // Test add Team Review Request to not allowned req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{ TeamReviewers: []string{"test_team"}, }) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // Test add Team Review Request to not exist req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{ TeamReviewers: []string{"not_exist_team"}, }) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test Remove team Review Request req = NewRequestWithJSON(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{ TeamReviewers: []string{"team1"}, }) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) // empty request test req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{}) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) req = NewRequestWithJSON(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers?token=%s", repo3.OwnerName, repo3.Name, pullIssue12.Index, token), &api.PullReviewRequestOptions{}) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) } diff --git a/tests/integration/api_pull_test.go b/tests/integration/api_pull_test.go index 5e987c441ef2a..3d7256d30dba3 100644 --- a/tests/integration/api_pull_test.go +++ b/tests/integration/api_pull_test.go @@ -80,7 +80,7 @@ func TestAPIMergePullWIP(t *testing.T) { Do: string(repo_model.MergeStyleMerge), }) - session.MakeRequest(t, req, http.StatusMethodNotAllowed) + MakeRequest(t, req, http.StatusMethodNotAllowed) } func TestAPICreatePullSuccess(t *testing.T) { @@ -99,8 +99,8 @@ func TestAPICreatePullSuccess(t *testing.T) { Base: "master", Title: "create a failure pr", }) - session.MakeRequest(t, req, http.StatusCreated) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) // second request should fail + MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusUnprocessableEntity) // second request should fail } func TestAPICreatePullWithFieldsSuccess(t *testing.T) { @@ -127,7 +127,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, http.StatusCreated) + res := MakeRequest(t, req, http.StatusCreated) pull := new(api.PullRequest) DecodeJSON(t, res, pull) @@ -158,19 +158,19 @@ func TestAPICreatePullWithFieldsFailure(t *testing.T) { } req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls?token=%s", owner10.Name, repo10.Name, token), opts) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) opts.Title = "is required" opts.Milestone = 666 - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) opts.Milestone = 5 opts.Assignees = []string{"qweruqweroiuyqweoiruywqer"} - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) opts.Assignees = []string{owner10.LoginName} opts.Labels = []int64{55555} - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) opts.Labels = []int64{5} } @@ -187,7 +187,7 @@ func TestAPIEditPull(t *testing.T) { Title: "create a success pr", }) pull := new(api.PullRequest) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, pull) assert.EqualValues(t, "master", pull.Base.Name) @@ -195,14 +195,14 @@ func TestAPIEditPull(t *testing.T) { Base: "feature/1", Title: "edit a this pr", }) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = 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, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } func doAPIGetPullFiles(ctx APITestContext, pr *api.PullRequest, callback func(*testing.T, []*api.ChangedFile)) func(*testing.T) { diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index 90691d81abee8..51bc07a3258eb 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -79,7 +79,7 @@ func createNewReleaseUsingAPI(t *testing.T, session *TestSession, token string, IsPrerelease: false, Target: target, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var newRelease api.Release DecodeJSON(t, resp, &newRelease) @@ -117,7 +117,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/%d?token=%s", owner.Name, repo.Name, newRelease.ID, token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var release api.Release DecodeJSON(t, resp, &release) @@ -134,7 +134,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) { IsPrerelease: &release.IsPrerelease, Target: release.Target, }) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &newRelease) rel := &repo_model.Release{ @@ -188,7 +188,7 @@ func TestAPIGetReleaseByTag(t *testing.T) { owner.Name, repo.Name, tag) req := NewRequestf(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var release *api.Release DecodeJSON(t, resp, &release) @@ -201,7 +201,7 @@ func TestAPIGetReleaseByTag(t *testing.T) { owner.Name, repo.Name, nonexistingtag) req = NewRequestf(t, "GET", urlStr) - resp = session.MakeRequest(t, req, http.StatusNotFound) + resp = MakeRequest(t, req, http.StatusNotFound) var err *api.APIError DecodeJSON(t, resp, &err) @@ -220,13 +220,13 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) { // delete release req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag?token=%s", owner.Name, repo.Name, token)) - _ = session.MakeRequest(t, req, http.StatusNoContent) + _ = MakeRequest(t, req, http.StatusNoContent) // make sure release is deleted req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag?token=%s", owner.Name, repo.Name, token)) - _ = session.MakeRequest(t, req, http.StatusNotFound) + _ = MakeRequest(t, req, http.StatusNotFound) // delete release tag too req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag?token=%s", owner.Name, repo.Name, token)) - _ = session.MakeRequest(t, req, http.StatusNoContent) + _ = MakeRequest(t, req, http.StatusNoContent) } diff --git a/tests/integration/api_repo_collaborator_test.go b/tests/integration/api_repo_collaborator_test.go index cb834096cb4da..6f96e13c66f9c 100644 --- a/tests/integration/api_repo_collaborator_test.go +++ b/tests/integration/api_repo_collaborator_test.go @@ -32,7 +32,7 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { t.Run("RepoOwnerShouldBeOwner", func(t *testing.T) { req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/collaborators/%s/permission?token=%s", repo2Owner.Name, repo2.Name, repo2Owner.Name, testCtx.Token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var repoPermission api.RepoCollaboratorPermission DecodeJSON(t, resp, &repoPermission) @@ -44,7 +44,7 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { t.Run("AddUserAsCollaboratorWithReadAccess", doAPIAddCollaborator(testCtx, user4.Name, perm.AccessModeRead)) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/collaborators/%s/permission?token=%s", repo2Owner.Name, repo2.Name, user4.Name, testCtx.Token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var repoPermission api.RepoCollaboratorPermission DecodeJSON(t, resp, &repoPermission) @@ -56,7 +56,7 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { t.Run("AddUserAsCollaboratorWithWriteAccess", doAPIAddCollaborator(testCtx, user4.Name, perm.AccessModeWrite)) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/collaborators/%s/permission?token=%s", repo2Owner.Name, repo2.Name, user4.Name, testCtx.Token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var repoPermission api.RepoCollaboratorPermission DecodeJSON(t, resp, &repoPermission) @@ -68,7 +68,7 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { t.Run("AddUserAsCollaboratorWithAdminAccess", doAPIAddCollaborator(testCtx, user4.Name, perm.AccessModeAdmin)) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/collaborators/%s/permission?token=%s", repo2Owner.Name, repo2.Name, user4.Name, testCtx.Token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var repoPermission api.RepoCollaboratorPermission DecodeJSON(t, resp, &repoPermission) @@ -78,7 +78,7 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { t.Run("CollaboratorNotFound", func(t *testing.T) { req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/collaborators/%s/permission?token=%s", repo2Owner.Name, repo2.Name, "non-existent-user", testCtx.Token) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) }) t.Run("CollaboratorCanQueryItsPermissions", func(t *testing.T) { diff --git a/tests/integration/api_repo_edit_test.go b/tests/integration/api_repo_edit_test.go index dcaecbd035cd4..d29200635467d 100644 --- a/tests/integration/api_repo_edit_test.go +++ b/tests/integration/api_repo_edit_test.go @@ -156,7 +156,7 @@ func TestAPIRepoEdit(t *testing.T) { repoEditOption := getNewRepoEditOption(origRepoEditOption) url := fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo1.Name, token2) req := NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var repo api.Repository DecodeJSON(t, resp, &repo) assert.NotNil(t, repo) @@ -187,7 +187,7 @@ func TestAPIRepoEdit(t *testing.T) { repoEditOption.ExternalWiki = nil url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, *repoEditOption.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &repo) assert.NotNil(t, repo) // check repo1 was written to database @@ -209,7 +209,7 @@ func TestAPIRepoEdit(t *testing.T) { ExternalWikiURL: "http://www.somewebsite.com", } req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &repo) assert.NotNil(t, repo) // check repo1 was written to database @@ -223,7 +223,7 @@ func TestAPIRepoEdit(t *testing.T) { repoEditOption.ExternalTracker.ExternalTrackerStyle = "regexp" repoEditOption.ExternalTracker.ExternalTrackerRegexpPattern = `(\d+)` req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &repo) assert.NotNil(t, repo) repo1edited = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) @@ -234,15 +234,15 @@ func TestAPIRepoEdit(t *testing.T) { // Do some tests with invalid URL for external tracker and wiki repoEditOption.ExternalTracker.ExternalTrackerURL = "htp://www.somewebsite.com" req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) repoEditOption.ExternalTracker.ExternalTrackerURL = "http://www.somewebsite.com" repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user/{repo}?issue={index}" req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user}/{repo}?issue={index}" repoEditOption.ExternalWiki.ExternalWikiURL = "htp://www.somewebsite.com" req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // Test small repo change through API with issue and wiki option not set; They shall not be touched. *repoEditOption.Description = "small change" @@ -251,7 +251,7 @@ func TestAPIRepoEdit(t *testing.T) { repoEditOption.HasWiki = nil repoEditOption.ExternalWiki = nil req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &repo) assert.NotNil(t, repo) // check repo1 was written to database @@ -266,38 +266,38 @@ func TestAPIRepoEdit(t *testing.T) { // reset repo in db url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, *repoEditOption.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &origRepoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // Test editing a non-existing repo name := "repodoesnotexist" url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, name, token2) req = NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{Name: &name}) - _ = session.MakeRequest(t, req, http.StatusNotFound) + _ = MakeRequest(t, req, http.StatusNotFound) // Test editing repo16 by user4 who does not have write access origRepoEditOption = getRepoEditOptionFromRepo(repo16) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo16.Name, token4) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Tests a repo with no token given so will fail origRepoEditOption = getRepoEditOptionFromRepo(repo16) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo16.Name) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - _ = session.MakeRequest(t, req, http.StatusNotFound) + _ = MakeRequest(t, req, http.StatusNotFound) // Test using access token for a private repo that the user of the token owns origRepoEditOption = getRepoEditOptionFromRepo(repo16) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo16.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // reset repo in db url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, *repoEditOption.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &origRepoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // Test making a repo public that is private repo16 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 16}) @@ -307,13 +307,13 @@ func TestAPIRepoEdit(t *testing.T) { } url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo16.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) repo16 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 16}) assert.False(t, repo16.IsPrivate) // Make it private again repoEditOption.Private = &bTrue req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // Test to change empty repo assert.False(t, repo15.IsArchived) @@ -321,37 +321,37 @@ func TestAPIRepoEdit(t *testing.T) { req = NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{ Archived: &bTrue, }) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) repo15 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 15}) assert.True(t, repo15.IsArchived) req = NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{ Archived: &bFalse, }) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" where user2 is a collaborator origRepoEditOption = getRepoEditOptionFromRepo(repo3) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user3.Name, repo3.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // reset repo in db url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user3.Name, *repoEditOption.Name, token2) req = NewRequestWithJSON(t, "PATCH", url, &origRepoEditOption) - _ = session.MakeRequest(t, req, http.StatusOK) + _ = MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" with no user token origRepoEditOption = getRepoEditOptionFromRepo(repo3) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s", user3.Name, repo3.Name) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using repo "user2/repo1" where user4 is a NOT collaborator origRepoEditOption = getRepoEditOptionFromRepo(repo1) repoEditOption = getNewRepoEditOption(origRepoEditOption) url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, repo1.Name, token4) req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) }) } diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index 17e26d966ba36..2586ae1ee29a5 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -167,7 +167,7 @@ func TestAPICreateFile(t *testing.T) { treePath := fmt.Sprintf("new/file%d.txt", fileID) url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "POST", url, &createFileOptions) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath()) commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName) latestCommit, _ := gitRepo.GetCommitByPath(treePath) @@ -194,7 +194,7 @@ func TestAPICreateFile(t *testing.T) { treePath := fmt.Sprintf("new/file%d.txt", fileID) url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "POST", url, &createFileOptions) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var fileResponse api.FileResponse DecodeJSON(t, resp, &fileResponse) expectedSHA := "a635aa942442ddfdba07468cf9661c08fbdf0ebf" @@ -212,7 +212,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, &fileResponse) expectedMessage := "Add '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) @@ -222,7 +222,7 @@ func TestAPICreateFile(t *testing.T) { treePath = "README.md" url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity) + resp = MakeRequest(t, req, http.StatusUnprocessableEntity) expectedAPIError := context.APIError{ Message: "repository file already exists [path: " + treePath + "]", URL: setting.API.SwaggerURL, @@ -237,7 +237,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Tests a repo with no token given so will fail createFileOptions = getCreateFileOptions() @@ -245,7 +245,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo16.Name, treePath) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using access token for a private repo that the user of the token owns createFileOptions = getCreateFileOptions() @@ -253,7 +253,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token2) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) // Test using org repo "user3/repo3" where user2 is a collaborator createFileOptions = getCreateFileOptions() @@ -261,7 +261,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user3.Name, repo3.Name, treePath, token2) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) // Test using org repo "user3/repo3" with no user token createFileOptions = getCreateFileOptions() @@ -269,7 +269,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user3.Name, repo3.Name, treePath) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using repo "user2/repo1" where user4 is a NOT collaborator createFileOptions = getCreateFileOptions() @@ -277,7 +277,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token4) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // Test creating a file in an empty repository doAPICreateRepository(NewAPITestContext(t, "user2", "empty-repo"), true)(t) @@ -286,7 +286,7 @@ func TestAPICreateFile(t *testing.T) { treePath = fmt.Sprintf("new/file%d.txt", fileID) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, "empty-repo", treePath, token2) req = NewRequestWithJSON(t, "POST", url, &createFileOptions) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user2", Name: "empty-repo"}) // public repo gitRepo, _ := git.OpenRepository(stdCtx.Background(), emptyRepo.RepoPath()) commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName) diff --git a/tests/integration/api_repo_file_delete_test.go b/tests/integration/api_repo_file_delete_test.go index 1956c2a3a2239..18544083c251e 100644 --- a/tests/integration/api_repo_file_delete_test.go +++ b/tests/integration/api_repo_file_delete_test.go @@ -66,7 +66,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions.BranchName = branch url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var fileResponse api.FileResponse DecodeJSON(t, resp, &fileResponse) assert.NotNil(t, fileResponse) @@ -82,7 +82,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions.NewBranchName = "new_branch" url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var fileResponse api.FileResponse DecodeJSON(t, resp, &fileResponse) assert.NotNil(t, fileResponse) @@ -97,7 +97,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions.Message = "" url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) expectedMessage := "Delete '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) @@ -110,7 +110,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions.SHA = "badsha" url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusBadRequest) + MakeRequest(t, req, http.StatusBadRequest) // Test creating a file in repo16 by user4 who does not have write access fileID++ @@ -119,7 +119,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Tests a repo with no token given so will fail fileID++ @@ -128,7 +128,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo16.Name, treePath) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using access token for a private repo that the user of the token owns fileID++ @@ -137,7 +137,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token2) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" where user2 is a collaborator fileID++ @@ -146,7 +146,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user3.Name, repo3.Name, treePath, token2) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" with no user token fileID++ @@ -155,7 +155,7 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user3.Name, repo3.Name, treePath) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using repo "user2/repo1" where user4 is a NOT collaborator fileID++ @@ -164,6 +164,6 @@ func TestAPIDeleteFile(t *testing.T) { deleteFileOptions = getDeleteFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token4) req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) }) } diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index eba1d78fe7f50..933452fcec698 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -134,7 +134,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions.BranchName = branch url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath()) commitID, _ := gitRepo.GetBranchCommitID(updateFileOptions.NewBranchName) lasCommit, _ := gitRepo.GetCommitByPath(treePath) @@ -158,7 +158,7 @@ func TestAPIUpdateFile(t *testing.T) { createFile(user2, repo1, treePath) url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req := NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var fileResponse api.FileResponse DecodeJSON(t, resp, &fileResponse) expectedSHA := "08bd14b2e2852529157324de9c226b3364e76136" @@ -179,7 +179,7 @@ func TestAPIUpdateFile(t *testing.T) { treePath = "rename/" + treePath url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) expectedSHA = "08bd14b2e2852529157324de9c226b3364e76136" expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID) @@ -197,7 +197,7 @@ func TestAPIUpdateFile(t *testing.T) { createFile(user2, repo1, treePath) url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) expectedMessage := "Update '" + treePath + "'\n" assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) @@ -211,7 +211,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions.SHA = "badsha" url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity) + resp = MakeRequest(t, req, http.StatusUnprocessableEntity) expectedAPIError := context.APIError{ Message: "sha does not match [given: " + updateFileOptions.SHA + ", expected: " + correctSHA + "]", URL: setting.API.SwaggerURL, @@ -227,7 +227,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Tests a repo with no token given so will fail fileID++ @@ -236,7 +236,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo16.Name, treePath) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using access token for a private repo that the user of the token owns fileID++ @@ -245,7 +245,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token2) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" where user2 is a collaborator fileID++ @@ -254,7 +254,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user3.Name, repo3.Name, treePath, token2) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" with no user token fileID++ @@ -263,7 +263,7 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user3.Name, repo3.Name, treePath) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using repo "user2/repo1" where user4 is a NOT collaborator fileID++ @@ -272,6 +272,6 @@ func TestAPIUpdateFile(t *testing.T) { updateFileOptions = getUpdateFileOptions() url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token4) req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) }) } diff --git a/tests/integration/api_repo_get_contents_list_test.go b/tests/integration/api_repo_get_contents_list_test.go index e0db8329dec30..1fc037dc09a8b 100644 --- a/tests/integration/api_repo_get_contents_list_test.go +++ b/tests/integration/api_repo_get_contents_list_test.go @@ -90,7 +90,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { ref := repo1.DefaultBranch refType := "branch" req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var contentsListResponse []*api.ContentsResponse DecodeJSON(t, resp, &contentsListResponse) assert.NotNil(t, contentsListResponse) @@ -102,7 +102,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { // No ref refType = "branch" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsListResponse) assert.NotNil(t, contentsListResponse) @@ -113,7 +113,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { ref = newBranch refType = "branch" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsListResponse) assert.NotNil(t, contentsListResponse) branchCommit, err := gitRepo.GetBranchCommit(ref) @@ -127,7 +127,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { ref = newTag refType = "tag" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsListResponse) assert.NotNil(t, contentsListResponse) tagCommit, err := gitRepo.GetTagCommit(ref) @@ -141,7 +141,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { ref = commitID refType = "commit" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsListResponse) assert.NotNil(t, contentsListResponse) expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, commitID) @@ -150,17 +150,17 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { // Test file contents a file with a bad ref ref = "badref" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test accessing private ref with user token that does not have access - should fail req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test access private ref of owner of token req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/readme.md?token=%s", user2.Name, repo16.Name, token2) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test access of org user3 private repo file by owner user2 req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user3.Name, repo3.Name, treePath, token2) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go index ccbcfba4865e0..5eddd0166f7fe 100644 --- a/tests/integration/api_repo_get_contents_test.go +++ b/tests/integration/api_repo_get_contents_test.go @@ -92,7 +92,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { ref := repo1.DefaultBranch refType := "branch" req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var contentsResponse api.ContentsResponse DecodeJSON(t, resp, &contentsResponse) assert.NotNil(t, contentsResponse) @@ -103,7 +103,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { // No ref refType = "branch" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsResponse) assert.NotNil(t, contentsResponse) expectedContentsResponse = getExpectedContentsResponseForContents(repo1.DefaultBranch, refType, lastCommit.ID.String()) @@ -113,7 +113,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { ref = newBranch refType = "branch" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsResponse) assert.NotNil(t, contentsResponse) branchCommit, _ := gitRepo.GetBranchCommit(ref) @@ -125,7 +125,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { ref = newTag refType = "tag" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsResponse) assert.NotNil(t, contentsResponse) tagCommit, _ := gitRepo.GetTagCommit(ref) @@ -137,7 +137,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { ref = commitID refType = "commit" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &contentsResponse) assert.NotNil(t, contentsResponse) expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, commitID) @@ -146,17 +146,17 @@ func testAPIGetContents(t *testing.T, u *url.URL) { // Test file contents a file with a bad ref ref = "badref" req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test accessing private ref with user token that does not have access - should fail req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test access private ref of owner of token req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/readme.md?token=%s", user2.Name, repo16.Name, token2) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test access of org user3 private repo file by owner user2 req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user3.Name, repo3.Name, treePath, token2) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } diff --git a/tests/integration/api_repo_git_blobs_test.go b/tests/integration/api_repo_git_blobs_test.go index 1dd59776c16d9..8240b1342921e 100644 --- a/tests/integration/api_repo_git_blobs_test.go +++ b/tests/integration/api_repo_git_blobs_test.go @@ -36,7 +36,7 @@ func TestAPIReposGitBlobs(t *testing.T) { // Test a public repo that anyone can GET the blob of req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s", user2.Name, repo1.Name, repo1ReadmeSHA) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var gitBlobResponse api.GitBlobResponse DecodeJSON(t, resp, &gitBlobResponse) assert.NotNil(t, gitBlobResponse) @@ -45,27 +45,27 @@ func TestAPIReposGitBlobs(t *testing.T) { // Tests a private repo with no token so will fail req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s", user2.Name, repo16.Name, repo16ReadmeSHA) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Test using access token for a private repo that the user of the token owns req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s?token=%s", user2.Name, repo16.Name, repo16ReadmeSHA, token) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using bad sha req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s", user2.Name, repo1.Name, badSHA) - session.MakeRequest(t, req, http.StatusBadRequest) + MakeRequest(t, req, http.StatusBadRequest) // Test using org repo "user3/repo3" where user2 is a collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s?token=%s", user3.Name, repo3.Name, repo3ReadmeSHA, token) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" where user2 is a collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s?token=%s", user3.Name, repo3.Name, repo3ReadmeSHA, token) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" with no user token req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s", user3.Name, repo3ReadmeSHA, repo3.Name) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Login as User4. session = loginUser(t, user4.Name) @@ -74,5 +74,5 @@ func TestAPIReposGitBlobs(t *testing.T) { // Test using org repo "user3/repo3" where user4 is a NOT collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/d56a3073c1dbb7b15963110a049d50cdb5db99fc?access=%s", user3.Name, repo3.Name, token4) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } diff --git a/tests/integration/api_repo_git_commits_test.go b/tests/integration/api_repo_git_commits_test.go index 90d17795c18e6..17750a2799f6c 100644 --- a/tests/integration/api_repo_git_commits_test.go +++ b/tests/integration/api_repo_git_commits_test.go @@ -32,13 +32,13 @@ func TestAPIReposGitCommits(t *testing.T) { // check invalid requests req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/12345?token="+token, user.Name) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/..?token="+token, user.Name) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/branch-not-exist?token="+token, user.Name) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) for _, ref := range [...]string{ "master", // Branch @@ -47,7 +47,7 @@ func TestAPIReposGitCommits(t *testing.T) { "65f1bf27bc3bf70f64657658635e66094edbcb4d", // full sha } { req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/commits/%s?token="+token, user.Name, ref) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } } @@ -60,7 +60,7 @@ func TestAPIReposGitCommitList(t *testing.T) { // Test getting commits (Page 1) req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/commits?token="+token, user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiData []api.Commit DecodeJSON(t, resp, &apiData) @@ -83,7 +83,7 @@ func TestAPIReposGitCommitListPage2Empty(t *testing.T) { // Test getting commits (Page=2) req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/commits?token="+token+"&page=2", user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiData []api.Commit DecodeJSON(t, resp, &apiData) @@ -100,7 +100,7 @@ func TestAPIReposGitCommitListDifferentBranch(t *testing.T) { // Test getting commits (Page=1, Branch=good-sign) req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/commits?token="+token+"&sha=good-sign", user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiData []api.Commit DecodeJSON(t, resp, &apiData) @@ -119,14 +119,14 @@ func TestDownloadCommitDiffOrPatch(t *testing.T) { // Test getting diff reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff?token="+token, user.Name) - resp := session.MakeRequest(t, reqDiff, http.StatusOK) + resp := MakeRequest(t, reqDiff, http.StatusOK) assert.EqualValues(t, "commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 \nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", resp.Body.String()) // Test getting patch reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch?token="+token, user.Name) - resp = session.MakeRequest(t, reqPatch, http.StatusOK) + resp = MakeRequest(t, reqPatch, http.StatusOK) assert.EqualValues(t, "From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 \nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n", resp.Body.String()) @@ -140,7 +140,7 @@ func TestGetFileHistory(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/commits?path=readme.md&token="+token+"&sha=good-sign", user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiData []api.Commit DecodeJSON(t, resp, &apiData) diff --git a/tests/integration/api_repo_git_notes_test.go b/tests/integration/api_repo_git_notes_test.go index e57055340e242..1448f405728b6 100644 --- a/tests/integration/api_repo_git_notes_test.go +++ b/tests/integration/api_repo_git_notes_test.go @@ -24,14 +24,14 @@ func TestAPIReposGitNotes(t *testing.T) { // check invalid requests req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/12345?token=%s", user.Name, token) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/..?token=%s", user.Name, token) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) // check valid request req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/notes/65f1bf27bc3bf70f64657658635e66094edbcb4d?token=%s", user.Name, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiData api.Note DecodeJSON(t, resp, &apiData) diff --git a/tests/integration/api_repo_git_ref_test.go b/tests/integration/api_repo_git_ref_test.go index ee4ae6e1268b1..aac01ca9ad429 100644 --- a/tests/integration/api_repo_git_ref_test.go +++ b/tests/integration/api_repo_git_ref_test.go @@ -24,12 +24,12 @@ func TestAPIReposGitRefs(t *testing.T) { "refs/tags/v1.1", // Tag } { req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/%s?token="+token, user.Name, ref) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } // Test getting all refs req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs?token="+token, user.Name) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test getting non-existent refs req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs/heads/unknown?token="+token, user.Name) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } diff --git a/tests/integration/api_repo_git_tags_test.go b/tests/integration/api_repo_git_tags_test.go index 941ede45f9095..146b4b74bd7dc 100644 --- a/tests/integration/api_repo_git_tags_test.go +++ b/tests/integration/api_repo_git_tags_test.go @@ -45,7 +45,7 @@ func TestAPIGitTags(t *testing.T) { // SHOULD work for annotated tags req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/tags/%s?token=%s", user.Name, repo.Name, aTag.ID.String(), token) - res := session.MakeRequest(t, req, http.StatusOK) + res := MakeRequest(t, req, http.StatusOK) var tag *api.AnnotatedTag DecodeJSON(t, res, &tag) @@ -60,7 +60,7 @@ func TestAPIGitTags(t *testing.T) { // Should NOT work for lightweight tags badReq := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/tags/%s?token=%s", user.Name, repo.Name, commit.ID.String(), token) - session.MakeRequest(t, badReq, http.StatusBadRequest) + MakeRequest(t, badReq, http.StatusBadRequest) } func TestAPIDeleteTagByName(t *testing.T) { @@ -75,7 +75,7 @@ func TestAPIDeleteTagByName(t *testing.T) { owner.Name, repo.Name, token) req := NewRequestf(t, http.MethodDelete, urlStr) - _ = session.MakeRequest(t, req, http.StatusNoContent) + _ = MakeRequest(t, req, http.StatusNoContent) // Make sure that actual releases can't be deleted outright createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test") @@ -83,5 +83,5 @@ func TestAPIDeleteTagByName(t *testing.T) { owner.Name, repo.Name, token) req = NewRequestf(t, http.MethodDelete, urlStr) - _ = session.MakeRequest(t, req, http.StatusConflict) + _ = MakeRequest(t, req, http.StatusConflict) } diff --git a/tests/integration/api_repo_git_trees_test.go b/tests/integration/api_repo_git_trees_test.go index b99326e1ac447..7a7630ea9033a 100644 --- a/tests/integration/api_repo_git_trees_test.go +++ b/tests/integration/api_repo_git_trees_test.go @@ -37,7 +37,7 @@ func TestAPIReposGitTrees(t *testing.T) { repo1TreeSHA, // Tree SHA } { req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo1.Name, ref) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } // Tests a private repo with no token so will fail @@ -46,24 +46,24 @@ func TestAPIReposGitTrees(t *testing.T) { repo1TreeSHA, // Tag } { req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo16.Name, ref) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } // Test using access token for a private repo that the user of the token owns req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s?token=%s", user2.Name, repo16.Name, repo16TreeSHA, token) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using bad sha req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user2.Name, repo1.Name, badSHA) - session.MakeRequest(t, req, http.StatusBadRequest) + MakeRequest(t, req, http.StatusBadRequest) // Test using org repo "user3/repo3" where user2 is a collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s?token=%s", user3.Name, repo3.Name, repo3TreeSHA, token) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) // Test using org repo "user3/repo3" with no user token req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/%s", user3.Name, repo3TreeSHA, repo3.Name) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // Login as User4. session = loginUser(t, user4.Name) @@ -72,5 +72,5 @@ func TestAPIReposGitTrees(t *testing.T) { // Test using org repo "user3/repo3" where user4 is a NOT collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/d56a3073c1dbb7b15963110a049d50cdb5db99fc?access=%s", user3.Name, repo3.Name, token4) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } diff --git a/tests/integration/api_repo_languages_test.go b/tests/integration/api_repo_languages_test.go index 17e626fa7fdff..f22ad9e7b7b86 100644 --- a/tests/integration/api_repo_languages_test.go +++ b/tests/integration/api_repo_languages_test.go @@ -18,7 +18,7 @@ func TestRepoLanguages(t *testing.T) { // Request editor page req := NewRequest(t, "GET", "/user2/repo1/_new/master/") - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) lastCommit := doc.GetInputValueByName("last_commit") @@ -32,14 +32,14 @@ func TestRepoLanguages(t *testing.T) { "content": "package main", "commit_choice": "direct", }) - session.MakeRequest(t, req, http.StatusSeeOther) + MakeRequest(t, req, http.StatusSeeOther) // let gitea calculate language stats time.Sleep(time.Second) // Save new file to master branch req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/languages") - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var languages map[string]int64 DecodeJSON(t, resp, &languages) diff --git a/tests/integration/api_repo_lfs_locks_test.go b/tests/integration/api_repo_lfs_locks_test.go index 5aa1396941ddd..5b299ba431ad1 100644 --- a/tests/integration/api_repo_lfs_locks_test.go +++ b/tests/integration/api_repo_lfs_locks_test.go @@ -107,7 +107,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks", test.repo.FullName()), map[string]string{"path": test.path}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp := session.MakeRequest(t, req, test.httpResult) + resp := MakeRequest(t, req, test.httpResult) if len(test.addTime) > 0 { var lfsLock api.LFSLockResponse DecodeJSON(t, resp, &lfsLock) @@ -124,7 +124,7 @@ func TestAPILFSLocksLogged(t *testing.T) { session := loginUser(t, test.user.Name) req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName()) req.Header.Set("Accept", lfs.MediaType) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var lfsLocks api.LFSLockList DecodeJSON(t, resp, &lfsLocks) assert.Len(t, lfsLocks.Locks, test.totalCount) @@ -137,7 +137,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/verify", test.repo.FullName()), map[string]string{}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var lfsLocksVerify api.LFSLockListVerify DecodeJSON(t, resp, &lfsLocksVerify) assert.Len(t, lfsLocksVerify.Ours, test.oursCount) @@ -161,7 +161,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/%s/unlock", test.repo.FullName(), test.lockID), map[string]string{}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var lfsLockRep api.LFSLockResponse DecodeJSON(t, resp, &lfsLockRep) assert.Equal(t, test.lockID, lfsLockRep.Lock.ID) @@ -173,7 +173,7 @@ func TestAPILFSLocksLogged(t *testing.T) { session := loginUser(t, test.user.Name) req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName()) req.Header.Set("Accept", lfs.MediaType) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var lfsLocks api.LFSLockList DecodeJSON(t, resp, &lfsLocks) assert.Len(t, lfsLocks.Locks, 0) diff --git a/tests/integration/api_repo_lfs_test.go b/tests/integration/api_repo_lfs_test.go index d4334ff8b99ca..deaaaa067cc19 100644 --- a/tests/integration/api_repo_lfs_test.go +++ b/tests/integration/api_repo_lfs_test.go @@ -98,7 +98,7 @@ func TestAPILFSBatch(t *testing.T) { req := newRequest(t, nil) - session.MakeRequest(t, req, http.StatusBadRequest) + MakeRequest(t, req, http.StatusBadRequest) }) t.Run("InvalidOperation", func(t *testing.T) { @@ -108,7 +108,7 @@ func TestAPILFSBatch(t *testing.T) { Operation: "dummy", }) - session.MakeRequest(t, req, http.StatusBadRequest) + MakeRequest(t, req, http.StatusBadRequest) }) t.Run("InvalidPointer", func(t *testing.T) { @@ -122,7 +122,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 2) assert.Equal(t, "dummy", br.Objects[0].Oid) @@ -147,7 +147,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -168,7 +168,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -192,7 +192,7 @@ func TestAPILFSBatch(t *testing.T) { Objects: []lfs.Pointer{p}, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -209,7 +209,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -236,7 +236,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -269,7 +269,7 @@ func TestAPILFSBatch(t *testing.T) { Objects: []lfs.Pointer{p}, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -294,7 +294,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -311,7 +311,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -350,7 +350,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "dummy"}, "") - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("AlreadyExistsInStore", func(t *testing.T) { @@ -371,13 +371,13 @@ func TestAPILFSUpload(t *testing.T) { t.Run("InvalidAccess", func(t *testing.T) { req := newRequest(t, p, "invalid") - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("ValidAccess", func(t *testing.T) { req := newRequest(t, p, "dummy5") - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) meta, err = git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.NoError(t, err) assert.NotNil(t, meta) @@ -393,7 +393,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: oid, Size: 6}, "") - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) }) t.Run("HashMismatch", func(t *testing.T) { @@ -401,7 +401,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "2581dd7bbc1fe44726de4b7dd806a087a978b9c5aec0a60481259e34be09b06a", Size: 1}, "a") - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("SizeMismatch", func(t *testing.T) { @@ -409,7 +409,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", Size: 2}, "a") - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("Success", func(t *testing.T) { @@ -419,7 +419,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, p, "gitea") - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) contentStore := lfs.NewContentStore() exist, err := contentStore.Exists(p) @@ -457,7 +457,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, nil) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("InvalidPointer", func(t *testing.T) { @@ -465,7 +465,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{}) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("PointerNotExisting", func(t *testing.T) { @@ -473,7 +473,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{Oid: "fb8f7d8435968c4f82a726a92395be4d16f2f63116caf36c8ad35c60831ab042", Size: 6}) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) }) t.Run("Success", func(t *testing.T) { @@ -481,6 +481,6 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{Oid: oid, Size: 6}) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) }) } diff --git a/tests/integration/api_repo_raw_test.go b/tests/integration/api_repo_raw_test.go index f050e354ac271..a35f1285b9683 100644 --- a/tests/integration/api_repo_raw_test.go +++ b/tests/integration/api_repo_raw_test.go @@ -27,11 +27,11 @@ func TestAPIReposRaw(t *testing.T) { "65f1bf27bc3bf70f64657658635e66094edbcb4d", // Commit } { req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md?token="+token, user.Name, ref) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type")) } // Test default branch req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md?token="+token, user.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type")) } diff --git a/tests/integration/api_repo_tags_test.go b/tests/integration/api_repo_tags_test.go index 5149542915eaf..6c7ab7971c769 100644 --- a/tests/integration/api_repo_tags_test.go +++ b/tests/integration/api_repo_tags_test.go @@ -27,7 +27,7 @@ func TestAPIRepoTags(t *testing.T) { repoName := "repo1" req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/tags?token=%s", user.Name, repoName, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var tags []*api.Tag DecodeJSON(t, resp, &tags) @@ -41,7 +41,7 @@ func TestAPIRepoTags(t *testing.T) { assert.Equal(t, setting.AppURL+"user2/repo1/archive/v1.1.tar.gz", tags[0].TarballURL) newTag := createNewTagUsingAPI(t, session, token, user.Name, repoName, "gitea/22", "", "nice!\nand some text") - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &tags) assert.Len(t, tags, 2) for _, tag := range tags { @@ -55,17 +55,17 @@ func TestAPIRepoTags(t *testing.T) { // get created tag req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/tags/%s?token=%s", user.Name, repoName, newTag.Name, token) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) var tag *api.Tag DecodeJSON(t, resp, &tag) assert.EqualValues(t, newTag, tag) // delete tag delReq := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/tags/%s?token=%s", user.Name, repoName, newTag.Name, token) - session.MakeRequest(t, delReq, http.StatusNoContent) + MakeRequest(t, delReq, http.StatusNoContent) // check if it's gone - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, repoName, name, target, msg string) *api.Tag { @@ -75,7 +75,7 @@ func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, Message: msg, Target: target, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var respObj api.Tag DecodeJSON(t, resp, &respObj) diff --git a/tests/integration/api_repo_teams_test.go b/tests/integration/api_repo_teams_test.go index 58ba841948c85..e4d054aaf845d 100644 --- a/tests/integration/api_repo_teams_test.go +++ b/tests/integration/api_repo_teams_test.go @@ -32,7 +32,7 @@ func TestAPIRepoTeams(t *testing.T) { // ListTeams url := fmt.Sprintf("/api/v1/repos/%s/teams?token=%s", publicOrgRepo.FullName(), token) req := NewRequest(t, "GET", url) - res := session.MakeRequest(t, req, http.StatusOK) + res := MakeRequest(t, req, http.StatusOK) var teams []*api.Team DecodeJSON(t, res, &teams) if assert.Len(t, teams, 2) { @@ -50,19 +50,19 @@ func TestAPIRepoTeams(t *testing.T) { // IsTeam url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "Test_Team", token) req = NewRequest(t, "GET", url) - res = session.MakeRequest(t, req, http.StatusOK) + res = MakeRequest(t, req, http.StatusOK) var team *api.Team DecodeJSON(t, res, &team) assert.EqualValues(t, teams[1], team) url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "NonExistingTeam", token) req = NewRequest(t, "GET", url) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // AddTeam with user4 url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token) req = NewRequest(t, "PUT", url) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // AddTeam with user2 user = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) @@ -70,12 +70,12 @@ func TestAPIRepoTeams(t *testing.T) { token = getTokenForLoggedInUser(t, session) url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token) req = NewRequest(t, "PUT", url) - session.MakeRequest(t, req, http.StatusNoContent) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request + MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request // DeleteTeam url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token) req = NewRequest(t, "DELETE", url) - session.MakeRequest(t, req, http.StatusNoContent) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request + MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request } diff --git a/tests/integration/api_repo_test.go b/tests/integration/api_repo_test.go index e32bb47bc7088..c84416104ca84 100644 --- a/tests/integration/api_repo_test.go +++ b/tests/integration/api_repo_test.go @@ -198,7 +198,7 @@ func TestAPISearchRepo(t *testing.T) { t.Run(testName, func(t *testing.T) { request := NewRequest(t, "GET", testCase.requestURL+"&token="+token) - response := session.MakeRequest(t, request, http.StatusOK) + response := MakeRequest(t, request, http.StatusOK) var body api.SearchResults DecodeJSON(t, response, &body) @@ -306,7 +306,7 @@ func TestAPIOrgRepos(t *testing.T) { } t.Run(testName, func(t *testing.T) { req := NewRequestf(t, "GET", "/api/v1/orgs/%s/repos?token="+token, sourceOrg.Name) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiRepos []*api.Repository DecodeJSON(t, resp, &apiRepos) @@ -326,7 +326,7 @@ func TestAPIGetRepoByIDUnauthorized(t *testing.T) { session := loginUser(t, user.Name) token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "GET", "/api/v1/repositories/2?token="+token) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) } func TestAPIRepoMigrate(t *testing.T) { @@ -422,7 +422,7 @@ func TestAPIMirrorSyncNonMirrorRepo(t *testing.T) { assert.EqualValues(t, false, repo.Mirror) req = NewRequestf(t, "POST", "/api/v1/repos/user2/repo1/mirror-sync?token=%s", token) - resp = session.MakeRequest(t, req, http.StatusBadRequest) + resp = MakeRequest(t, req, http.StatusBadRequest) errRespJSON := map[string]string{} DecodeJSON(t, resp, &errRespJSON) assert.Equal(t, "Repository is not a mirror", errRespJSON["message"]) @@ -449,7 +449,7 @@ func TestAPIOrgRepoCreate(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/org/%s/repos?token="+token, testCase.orgName), &api.CreateRepoOption{ Name: testCase.repoName, }) - session.MakeRequest(t, req, testCase.expectedStatus) + MakeRequest(t, req, testCase.expectedStatus) } } @@ -519,7 +519,7 @@ func TestAPIRepoTransfer(t *testing.T) { Readme: "Default", AutoInit: true, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, apiRepo) // start testing @@ -532,7 +532,7 @@ func TestAPIRepoTransfer(t *testing.T) { NewOwner: testCase.newOwner, TeamIDs: testCase.teams, }) - session.MakeRequest(t, req, testCase.expectedStatus) + MakeRequest(t, req, testCase.expectedStatus) } // cleanup @@ -555,14 +555,14 @@ func transfer(t *testing.T) *repo_model.Repository { AutoInit: true, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, apiRepo) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: apiRepo.ID}) req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer?token=%s", repo.OwnerName, repo.Name, token), &api.TransferRepoOption{ NewOwner: "user4", }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) return repo } @@ -576,18 +576,18 @@ func TestAPIAcceptTransfer(t *testing.T) { session := loginUser(t, "user2") token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/reject?token=%s", repo.OwnerName, repo.Name, token)) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // try to accept repo that's not marked as transferred req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/accept?token=%s", "user2", "repo1", token)) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // accept transfer session = loginUser(t, "user4") token = getTokenForLoggedInUser(t, session) req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/accept?token=%s", repo.OwnerName, repo.Name, token)) - resp := session.MakeRequest(t, req, http.StatusAccepted) + resp := MakeRequest(t, req, http.StatusAccepted) apiRepo := new(api.Repository) DecodeJSON(t, resp, apiRepo) assert.Equal(t, "user4", apiRepo.Owner.UserName) @@ -602,18 +602,18 @@ func TestAPIRejectTransfer(t *testing.T) { session := loginUser(t, "user2") token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/reject?token=%s", repo.OwnerName, repo.Name, token)) - session.MakeRequest(t, req, http.StatusForbidden) + MakeRequest(t, req, http.StatusForbidden) // try to reject repo that's not marked as transferred req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/reject?token=%s", "user2", "repo1", token)) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) // reject transfer session = loginUser(t, "user4") token = getTokenForLoggedInUser(t, session) req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/transfer/reject?token=%s", repo.OwnerName, repo.Name, token)) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) apiRepo := new(api.Repository) DecodeJSON(t, resp, apiRepo) assert.Equal(t, "user2", apiRepo.Owner.UserName) @@ -637,7 +637,7 @@ func TestAPIGenerateRepo(t *testing.T) { Private: false, GitContent: true, }) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, repo) assert.Equal(t, "new-repo", repo.Name) @@ -650,7 +650,7 @@ func TestAPIGenerateRepo(t *testing.T) { Private: false, GitContent: true, }) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, repo) assert.Equal(t, "new-repo", repo.Name) @@ -664,7 +664,7 @@ func TestAPIRepoGetReviewers(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/reviewers?token=%s", user.Name, repo.Name, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var reviewers []*api.User DecodeJSON(t, resp, &reviewers) assert.Len(t, reviewers, 4) @@ -678,7 +678,7 @@ func TestAPIRepoGetAssignees(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/assignees?token=%s", user.Name, repo.Name, token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var assignees []*api.User DecodeJSON(t, resp, &assignees) assert.Len(t, assignees, 1) diff --git a/tests/integration/api_team_test.go b/tests/integration/api_team_test.go index c6be5c19472c6..46207203bc37d 100644 --- a/tests/integration/api_team_test.go +++ b/tests/integration/api_team_test.go @@ -31,7 +31,7 @@ func TestAPITeam(t *testing.T) { session := loginUser(t, user.Name) token := getTokenForLoggedInUser(t, session) req := NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamUser.TeamID) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiTeam api.Team DecodeJSON(t, resp, &apiTeam) @@ -45,10 +45,10 @@ func TestAPITeam(t *testing.T) { session = loginUser(t, user2.Name) token = getTokenForLoggedInUser(t, session) req = NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamUser.TeamID) - _ = session.MakeRequest(t, req, http.StatusForbidden) + _ = MakeRequest(t, req, http.StatusForbidden) req = NewRequestf(t, "GET", "/api/v1/teams/%d", teamUser.TeamID) - _ = session.MakeRequest(t, req, http.StatusUnauthorized) + _ = MakeRequest(t, req, http.StatusUnauthorized) // Get an admin user able to create, update and delete teams. user = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}) @@ -66,7 +66,7 @@ func TestAPITeam(t *testing.T) { Units: []string{"repo.code", "repo.issues"}, } req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/orgs/%s/teams?token=%s", org.Name, token), teamToCreate) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "CreateTeam1", &apiTeam, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories, @@ -87,7 +87,7 @@ func TestAPITeam(t *testing.T) { } req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/teams/%d?token=%s", teamID, token), teamToEdit) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "EditTeam1", &apiTeam, teamToEdit.Name, *teamToEdit.Description, *teamToEdit.IncludesAllRepositories, @@ -99,7 +99,7 @@ func TestAPITeam(t *testing.T) { editDescription = "first team" teamToEditDesc := api.EditTeamOption{Description: &editDescription} req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/teams/%d?token=%s", teamID, token), teamToEditDesc) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "EditTeam1_DescOnly", &apiTeam, teamToEdit.Name, *teamToEditDesc.Description, *teamToEdit.IncludesAllRepositories, @@ -111,7 +111,7 @@ func TestAPITeam(t *testing.T) { teamRead := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamID}) assert.NoError(t, teamRead.GetUnits()) req = NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamID) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "ReadTeam1", &apiTeam, teamRead.Name, *teamToEditDesc.Description, teamRead.IncludesAllRepositories, @@ -119,7 +119,7 @@ func TestAPITeam(t *testing.T) { // Delete team. req = NewRequestf(t, "DELETE", "/api/v1/teams/%d?token="+token, teamID) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) unittest.AssertNotExistsBean(t, &organization.Team{ID: teamID}) // create team again via UnitsMap @@ -132,7 +132,7 @@ func TestAPITeam(t *testing.T) { UnitsMap: map[string]string{"repo.code": "read", "repo.issues": "write", "repo.wiki": "none"}, } req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/orgs/%s/teams?token=%s", org.Name, token), teamToCreate) - resp = session.MakeRequest(t, req, http.StatusCreated) + resp = MakeRequest(t, req, http.StatusCreated) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "CreateTeam2", &apiTeam, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories, @@ -153,7 +153,7 @@ func TestAPITeam(t *testing.T) { } req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/teams/%d?token=%s", teamID, token), teamToEdit) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "EditTeam2", &apiTeam, teamToEdit.Name, *teamToEdit.Description, *teamToEdit.IncludesAllRepositories, @@ -165,7 +165,7 @@ func TestAPITeam(t *testing.T) { editDescription = "second team" teamToEditDesc = api.EditTeamOption{Description: &editDescription} req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/teams/%d?token=%s", teamID, token), teamToEditDesc) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) checkTeamResponse(t, "EditTeam2_DescOnly", &apiTeam, teamToEdit.Name, *teamToEditDesc.Description, *teamToEdit.IncludesAllRepositories, @@ -176,7 +176,7 @@ func TestAPITeam(t *testing.T) { // Read team. teamRead = unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: teamID}) req = NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamID) - resp = session.MakeRequest(t, req, http.StatusOK) + resp = MakeRequest(t, req, http.StatusOK) apiTeam = api.Team{} DecodeJSON(t, resp, &apiTeam) assert.NoError(t, teamRead.GetUnits()) @@ -185,7 +185,7 @@ func TestAPITeam(t *testing.T) { // Delete team. req = NewRequestf(t, "DELETE", "/api/v1/teams/%d?token="+token, teamID) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) unittest.AssertNotExistsBean(t, &organization.Team{ID: teamID}) } diff --git a/tests/integration/api_team_user_test.go b/tests/integration/api_team_user_test.go index d09749d65ca5b..78f98680c1116 100644 --- a/tests/integration/api_team_user_test.go +++ b/tests/integration/api_team_user_test.go @@ -24,10 +24,10 @@ func TestAPITeamUser(t *testing.T) { session := loginUser(t, normalUsername) token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "GET", "/api/v1/teams/1/members/user1?token="+token) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) req = NewRequest(t, "GET", "/api/v1/teams/1/members/user2?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var user2 *api.User DecodeJSON(t, resp, &user2) user2.Created = user2.Created.In(time.Local) diff --git a/tests/integration/api_user_email_test.go b/tests/integration/api_user_email_test.go index 5f2592252a389..147f703e9a41d 100644 --- a/tests/integration/api_user_email_test.go +++ b/tests/integration/api_user_email_test.go @@ -21,7 +21,7 @@ func TestAPIListEmails(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "GET", "/api/v1/user/emails?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var emails []*api.Email DecodeJSON(t, resp, &emails) @@ -52,13 +52,13 @@ func TestAPIAddEmail(t *testing.T) { } req := NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) opts = api.CreateEmailOption{ Emails: []string{"user2-3@example.com"}, } req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts) - resp := session.MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) var emails []*api.Email DecodeJSON(t, resp, &emails) @@ -74,7 +74,7 @@ func TestAPIAddEmail(t *testing.T) { Emails: []string{"notAEmail"}, } req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts) - session.MakeRequest(t, req, http.StatusUnprocessableEntity) + MakeRequest(t, req, http.StatusUnprocessableEntity) } func TestAPIDeleteEmail(t *testing.T) { @@ -88,16 +88,16 @@ func TestAPIDeleteEmail(t *testing.T) { Emails: []string{"user2-3@example.com"}, } req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts) - session.MakeRequest(t, req, http.StatusNotFound) + MakeRequest(t, req, http.StatusNotFound) opts = api.DeleteEmailOption{ Emails: []string{"user2-2@example.com"}, } req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts) - session.MakeRequest(t, req, http.StatusNoContent) + MakeRequest(t, req, http.StatusNoContent) req = NewRequest(t, "GET", "/api/v1/user/emails?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var emails []*api.Email DecodeJSON(t, resp, &emails) diff --git a/tests/integration/api_user_org_perm_test.go b/tests/integration/api_user_org_perm_test.go index 9483283e32884..94a62b2ab54f3 100644 --- a/tests/integration/api_user_org_perm_test.go +++ b/tests/integration/api_user_org_perm_test.go @@ -26,7 +26,7 @@ func TestTokenNeeded(t *testing.T) { session := emptyTestSession(t) req := NewRequest(t, "GET", "/api/v1/users/user1/orgs/user6/permissions") - session.MakeRequest(t, req, http.StatusUnauthorized) + MakeRequest(t, req, http.StatusUnauthorized) } func sampleTest(t *testing.T, auoptc apiUserOrgPermTestCase) { @@ -36,7 +36,7 @@ func sampleTest(t *testing.T, auoptc apiUserOrgPermTestCase) { token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/orgs/%s/permissions?token=%s", auoptc.User, auoptc.Organization, token)) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var apiOP api.OrganizationPermissions DecodeJSON(t, resp, &apiOP) @@ -129,7 +129,7 @@ func TestUnknowUser(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/unknow/orgs/org25/permissions?token=%s", token)) - resp := session.MakeRequest(t, req, http.StatusNotFound) + resp := MakeRequest(t, req, http.StatusNotFound) var apiError api.APIError DecodeJSON(t, resp, &apiError) @@ -143,7 +143,7 @@ func TestUnknowOrganization(t *testing.T) { token := getTokenForLoggedInUser(t, session) req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/user1/orgs/unknow/permissions?token=%s", token)) - resp := session.MakeRequest(t, req, http.StatusNotFound) + resp := MakeRequest(t, req, http.StatusNotFound) var apiError api.APIError DecodeJSON(t, resp, &apiError) assert.Equal(t, "GetUserByName", apiError.Message) diff --git a/tests/integration/api_user_orgs_test.go b/tests/integration/api_user_orgs_test.go index f29014e934c99..140d7a777b16f 100644 --- a/tests/integration/api_user_orgs_test.go +++ b/tests/integration/api_user_orgs_test.go @@ -75,7 +75,7 @@ func getUserOrgs(t *testing.T, userDoer, userCheck string) (orgs []*api.Organiza } urlStr := fmt.Sprintf("/api/v1/users/%s/orgs?token=%s", userCheck, token) req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &orgs) return orgs } @@ -85,13 +85,13 @@ func TestMyOrgs(t *testing.T) { session := emptyTestSession(t) req := NewRequest(t, "GET", "/api/v1/user/orgs") - session.MakeRequest(t, req, http.StatusUnauthorized) + MakeRequest(t, req, http.StatusUnauthorized) normalUsername := "user2" session = loginUser(t, normalUsername) token := getTokenForLoggedInUser(t, session) req = NewRequest(t, "GET", "/api/v1/user/orgs?token="+token) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var orgs []*api.Organization DecodeJSON(t, resp, &orgs) user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user3"}) diff --git a/tests/integration/api_user_search_test.go b/tests/integration/api_user_search_test.go index 58b24d0e1efcf..dc11281c46f1b 100644 --- a/tests/integration/api_user_search_test.go +++ b/tests/integration/api_user_search_test.go @@ -29,7 +29,7 @@ func TestAPIUserSearchLoggedIn(t *testing.T) { token := getTokenForLoggedInUser(t, session) query := "user2" req := NewRequestf(t, "GET", "/api/v1/users/search?token=%s&q=%s", token, query) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var results SearchResults DecodeJSON(t, resp, &results) @@ -69,7 +69,7 @@ func TestAPIUserSearchAdminLoggedInUserHidden(t *testing.T) { query := "user31" req := NewRequestf(t, "GET", "/api/v1/users/search?token=%s&q=%s", token, query) req.SetBasicAuth(token, "x-oauth-basic") - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var results SearchResults DecodeJSON(t, resp, &results) diff --git a/tests/integration/api_wiki_test.go b/tests/integration/api_wiki_test.go index d56b04e913180..1dab796fea704 100644 --- a/tests/integration/api_wiki_test.go +++ b/tests/integration/api_wiki_test.go @@ -24,7 +24,7 @@ func TestAPIGetWikiPage(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/page/Home", username, "repo1") req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var page *api.WikiPage DecodeJSON(t, resp, &page) @@ -70,7 +70,7 @@ func TestAPIListWikiPages(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/pages", username, "repo1") req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var meta []*api.WikiPageMetaData DecodeJSON(t, resp, &meta) @@ -190,7 +190,7 @@ func TestAPINewWikiPage(t *testing.T) { ContentBase64: base64.StdEncoding.EncodeToString([]byte("Wiki page content for API unit tests")), Message: "", }) - session.MakeRequest(t, req, http.StatusCreated) + MakeRequest(t, req, http.StatusCreated) } } @@ -207,7 +207,7 @@ func TestAPIEditWikiPage(t *testing.T) { ContentBase64: base64.StdEncoding.EncodeToString([]byte("Edited wiki page content for API unit tests")), Message: "", }) - session.MakeRequest(t, req, http.StatusOK) + MakeRequest(t, req, http.StatusOK) } func TestAPIListPageRevisions(t *testing.T) { @@ -218,7 +218,7 @@ func TestAPIListPageRevisions(t *testing.T) { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/revisions/Home", username, "repo1") req := NewRequest(t, "GET", urlStr) - resp := session.MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) var revisions *api.WikiCommitList DecodeJSON(t, resp, &revisions) From 4f60bda39e7d1563f7d36b3ae9a71d66231faffe Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 30 Nov 2022 15:51:41 +0800 Subject: [PATCH 2/4] Fix lint --- tests/integration/api_pull_commits_test.go | 1 - tests/integration/api_releases_test.go | 1 - .../integration/api_repo_collaborator_test.go | 1 - tests/integration/api_repo_edit_test.go | 1 - .../integration/api_repo_file_create_test.go | 1 - .../integration/api_repo_file_delete_test.go | 1 - .../integration/api_repo_file_update_test.go | 1 - .../api_repo_get_contents_list_test.go | 1 - .../integration/api_repo_get_contents_test.go | 1 - tests/integration/api_repo_git_blobs_test.go | 2 - tests/integration/api_repo_git_trees_test.go | 2 - tests/integration/api_repo_languages_test.go | 4 +- tests/integration/api_repo_lfs_locks_test.go | 10 ++--- tests/integration/api_repo_lfs_test.go | 44 +++++++++---------- tests/integration/api_user_org_perm_test.go | 1 - tests/integration/api_user_orgs_test.go | 8 +--- tests/integration/api_wiki_test.go | 3 -- 17 files changed, 31 insertions(+), 52 deletions(-) diff --git a/tests/integration/api_pull_commits_test.go b/tests/integration/api_pull_commits_test.go index 6449cc29c7d25..0bcfb906845a4 100644 --- a/tests/integration/api_pull_commits_test.go +++ b/tests/integration/api_pull_commits_test.go @@ -23,7 +23,6 @@ func TestAPIPullCommits(t *testing.T) { assert.NoError(t, pr.LoadIssue(db.DefaultContext)) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: pr.HeadRepoID}) - session := loginUser(t, "user2") req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/commits", repo.OwnerName, repo.Name, pr.Index) resp := MakeRequest(t, req, http.StatusOK) diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index 51bc07a3258eb..12d2a02fb13da 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -180,7 +180,6 @@ func TestAPIGetReleaseByTag(t *testing.T) { repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}) - session := loginUser(t, owner.LowerName) tag := "v1.1" diff --git a/tests/integration/api_repo_collaborator_test.go b/tests/integration/api_repo_collaborator_test.go index 6f96e13c66f9c..318c86e2c31f3 100644 --- a/tests/integration/api_repo_collaborator_test.go +++ b/tests/integration/api_repo_collaborator_test.go @@ -27,7 +27,6 @@ func TestAPIRepoCollaboratorPermission(t *testing.T) { user10 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 10}) user11 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 11}) - session := loginUser(t, repo2Owner.Name) testCtx := NewAPITestContext(t, repo2Owner.Name, repo2.Name) t.Run("RepoOwnerShouldBeOwner", func(t *testing.T) { diff --git a/tests/integration/api_repo_edit_test.go b/tests/integration/api_repo_edit_test.go index d29200635467d..47e07f8d4b650 100644 --- a/tests/integration/api_repo_edit_test.go +++ b/tests/integration/api_repo_edit_test.go @@ -149,7 +149,6 @@ func TestAPIRepoEdit(t *testing.T) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Test editing a repo1 which user2 owns, changing name and many properties origRepoEditOption := getRepoEditOptionFromRepo(repo1) diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index 2586ae1ee29a5..476441dbb1361 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -154,7 +154,6 @@ func TestAPICreateFile(t *testing.T) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Test creating a file in repo1 which user2 owns, try both with branch and empty branch for _, branch := range [...]string{ diff --git a/tests/integration/api_repo_file_delete_test.go b/tests/integration/api_repo_file_delete_test.go index 18544083c251e..196d3208f5aa4 100644 --- a/tests/integration/api_repo_file_delete_test.go +++ b/tests/integration/api_repo_file_delete_test.go @@ -52,7 +52,6 @@ func TestAPIDeleteFile(t *testing.T) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Test deleting a file in repo1 which user2 owns, try both with branch and empty branch for _, branch := range [...]string{ diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index 933452fcec698..6dd06b712590e 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -120,7 +120,6 @@ func TestAPIUpdateFile(t *testing.T) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Test updating a file in repo1 which user2 owns, try both with branch and empty branch for _, branch := range [...]string{ diff --git a/tests/integration/api_repo_get_contents_list_test.go b/tests/integration/api_repo_get_contents_list_test.go index 1fc037dc09a8b..2c7b44120c512 100644 --- a/tests/integration/api_repo_get_contents_list_test.go +++ b/tests/integration/api_repo_get_contents_list_test.go @@ -68,7 +68,6 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Make a new branch in repo1 newBranch := "test_branch" diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go index 5eddd0166f7fe..f7d9c716aaf11 100644 --- a/tests/integration/api_repo_get_contents_test.go +++ b/tests/integration/api_repo_get_contents_test.go @@ -69,7 +69,6 @@ func testAPIGetContents(t *testing.T, u *url.URL) { // Get user4's token session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // Make a new branch in repo1 newBranch := "test_branch" diff --git a/tests/integration/api_repo_git_blobs_test.go b/tests/integration/api_repo_git_blobs_test.go index 8240b1342921e..02652e5934843 100644 --- a/tests/integration/api_repo_git_blobs_test.go +++ b/tests/integration/api_repo_git_blobs_test.go @@ -32,7 +32,6 @@ func TestAPIReposGitBlobs(t *testing.T) { // Login as User2. session := loginUser(t, user2.Name) token := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // don't want anyone logged in for this // Test a public repo that anyone can GET the blob of req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/%s", user2.Name, repo1.Name, repo1ReadmeSHA) @@ -70,7 +69,6 @@ func TestAPIReposGitBlobs(t *testing.T) { // Login as User4. session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // don't want anyone logged in for this // Test using org repo "user3/repo3" where user4 is a NOT collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/blobs/d56a3073c1dbb7b15963110a049d50cdb5db99fc?access=%s", user3.Name, repo3.Name, token4) diff --git a/tests/integration/api_repo_git_trees_test.go b/tests/integration/api_repo_git_trees_test.go index 7a7630ea9033a..d1d49e4627f7e 100644 --- a/tests/integration/api_repo_git_trees_test.go +++ b/tests/integration/api_repo_git_trees_test.go @@ -29,7 +29,6 @@ func TestAPIReposGitTrees(t *testing.T) { // Login as User2. session := loginUser(t, user2.Name) token := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // don't want anyone logged in for this // Test a public repo that anyone can GET the tree of for _, ref := range [...]string{ @@ -68,7 +67,6 @@ func TestAPIReposGitTrees(t *testing.T) { // Login as User4. session = loginUser(t, user4.Name) token4 := getTokenForLoggedInUser(t, session) - session = emptyTestSession(t) // don't want anyone logged in for this // Test using org repo "user3/repo3" where user4 is a NOT collaborator req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/trees/d56a3073c1dbb7b15963110a049d50cdb5db99fc?access=%s", user3.Name, repo3.Name, token4) diff --git a/tests/integration/api_repo_languages_test.go b/tests/integration/api_repo_languages_test.go index f22ad9e7b7b86..1045aef57d7e2 100644 --- a/tests/integration/api_repo_languages_test.go +++ b/tests/integration/api_repo_languages_test.go @@ -18,7 +18,7 @@ func TestRepoLanguages(t *testing.T) { // Request editor page req := NewRequest(t, "GET", "/user2/repo1/_new/master/") - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) lastCommit := doc.GetInputValueByName("last_commit") @@ -32,7 +32,7 @@ func TestRepoLanguages(t *testing.T) { "content": "package main", "commit_choice": "direct", }) - MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusSeeOther) // let gitea calculate language stats time.Sleep(time.Second) diff --git a/tests/integration/api_repo_lfs_locks_test.go b/tests/integration/api_repo_lfs_locks_test.go index 5b299ba431ad1..5aa1396941ddd 100644 --- a/tests/integration/api_repo_lfs_locks_test.go +++ b/tests/integration/api_repo_lfs_locks_test.go @@ -107,7 +107,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks", test.repo.FullName()), map[string]string{"path": test.path}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp := MakeRequest(t, req, test.httpResult) + resp := session.MakeRequest(t, req, test.httpResult) if len(test.addTime) > 0 { var lfsLock api.LFSLockResponse DecodeJSON(t, resp, &lfsLock) @@ -124,7 +124,7 @@ func TestAPILFSLocksLogged(t *testing.T) { session := loginUser(t, test.user.Name) req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName()) req.Header.Set("Accept", lfs.MediaType) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) var lfsLocks api.LFSLockList DecodeJSON(t, resp, &lfsLocks) assert.Len(t, lfsLocks.Locks, test.totalCount) @@ -137,7 +137,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/verify", test.repo.FullName()), map[string]string{}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp = MakeRequest(t, req, http.StatusOK) + resp = session.MakeRequest(t, req, http.StatusOK) var lfsLocksVerify api.LFSLockListVerify DecodeJSON(t, resp, &lfsLocksVerify) assert.Len(t, lfsLocksVerify.Ours, test.oursCount) @@ -161,7 +161,7 @@ func TestAPILFSLocksLogged(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/%s/unlock", test.repo.FullName(), test.lockID), map[string]string{}) req.Header.Set("Accept", lfs.MediaType) req.Header.Set("Content-Type", lfs.MediaType) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) var lfsLockRep api.LFSLockResponse DecodeJSON(t, resp, &lfsLockRep) assert.Equal(t, test.lockID, lfsLockRep.Lock.ID) @@ -173,7 +173,7 @@ func TestAPILFSLocksLogged(t *testing.T) { session := loginUser(t, test.user.Name) req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName()) req.Header.Set("Accept", lfs.MediaType) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) var lfsLocks api.LFSLockList DecodeJSON(t, resp, &lfsLocks) assert.Len(t, lfsLocks.Locks, 0) diff --git a/tests/integration/api_repo_lfs_test.go b/tests/integration/api_repo_lfs_test.go index deaaaa067cc19..d4334ff8b99ca 100644 --- a/tests/integration/api_repo_lfs_test.go +++ b/tests/integration/api_repo_lfs_test.go @@ -98,7 +98,7 @@ func TestAPILFSBatch(t *testing.T) { req := newRequest(t, nil) - MakeRequest(t, req, http.StatusBadRequest) + session.MakeRequest(t, req, http.StatusBadRequest) }) t.Run("InvalidOperation", func(t *testing.T) { @@ -108,7 +108,7 @@ func TestAPILFSBatch(t *testing.T) { Operation: "dummy", }) - MakeRequest(t, req, http.StatusBadRequest) + session.MakeRequest(t, req, http.StatusBadRequest) }) t.Run("InvalidPointer", func(t *testing.T) { @@ -122,7 +122,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 2) assert.Equal(t, "dummy", br.Objects[0].Oid) @@ -147,7 +147,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -168,7 +168,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -192,7 +192,7 @@ func TestAPILFSBatch(t *testing.T) { Objects: []lfs.Pointer{p}, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -209,7 +209,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -236,7 +236,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.NotNil(t, br.Objects[0].Error) @@ -269,7 +269,7 @@ func TestAPILFSBatch(t *testing.T) { Objects: []lfs.Pointer{p}, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -294,7 +294,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -311,7 +311,7 @@ func TestAPILFSBatch(t *testing.T) { }, }) - resp := MakeRequest(t, req, http.StatusOK) + resp := session.MakeRequest(t, req, http.StatusOK) br := decodeResponse(t, resp.Body) assert.Len(t, br.Objects, 1) assert.Nil(t, br.Objects[0].Error) @@ -350,7 +350,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "dummy"}, "") - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("AlreadyExistsInStore", func(t *testing.T) { @@ -371,13 +371,13 @@ func TestAPILFSUpload(t *testing.T) { t.Run("InvalidAccess", func(t *testing.T) { req := newRequest(t, p, "invalid") - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("ValidAccess", func(t *testing.T) { req := newRequest(t, p, "dummy5") - MakeRequest(t, req, http.StatusOK) + session.MakeRequest(t, req, http.StatusOK) meta, err = git_model.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.NoError(t, err) assert.NotNil(t, meta) @@ -393,7 +393,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: oid, Size: 6}, "") - MakeRequest(t, req, http.StatusOK) + session.MakeRequest(t, req, http.StatusOK) }) t.Run("HashMismatch", func(t *testing.T) { @@ -401,7 +401,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "2581dd7bbc1fe44726de4b7dd806a087a978b9c5aec0a60481259e34be09b06a", Size: 1}, "a") - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("SizeMismatch", func(t *testing.T) { @@ -409,7 +409,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, lfs.Pointer{Oid: "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", Size: 2}, "a") - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("Success", func(t *testing.T) { @@ -419,7 +419,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, p, "gitea") - MakeRequest(t, req, http.StatusOK) + session.MakeRequest(t, req, http.StatusOK) contentStore := lfs.NewContentStore() exist, err := contentStore.Exists(p) @@ -457,7 +457,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, nil) - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("InvalidPointer", func(t *testing.T) { @@ -465,7 +465,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{}) - MakeRequest(t, req, http.StatusUnprocessableEntity) + session.MakeRequest(t, req, http.StatusUnprocessableEntity) }) t.Run("PointerNotExisting", func(t *testing.T) { @@ -473,7 +473,7 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{Oid: "fb8f7d8435968c4f82a726a92395be4d16f2f63116caf36c8ad35c60831ab042", Size: 6}) - MakeRequest(t, req, http.StatusNotFound) + session.MakeRequest(t, req, http.StatusNotFound) }) t.Run("Success", func(t *testing.T) { @@ -481,6 +481,6 @@ func TestAPILFSVerify(t *testing.T) { req := newRequest(t, &lfs.Pointer{Oid: oid, Size: 6}) - MakeRequest(t, req, http.StatusOK) + session.MakeRequest(t, req, http.StatusOK) }) } diff --git a/tests/integration/api_user_org_perm_test.go b/tests/integration/api_user_org_perm_test.go index 94a62b2ab54f3..8df418494a2c2 100644 --- a/tests/integration/api_user_org_perm_test.go +++ b/tests/integration/api_user_org_perm_test.go @@ -24,7 +24,6 @@ type apiUserOrgPermTestCase struct { func TestTokenNeeded(t *testing.T) { defer tests.PrepareTestEnv(t)() - session := emptyTestSession(t) req := NewRequest(t, "GET", "/api/v1/users/user1/orgs/user6/permissions") MakeRequest(t, req, http.StatusUnauthorized) } diff --git a/tests/integration/api_user_orgs_test.go b/tests/integration/api_user_orgs_test.go index 140d7a777b16f..1f9ee2ea6eef6 100644 --- a/tests/integration/api_user_orgs_test.go +++ b/tests/integration/api_user_orgs_test.go @@ -68,10 +68,8 @@ func TestUserOrgs(t *testing.T) { func getUserOrgs(t *testing.T, userDoer, userCheck string) (orgs []*api.Organization) { token := "" - session := emptyTestSession(t) if len(userDoer) != 0 { - session = loginUser(t, userDoer) - token = getTokenForLoggedInUser(t, session) + token = getUserToken(t, userDoer) } urlStr := fmt.Sprintf("/api/v1/users/%s/orgs?token=%s", userCheck, token) req := NewRequest(t, "GET", urlStr) @@ -83,13 +81,11 @@ func getUserOrgs(t *testing.T, userDoer, userCheck string) (orgs []*api.Organiza func TestMyOrgs(t *testing.T) { defer tests.PrepareTestEnv(t)() - session := emptyTestSession(t) req := NewRequest(t, "GET", "/api/v1/user/orgs") MakeRequest(t, req, http.StatusUnauthorized) normalUsername := "user2" - session = loginUser(t, normalUsername) - token := getTokenForLoggedInUser(t, session) + token := getUserToken(t, normalUsername) req = NewRequest(t, "GET", "/api/v1/user/orgs?token="+token) resp := MakeRequest(t, req, http.StatusOK) var orgs []*api.Organization diff --git a/tests/integration/api_wiki_test.go b/tests/integration/api_wiki_test.go index 1dab796fea704..546f4d0e3e8ec 100644 --- a/tests/integration/api_wiki_test.go +++ b/tests/integration/api_wiki_test.go @@ -19,7 +19,6 @@ func TestAPIGetWikiPage(t *testing.T) { defer tests.PrepareTestEnv(t)() username := "user2" - session := loginUser(t, username) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/page/Home", username, "repo1") @@ -65,7 +64,6 @@ func TestAPIListWikiPages(t *testing.T) { defer tests.PrepareTestEnv(t)() username := "user2" - session := loginUser(t, username) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/pages", username, "repo1") @@ -213,7 +211,6 @@ func TestAPIEditWikiPage(t *testing.T) { func TestAPIListPageRevisions(t *testing.T) { defer tests.PrepareTestEnv(t)() username := "user2" - session := loginUser(t, username) urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/revisions/Home", username, "repo1") From c1fdee2ab435f3cba726b076a4b9f38ca97ccfc5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 30 Nov 2022 20:17:04 +0800 Subject: [PATCH 3/4] Fix test --- tests/integration/api_httpsig_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/api_httpsig_test.go b/tests/integration/api_httpsig_test.go index 29d961a23d0df..881bb45ca497e 100644 --- a/tests/integration/api_httpsig_test.go +++ b/tests/integration/api_httpsig_test.go @@ -98,7 +98,7 @@ func TestHTTPSigCert(t *testing.T) { "type": "principal", }) - MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusSeeOther) pkcert, _, _, _, err := ssh.ParseAuthorizedKey([]byte(httpsigCertificate)) if err != nil { t.Fatal(err) From fcf0b92c92175b9d77026ee0504879694dd47ea6 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 30 Nov 2022 21:34:20 +0800 Subject: [PATCH 4/4] Fix test --- tests/integration/api_packages_container_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/api_packages_container_test.go b/tests/integration/api_packages_container_test.go index 1faf19a2d9bd9..851021da1b7cb 100644 --- a/tests/integration/api_packages_container_test.go +++ b/tests/integration/api_packages_container_test.go @@ -660,7 +660,7 @@ func TestPackageContainer(t *testing.T) { "email": "user2@example.com", "language": "en-US", }) - MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusSeeOther) t.Run(fmt.Sprintf("Catalog[%s]", newOwnerName), checkCatalog(newOwnerName)) @@ -670,6 +670,6 @@ func TestPackageContainer(t *testing.T) { "email": "user2@example.com", "language": "en-US", }) - MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusSeeOther) }) }