File tree 4 files changed +6
-40
lines changed
4 files changed +6
-40
lines changed Original file line number Diff line number Diff line change @@ -352,8 +352,7 @@ class CallableRequest(_typing.Generic[_core.T]):
352
352
_C2 = _typing .Callable [[CallableRequest [_typing .Any ]], _typing .Any ]
353
353
354
354
355
- def _on_call_handler (func : _C2 ,
356
- request : Request ,
355
+ def _on_call_handler (func : _C2 , request : Request ,
357
356
enforce_app_check : bool ) -> Response :
358
357
try :
359
358
if not _util .valid_on_call_request (request ):
Original file line number Diff line number Diff line change @@ -211,7 +211,9 @@ def as_dict(self) -> dict:
211
211
}
212
212
213
213
214
- def _on_call_check_auth_token (request : _Request ) -> None | _typing .Literal [OnCallTokenState .INVALID ] | dict [str , _typing .Any ]:
214
+ def _on_call_check_auth_token (
215
+ request : _Request
216
+ ) -> None | _typing .Literal [OnCallTokenState .INVALID ] | dict [str , _typing .Any ]:
215
217
"""
216
218
Validates the auth token in a callable request.
217
219
If verify_token is False, the token will be decoded without verification.
Original file line number Diff line number Diff line change 32
32
_C1 = _typing .Callable [[Request ], Response ]
33
33
_C2 = _typing .Callable [[CallableRequest [_typing .Any ]], _typing .Any ]
34
34
35
- def _on_call_handler ( func : _C2 ,
36
- request : Request ) -> Response :
35
+
36
+ def _on_call_handler ( func : _C2 , request : Request ) -> Response :
37
37
try :
38
38
if not _util .valid_on_call_request (request ):
39
39
_logging .error ("Invalid request, unable to process." )
Original file line number Diff line number Diff line change @@ -71,41 +71,6 @@ def example(request: CallableRequest[object]) -> str:
71
71
'{"result":"Hello World"}\n ' ,
72
72
)
73
73
74
- def test_token_is_decoded (self ):
75
- """
76
- Test that the token is decoded instead of verifying auth first.
77
- """
78
- app = Flask (__name__ )
79
-
80
- @on_task_dispatched ()
81
- def example (request : CallableRequest [object ]) -> str :
82
- auth = request .auth
83
- # Make mypy happy
84
- if auth is None :
85
- self .fail ("Auth is None" )
86
- return "No Auth"
87
- self .assertEqual (auth .token ["sub" ], "firebase" )
88
- self .assertEqual (auth .token ["name" ], "John Doe" )
89
- return "Hello World"
90
-
91
- with app .test_request_context ("/" ):
92
- # pylint: disable=line-too-long
93
- test_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmaXJlYmFzZSIsIm5hbWUiOiJKb2huIERvZSJ9.74A24Y821E7CZx8aYCsCKo0Y-W0qXwqME-14QlEMcB0"
94
- environ = EnvironBuilder (
95
- method = "POST" ,
96
- headers = {
97
- "Authorization" : f"Bearer { test_token } "
98
- },
99
- json = {
100
- "data" : {
101
- "test" : "value"
102
- },
103
- },
104
- ).get_environ ()
105
- request = Request (environ )
106
- response = example (request )
107
- self .assertEqual (response .status_code , 200 )
108
-
109
74
def test_calls_init (self ):
110
75
hello = None
111
76
You can’t perform that action at this time.
0 commit comments