This repository was archived by the owner on Jun 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222from oidcop .exception import InvalidClient
2323from oidcop .exception import MultipleUsage
2424from oidcop .exception import NotForMe
25+ from oidcop .exception import ToOld
2526from oidcop .exception import UnknownClient
2627from oidcop .util import importer
2728
@@ -409,6 +410,8 @@ def verify_client(
409410 try :
410411 # get_client_id_from_token is a callback... Do not abuse for code readability.
411412 auth_info ["client_id" ] = get_client_id_from_token (endpoint_context , _token , request )
413+ except ToOld :
414+ raise ValueError ("Expired token" )
412415 except KeyError :
413416 raise ValueError ("Unknown token" )
414417
Original file line number Diff line number Diff line change @@ -381,6 +381,27 @@ def test_invalid_token(self):
381381 assert isinstance (args , ResponseMessage )
382382 assert args ["error_description" ] == "Invalid Token"
383383
384+ def test_expired_token (self , monkeypatch ):
385+ _auth_req = AUTH_REQ .copy ()
386+ _auth_req ["scope" ] = ["openid" , "research_and_scholarship" ]
387+
388+ session_id = self ._create_session (_auth_req )
389+ grant = self .session_manager [session_id ]
390+ access_token = self ._mint_token ("access_token" , grant , session_id )
391+
392+ http_info = {"headers" : {"authorization" : "Bearer {}" .format (access_token .value )}}
393+
394+ def mock ():
395+ return time_sans_frac () + access_token .expires_at + 1
396+
397+ monkeypatch .setattr ("oidcop.token.time_sans_frac" , mock )
398+
399+ _req = self .endpoint .parse_request ({}, http_info = http_info )
400+
401+ assert _req .to_dict () == {
402+ "error" : "invalid_token" , "error_description" : "Expired token"
403+ }
404+
384405 def test_userinfo_claims (self ):
385406 _acr = "https://refeds.org/profile/mfa"
386407 _auth_req = AUTH_REQ .copy ()
You can’t perform that action at this time.
0 commit comments