Example #1
0
    def test_doesnt_work_if_samlrequest_not_in_params(self):
        request = HttpRequest()
        request.method = 'GET'
        request.session = {}

        with pytest.raises(ValidationError):
            store_params_in_session(request)
Example #2
0
 def test_works_correctly_with_get(self):
     store_params_in_session(sample_get_request)
     expected_session = {
         'Binding': BINDING_HTTP_REDIRECT,
         'SAMLRequest': encode_saml(expected_result),
         'RelayState': 'Test Relay State'
     }
     assert all(item in sample_get_request.session.items()
                for item in expected_session.items())
Example #3
0
 def test_works_correctly_with_post(self):
     request = HttpRequest()
     request.method = 'POST'
     request.session = {}
     request.POST = {
         'SAMLRequest': encode_saml(expected_result),
         'RelayState': 'Test Relay State'
     }
     store_params_in_session(request)
     expected_session = {
         'Binding': BINDING_HTTP_POST,
         'SAMLRequest': encode_saml(expected_result),
         'RelayState': 'Test Relay State'
     }
     assert all(item in request.session.items()
                for item in expected_session.items())