parent
04b235d094
commit
838db2f891
102 changed files with 1715 additions and 1523 deletions
|
@ -36,8 +36,8 @@ func testAPICreateOAuth2Application(t *testing.T) {
|
|||
ConfidentialClient: true,
|
||||
}
|
||||
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/applications/oauth2", &appBody)
|
||||
req = AddBasicAuthHeader(req, user.Name)
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/user/applications/oauth2", &appBody).
|
||||
AddBasicAuth(user.Name)
|
||||
resp := MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
var createdApp *api.OAuth2Application
|
||||
|
@ -66,8 +66,8 @@ func testAPIListOAuth2Applications(t *testing.T) {
|
|||
ConfidentialClient: true,
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2?token=%s", token)
|
||||
req := NewRequest(t, "GET", urlStr)
|
||||
req := NewRequest(t, "GET", "/api/v1/user/applications/oauth2").
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var appList api.OAuth2ApplicationList
|
||||
|
@ -93,14 +93,16 @@ func testAPIDeleteOAuth2Application(t *testing.T) {
|
|||
Name: "test-app-1",
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", oldApp.ID, token)
|
||||
req := NewRequest(t, "DELETE", urlStr)
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d", oldApp.ID)
|
||||
req := NewRequest(t, "DELETE", urlStr).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNoContent)
|
||||
|
||||
unittest.AssertNotExistsBean(t, &auth_model.OAuth2Application{UID: oldApp.UID, Name: oldApp.Name})
|
||||
|
||||
// Delete again will return not found
|
||||
req = NewRequest(t, "DELETE", urlStr)
|
||||
req = NewRequest(t, "DELETE", urlStr).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
|
@ -118,8 +120,8 @@ func testAPIGetOAuth2Application(t *testing.T) {
|
|||
ConfidentialClient: true,
|
||||
})
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d?token=%s", existApp.ID, token)
|
||||
req := NewRequest(t, "GET", urlStr)
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/applications/oauth2/%d", existApp.ID)).
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var app api.OAuth2Application
|
||||
|
@ -157,8 +159,8 @@ func testAPIUpdateOAuth2Application(t *testing.T) {
|
|||
}
|
||||
|
||||
urlStr := fmt.Sprintf("/api/v1/user/applications/oauth2/%d", existApp.ID)
|
||||
req := NewRequestWithJSON(t, "PATCH", urlStr, &appBody)
|
||||
req = AddBasicAuthHeader(req, user.Name)
|
||||
req := NewRequestWithJSON(t, "PATCH", urlStr, &appBody).
|
||||
AddBasicAuth(user.Name)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var app api.OAuth2Application
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue