MCPcopy
hub / github.com/authlib/authlib / test_pure_code_flow

Function test_pure_code_flow

tests/flask/test_oauth2/test_openid_code_grant.py:127–160  ·  view source on GitHub ↗
(test_client, server)

Source from the content-addressed store, hash-verified

125
126
127def test_pure_code_flow(test_client, server):
128 register_oidc_code_grant(
129 server,
130 )
131 rv = test_client.post(
132 "/oauth/authorize",
133 data={
134 "response_type": "code",
135 "client_id": "client-id",
136 "state": "bar",
137 "scope": "profile",
138 "redirect_uri": "https://client.test",
139 "user_id": "1",
140 },
141 )
142 assert "code=" in rv.location
143
144 params = dict(url_decode(urlparse.urlparse(rv.location).query))
145 assert params["state"] == "bar"
146
147 code = params["code"]
148 headers = create_basic_header("client-id", "client-secret")
149 rv = test_client.post(
150 "/oauth/token",
151 data={
152 "grant_type": "authorization_code",
153 "redirect_uri": "https://client.test",
154 "code": code,
155 },
156 headers=headers,
157 )
158 resp = json.loads(rv.data)
159 assert "access_token" in resp
160 assert "id_token" not in resp
161
162
163def test_require_nonce(test_client, server):

Callers

nothing calls this directly

Calls 4

url_decodeFunction · 0.90
register_oidc_code_grantFunction · 0.85
create_basic_headerFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…