def test_delete(self): oqc = OutstandingQueriesCache({}) oqc.set('session_id', '/next') self.assertEqual(oqc.outstanding_queries(), {'session_id': '/next'}) oqc.delete('session_id') self.assertEqual(oqc.outstanding_queries(), {})
def parse_authn_response(saml_response): client = Saml2Client(current_app.saml2_config, identity_cache=IdentityCache(session)) oq_cache = OutstandingQueriesCache(session) outstanding_queries = oq_cache.outstanding_queries() try: # process the authentication response response = client.parse_authn_request_response(saml_response, BINDING_HTTP_POST, outstanding_queries) except SAMLError as e: current_app.logger.error('SAML response is not verified: {}'.format(e)) raise BadSAMLResponse(str(e)) except ParseError as e: current_app.logger.error('SAML response is not correctly formatted: {}'.format(e)) raise BadSAMLResponse('SAML response XML document could not be parsed: {}'.format(e)) if response is None: current_app.logger.error('SAML response is None') raise BadSAMLResponse( "SAML response has errors. Please check the logs") session_id = response.session_id() oq_cache.delete(session_id) return response
def test_outstanding_queries(self): oqc = OutstandingQueriesCache({}) oqc._db['user'] = '******' oqc._db.sync() self.assertEqual(oqc.outstanding_queries(), {'user': '******'})
def parse_authn_response(saml_response): client = Saml2Client(current_app.saml2_config, identity_cache=IdentityCache(session)) oq_cache = OutstandingQueriesCache(session) outstanding_queries = oq_cache.outstanding_queries() try: # process the authentication response response = client.parse_authn_request_response(saml_response, BINDING_HTTP_POST, outstanding_queries) except SAMLError as e: current_app.logger.error('SAML response is not verified: {}'.format(e)) raise BadSAMLResponse(str(e)) except ParseError as e: current_app.logger.error('SAML response is not correctly formatted: {}'.format(e)) raise BadSAMLResponse('SAML response XML document could not be parsed: {}'.format(e)) if response is None: current_app.logger.error('SAML response is None') raise BadSAMLResponse("SAML response has errors. Please check the logs") session_id = response.session_id() oq_cache.delete(session_id) return response