def test_custom_conf_loader_from_view(self): config_loader_path = 'djangosaml2.tests.test_config_loader_with_real_conf' request = RequestFactory().get('/login/') request.user = AnonymousUser() request.session = {} response = views.login(request, config_loader_path) self.assertEquals(response.status_code, 302) location = response['Location'] url = urlparse.urlparse(location) self.assertEquals(url.hostname, 'idp.example.com') self.assertEquals(url.path, '/simplesaml/saml2/idp/SSOService.php')
def test_custom_conf_loader_from_view(self): config_loader_path = 'djangosaml2.tests.test_config_loader_with_real_conf' request = RequestFactory().get('/login/') request.user = AnonymousUser() middleware = SamlSessionMiddleware() middleware.process_request(request) saml_session_name = getattr(settings, 'SAML_SESSION_COOKIE_NAME', 'saml_session') getattr(request, saml_session_name).save() response = views.login(request, config_loader_path) self.assertEqual(response.status_code, 302) location = response['Location'] url = urlparse(location) self.assertEqual(url.hostname, 'idp.example.com') self.assertEqual(url.path, '/simplesaml/saml2/idp/SSOService.php')