def test_build_authn_response(self): mixin = IdPHandlerViewMixin() try: mixin.dispatch(HttpRequest()) except AttributeError: mixin.set_sp('test_generic_sp') mixin.set_processor() user = User() authn = mixin.get_authn() resp_args = { "in_response_to": "SP_Initiated_Login", "destination": "https://sp.example.com/SAML2", } assert isinstance( mixin.build_authn_response(user, authn, resp_args), Response)
def compile_data_for_render_response(self): mixin = IdPHandlerViewMixin() mixin.set_sp("test_generic_sp") mixin.set_processor() user = User.objects.create() user.email = "*****@*****.**", user.first_name = 'First Name', user.last_name = 'Last Name', user.is_staff = True user.is_superuser = False request = HttpRequest() request.user = user request.session = {} html_response = {"type": "POST", "data": "<html></html>"} return mixin, request, html_response
def test_get_processor_loads_custom_processor(self): mixin = IdPHandlerViewMixin() mixin.set_sp('test_sp_with_custom_processor') mixin.set_processor() assert isinstance(mixin.processor, CustomProcessor)
def test_set_processor_defaults_to_base_processor(self): mixin = IdPHandlerViewMixin() mixin.set_sp('test_sp_with_no_processor') mixin.set_processor() assert isinstance(mixin.processor, BaseProcessor)
def test_set_processor_errors_if_processor_cannot_be_loaded(self): mixin = IdPHandlerViewMixin() mixin.set_sp('test_sp_with_bad_processor') with pytest.raises(Exception): mixin.set_processor()
def test_check_access_fails_when_it_should(self): mixin = IdPHandlerViewMixin() mixin.set_sp('test_sp_with_custom_processor_that_doesnt_allow_access') mixin.set_processor() with pytest.raises(PermissionDenied): mixin.check_access(HttpRequest())
def test_check_access_works(self): mixin = IdPHandlerViewMixin() mixin.set_sp('test_generic_sp') mixin.set_processor() mixin.check_access(HttpRequest())