コード例 #1
0
 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)
コード例 #2
0
    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
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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()
コード例 #6
0
 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())
コード例 #7
0
 def test_check_access_works(self):
     mixin = IdPHandlerViewMixin()
     mixin.set_sp('test_generic_sp')
     mixin.set_processor()
     mixin.check_access(HttpRequest())