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

@ -35,14 +35,16 @@ func TestAPIUpdateUserAvatar(t *testing.T) {
Image: base64.StdEncoding.EncodeToString(avatar),
}
req := NewRequestWithJSON(t, "POST", "/api/v1/user/avatar?token="+token, &opts)
req := NewRequestWithJSON(t, "POST", "/api/v1/user/avatar", &opts).
AddTokenAuth(token)
MakeRequest(t, req, http.StatusNoContent)
opts = api.UpdateUserAvatarOption{
Image: "Invalid",
}
req = NewRequestWithJSON(t, "POST", "/api/v1/user/avatar?token="+token, &opts)
req = NewRequestWithJSON(t, "POST", "/api/v1/user/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 TestAPIUpdateUserAvatar(t *testing.T) {
Image: base64.StdEncoding.EncodeToString(text),
}
req = NewRequestWithJSON(t, "POST", "/api/v1/user/avatar?token="+token, &opts)
req = NewRequestWithJSON(t, "POST", "/api/v1/user/avatar", &opts).
AddTokenAuth(token)
MakeRequest(t, req, http.StatusInternalServerError)
}
@ -67,6 +70,7 @@ func TestAPIDeleteUserAvatar(t *testing.T) {
session := loginUser(t, normalUsername)
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteUser)
req := NewRequest(t, "DELETE", "/api/v1/user/avatar?token="+token)
req := NewRequest(t, "DELETE", "/api/v1/user/avatar").
AddTokenAuth(token)
MakeRequest(t, req, http.StatusNoContent)
}