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

@ -31,7 +31,8 @@ func TestAPIUserInfo(t *testing.T) {
t.Run("GetInfo", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s?token=%s", user2, token))
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s", user2)).
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var u api.User
@ -48,7 +49,8 @@ func TestAPIUserInfo(t *testing.T) {
assert.Equal(t, org3.GetPlaceholderEmail(), u.Email)
// Test if the correct Mail is returned if a User is logged in
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s?token=%s", org3.Name, token))
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s", org3.Name)).
AddTokenAuth(token)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &u)
assert.Equal(t, org3.GetEmail(), u.Email)
@ -57,7 +59,8 @@ func TestAPIUserInfo(t *testing.T) {
t.Run("GetAuthenticatedUser", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user?token=%s", token))
req := NewRequest(t, "GET", "/api/v1/user").
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var u api.User