summaryrefslogtreecommitdiffstats
path: root/tests/integration/api_repo_get_contents_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-02 11:39:42 +0800
committerGitHub <noreply@github.com>2022-12-01 22:39:42 -0500
commitdf676a47d05b20f7bfe4fdae350f50af15b52905 (patch)
treedc747e21fd2a533aeacb1686f747bba0a8f60736 /tests/integration/api_repo_get_contents_test.go
parent665d02efaf6ebaadf3ffb5b412ea77c4502f0baf (diff)
downloadgitea-df676a47d05b20f7bfe4fdae350f50af15b52905.tar.gz
gitea-df676a47d05b20f7bfe4fdae350f50af15b52905.zip
Remove session in api tests (#21984)
It's no meaning to request an API route with session.
Diffstat (limited to 'tests/integration/api_repo_get_contents_test.go')
-rw-r--r--tests/integration/api_repo_get_contents_test.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go
index ccbcfba486..f7d9c716aa 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"
@@ -92,7 +91,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 +102,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 +112,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 +124,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 +136,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 +145,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)
}