1
0
Fork 0
forked from forgejo/forgejo

Convert to url auth to header auth in tests (#28484)

Related #28390
This commit is contained in:
KN4CK3R 2023-12-22 00:59:59 +01:00 committed by GitHub
parent 04b235d094
commit 838db2f891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
102 changed files with 1715 additions and 1523 deletions

View file

@ -6,7 +6,6 @@ package integration
import (
"bytes"
"encoding/base64"
"fmt"
"io"
"mime/multipart"
"net/http"
@ -119,14 +118,13 @@ func TestEmptyRepoAddFileByAPI(t *testing.T) {
session := loginUser(t, "user30")
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository)
url := fmt.Sprintf("/api/v1/repos/user30/empty/contents/new-file.txt?token=%s", token)
req := NewRequestWithJSON(t, "POST", url, &api.CreateFileOptions{
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user30/empty/contents/new-file.txt", &api.CreateFileOptions{
FileOptions: api.FileOptions{
NewBranchName: "new_branch",
Message: "init",
},
ContentBase64: base64.StdEncoding.EncodeToString([]byte("newly-added-api-file")),
})
}).AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusCreated)
var fileResponse api.FileResponse
@ -138,7 +136,8 @@ func TestEmptyRepoAddFileByAPI(t *testing.T) {
resp = session.MakeRequest(t, req, http.StatusOK)
assert.Contains(t, resp.Body.String(), "newly-added-api-file")
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/user30/empty?token=%s", token))
req = NewRequest(t, "GET", "/api/v1/repos/user30/empty").
AddTokenAuth(token)
resp = session.MakeRequest(t, req, http.StatusOK)
var apiRepo api.Repository
DecodeJSON(t, resp, &apiRepo)