def test_parse_authentication_response_preserves_id_token_jwt(self):
     facade = PyoidcFacade(
         ProviderConfiguration(provider_metadata=self.PROVIDER_METADATA,
                               client_metadata=self.CLIENT_METADATA),
         REDIRECT_URI)
     state = 'state-1234'
     now = int(time.time())
     id_token, id_token_signing_key = signed_id_token({
         'iss':
         self.PROVIDER_METADATA['issuer'],
         'sub':
         'test_sub',
         'aud':
         'client1',
         'exp':
         now + 1,
         'iat':
         now
     })
     responses.add(responses.GET,
                   self.PROVIDER_METADATA['jwks_uri'],
                   json={'keys': [id_token_signing_key.serialize()]})
     auth_response = AuthorizationResponse(**{
         'state': state,
         'id_token': id_token
     })
     parsed_auth_response = facade.parse_authentication_response(
         auth_response)
     assert isinstance(parsed_auth_response, AuthorizationResponse)
     assert parsed_auth_response['state'] == state
     assert parsed_auth_response['id_token_jwt'] == id_token
 def test_parse_authentication_response_handles_error_response(self):
     facade = PyoidcFacade(ProviderConfiguration(provider_metadata=self.PROVIDER_METADATA,
                                                 client_metadata=self.CLIENT_METADATA),
                           self.REDIRECT_URI)
     error_response = AuthorizationErrorResponse(**{'error': 'invalid_request', 'state': 'state-1234'})
     parsed_auth_response = facade.parse_authentication_response(error_response)
     assert isinstance(parsed_auth_response, AuthorizationErrorResponse)
     assert parsed_auth_response.to_dict() == error_response.to_dict()
 def test_parse_authentication_response(self):
     facade = PyoidcFacade(ProviderConfiguration(provider_metadata=self.PROVIDER_METADATA,
                                                 client_metadata=self.CLIENT_METADATA),
                           self.REDIRECT_URI)
     auth_code = 'auth_code-1234'
     state = 'state-1234'
     auth_response = AuthorizationResponse(**{'state': state, 'code': auth_code})
     parsed_auth_response = facade.parse_authentication_response(auth_response.to_dict())
     assert isinstance(parsed_auth_response, AuthorizationResponse)
     assert parsed_auth_response.to_dict() == auth_response.to_dict()
Esempio n. 4
0
 def test_parse_authentication_response_preserves_id_token_jwt(self):
     facade = PyoidcFacade(
         ProviderConfiguration(
             provider_metadata=self.PROVIDER_METADATA,
             client_metadata=self.CLIENT_METADATA,
         ),
         self.REDIRECT_URI,
     )
     state = "state-1234"
     now = int(time.time())
     id_token, id_token_signing_key = signed_id_token({
         "iss":
         self.PROVIDER_METADATA["issuer"],
         "sub":
         "test_sub",
         "aud":
         "client1",
         "exp":
         now + 1,
         "iat":
         now,
     })
     responses.add(
         responses.GET,
         self.PROVIDER_METADATA["jwks_uri"],
         json={"keys": [id_token_signing_key.serialize()]},
     )
     auth_response = AuthorizationResponse(**{
         "state": state,
         "id_token": id_token
     })
     parsed_auth_response = facade.parse_authentication_response(
         auth_response)
     assert isinstance(parsed_auth_response, AuthorizationResponse)
     assert parsed_auth_response["state"] == state
     assert parsed_auth_response["id_token_jwt"] == id_token