mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 13:44:06 +01:00
Merge pull request 'test(oauth): coverage for the redirection of a denied grant' (#4026) from earl-warren/forgejo:wip-oauth into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4026 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
This commit is contained in:
commit
63f7a14883
2 changed files with 22 additions and 0 deletions
1
release-notes/8.0.0/fix/4026.md
Normal file
1
release-notes/8.0.0/fix/4026.md
Normal file
|
@ -0,0 +1 @@
|
|||
- when an OAuth grant request submitted to a Forgejo user is denied, the server from which the request originates is not notified that it has been denied
|
|
@ -608,3 +608,24 @@ func TestSignUpViaOAuthWithMissingFields(t *testing.T) {
|
|||
resp := MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Equal(t, test.RedirectURL(resp), "/user/link_account")
|
||||
}
|
||||
|
||||
func TestOAuth_GrantApplicationOAuth(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/login/oauth/authorize?client_id=da7da3ba-9a13-4167-856f-3899de0b0138&redirect_uri=a&response_type=code&state=thestate")
|
||||
ctx := loginUser(t, "user4")
|
||||
resp := ctx.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
htmlDoc.AssertElement(t, "#authorize-app", true)
|
||||
|
||||
req = NewRequestWithValues(t, "POST", "/login/oauth/grant", map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"client_id": "da7da3ba-9a13-4167-856f-3899de0b0138",
|
||||
"redirect_uri": "a",
|
||||
"state": "thestate",
|
||||
"granted": "false",
|
||||
})
|
||||
resp = ctx.MakeRequest(t, req, http.StatusSeeOther)
|
||||
assert.Contains(t, test.RedirectURL(resp), "error=access_denied&error_description=the+request+is+denied")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue