MCPcopy
hub / github.com/ory/hydra / checkAndAcceptConsentHandler

Function checkAndAcceptConsentHandler

consent/strategy_default_test.go:63–76  ·  view source on GitHub ↗
(t *testing.T, apiClient *hydra.APIClient, cb func(*testing.T, *hydra.OAuth2ConsentRequest, error) hydra.AcceptOAuth2ConsentRequest)

Source from the content-addressed store, hash-verified

61}
62
63func checkAndAcceptConsentHandler(t *testing.T, apiClient *hydra.APIClient, cb func(*testing.T, *hydra.OAuth2ConsentRequest, error) hydra.AcceptOAuth2ConsentRequest) http.HandlerFunc {
64 return func(w http.ResponseWriter, r *http.Request) {
65 res, _, err := apiClient.OAuth2API.GetOAuth2ConsentRequest(context.Background()).ConsentChallenge(r.URL.Query().Get("consent_challenge")).Execute()
66 payload := cb(t, res, err)
67
68 v, _, err := apiClient.OAuth2API.AcceptOAuth2ConsentRequest(context.Background()).
69 ConsentChallenge(res.Challenge).
70 AcceptOAuth2ConsentRequest(payload).
71 Execute()
72 require.NoError(t, err)
73 require.NotEmpty(t, v.RedirectTo)
74 http.Redirect(w, r, v.RedirectTo, http.StatusFound)
75 }
76}
77
78func makeOAuth2Request(t *testing.T, reg *driver.RegistrySQL, hc *http.Client, oc *client.Client, values url.Values) (gjson.Result, *http.Response) {
79 ctx := context.Background()

Callers 3

TestLogoutFlowsFunction · 0.85

Calls 5

GetMethod · 0.65
ExecuteMethod · 0.45
ConsentChallengeMethod · 0.45

Tested by

no test coverage detected