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

@ -34,7 +34,8 @@ func TestAPIUpdateOrgAvatar(t *testing.T) {
Image: base64.StdEncoding.EncodeToString(avatar),
}
req := NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar?token="+token, &opts)
req := NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar", &opts).
AddTokenAuth(token)
MakeRequest(t, req, http.StatusNoContent)
// Test what happens if you don't have a valid Base64 string
@ -42,7 +43,8 @@ func TestAPIUpdateOrgAvatar(t *testing.T) {
Image: "Invalid",
}
req = NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar?token="+token, &opts)
req = NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar", &opts).
AddTokenAuth(token)
MakeRequest(t, req, http.StatusBadRequest)
// Test what happens if you use a file that is not an image
@ -56,7 +58,8 @@ func TestAPIUpdateOrgAvatar(t *testing.T) {
Image: base64.StdEncoding.EncodeToString(text),
}
req = NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar?token="+token, &opts)
req = NewRequestWithJSON(t, "POST", "/api/v1/orgs/org3/avatar", &opts).
AddTokenAuth(token)
MakeRequest(t, req, http.StatusInternalServerError)
}
@ -67,6 +70,7 @@ func TestAPIDeleteOrgAvatar(t *testing.T) {
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization)
req := NewRequest(t, "DELETE", "/api/v1/orgs/org3/avatar?token="+token)
req := NewRequest(t, "DELETE", "/api/v1/orgs/org3/avatar").
AddTokenAuth(token)
MakeRequest(t, req, http.StatusNoContent)
}