Skip to content

Commit 44c78e1

Browse files
authored
chore(tests/flask): add comprehensive Flask integration tests and update mypy configuration (#602)
1 parent 12e7d37 commit 44c78e1

File tree

3 files changed

+576
-11
lines changed

3 files changed

+576
-11
lines changed

descope/flask/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from functools import wraps
66

7-
from flask import Response, _request_ctx_stack, redirect, request
7+
from flask import Response, redirect, request, g
88

99
from .. import (
1010
COOKIE_DATA_NAME,
@@ -143,7 +143,7 @@ def decorated(*args, **kwargs):
143143
return Response("Access denied", 401)
144144

145145
# Save the claims on the context execute the original API
146-
_request_ctx_stack.top.claims = jwt_response
146+
g.claims = jwt_response
147147
response = f(*args, **kwargs)
148148

149149
if jwt_response.get(COOKIE_DATA_NAME, None):
@@ -181,7 +181,7 @@ def decorated(*args, **kwargs):
181181
return Response("Unauthorized", 401)
182182

183183
# Save the claims on the context execute the original API
184-
_request_ctx_stack.top.claims = jwt_response
184+
g.claims = jwt_response
185185
response = f(*args, **kwargs)
186186

187187
set_cookie_on_response(
@@ -194,7 +194,6 @@ def decorated(*args, **kwargs):
194194
jwt_response[REFRESH_SESSION_TOKEN_NAME],
195195
jwt_response[COOKIE_DATA_NAME],
196196
)
197-
198197
return response
199198

200199
return decorated
@@ -224,7 +223,7 @@ def decorated(*args, **kwargs):
224223
return Response("Unauthorized", 401)
225224

226225
# Save the claims on the context execute the original API
227-
_request_ctx_stack.top.claims = jwt_response
226+
g.claims = jwt_response
228227
response = f(*args, **kwargs)
229228

230229
set_cookie_on_response(
@@ -267,7 +266,7 @@ def decorated(*args, **kwargs):
267266
return Response("Unauthorized", 401)
268267

269268
# Save the claims on the context execute the original API
270-
_request_ctx_stack.top.claims = jwt_response
269+
g.claims = jwt_response
271270
response = f(*args, **kwargs)
272271

273272
set_cookie_on_response(
@@ -310,7 +309,7 @@ def decorated(*args, **kwargs):
310309
return Response("Unauthorized", 401)
311310

312311
# Save the claims on the context execute the original API
313-
_request_ctx_stack.top.claims = jwt_response
312+
g.claims = jwt_response
314313
response = f(*args, **kwargs)
315314

316315
set_cookie_on_response(
@@ -400,7 +399,7 @@ def decorated(*args, **kwargs):
400399
return Response("Unauthorized", 401)
401400

402401
# Save the claims on the context execute the original API
403-
_request_ctx_stack.top.claims = jwt_response
402+
g.claims = jwt_response
404403
response = f(*args, **kwargs)
405404

406405
set_cookie_on_response(

0 commit comments

Comments
 (0)