forked from forgejo/forgejo
parent
04b235d094
commit
838db2f891
102 changed files with 1715 additions and 1523 deletions
|
@ -21,7 +21,8 @@ func TestAPIListEmails(t *testing.T) {
|
|||
session := loginUser(t, normalUsername)
|
||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadUser)
|
||||
|
||||
req := NewRequest(t, "GET", "/api/v1/user/emails?token="+token)
|
||||
req := NewRequest(t, "GET", "/api/v1/user/emails").
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var emails []*api.Email
|
||||
|
@ -52,13 +53,15 @@ func TestAPIAddEmail(t *testing.T) {
|
|||
Emails: []string{"user101@example.com"},
|
||||
}
|
||||
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/emails", &opts).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
|
||||
opts = api.CreateEmailOption{
|
||||
Emails: []string{"user2-3@example.com"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails", &opts).
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
var emails []*api.Email
|
||||
|
@ -74,7 +77,8 @@ func TestAPIAddEmail(t *testing.T) {
|
|||
opts = api.CreateEmailOption{
|
||||
Emails: []string{"notAEmail"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails", &opts).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
}
|
||||
|
||||
|
@ -88,16 +92,19 @@ func TestAPIDeleteEmail(t *testing.T) {
|
|||
opts := api.DeleteEmailOption{
|
||||
Emails: []string{"user2-3@example.com"},
|
||||
}
|
||||
req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
|
||||
req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails", &opts).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
opts = api.DeleteEmailOption{
|
||||
Emails: []string{"user2-2@example.com"},
|
||||
}
|
||||
req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
|
||||
req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails", &opts).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNoContent)
|
||||
|
||||
req = NewRequest(t, "GET", "/api/v1/user/emails?token="+token)
|
||||
req = NewRequest(t, "GET", "/api/v1/user/emails").
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var emails []*api.Email
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue