@@ -34,7 +34,7 @@ def setUp(self):
3434 def get_app_with_middleware (self , config ):
3535 return ASAPMiddleware (app , config )
3636
37- def send_request (self , url = '/' , config = None , token = None ):
37+ def send_request (self , url = '/' , config = None , token = None , application = None ):
3838 """ returns the response of sending a request containing the given
3939 token sent in the Authorization header.
4040 """
@@ -48,9 +48,9 @@ def start_response(status, response_headers, exc_info=None):
4848 environ = {}
4949 if token :
5050 environ ['HTTP_AUTHORIZATION' ] = b'Bearer ' + token
51-
52- app = self .get_app_with_middleware (config or self .config )
53- return app (environ , start_response ), resp_info , environ
51+ if application is None :
52+ application = self .get_app_with_middleware (config or self .config )
53+ return application (environ , start_response ), resp_info , environ
5454
5555 def test_request_with_valid_token_is_allowed (self ):
5656 token = create_token (
@@ -61,6 +61,19 @@ def test_request_with_valid_token_is_allowed(self):
6161 self .assertEqual (resp_info ['status' ], '200 OK' )
6262 self .assertIn ('ATL_ASAP_CLAIMS' , environ )
6363
64+ def test_request_with_duplicate_jti_is_rejected (self ):
65+ token = create_token (
66+ 'client-app' , 'server-app' ,
67+ 'client-app/key01' , self ._private_key_pem
68+ )
69+ application = self .get_app_with_middleware (self .config )
70+ body , resp_info , environ = self .send_request (
71+ token = token , application = application )
72+ self .assertEqual (resp_info ['status' ], '200 OK' )
73+ body , resp_info , environ = self .send_request (
74+ token = token , application = application )
75+ self .assertEqual (resp_info ['status' ], '401 Unauthorized' )
76+
6477 def test_request_with_invalid_audience_is_rejected (self ):
6578 token = create_token (
6679 'client-app' , 'invalid-audience' ,
0 commit comments