authentik.providers.saml.tests.test_logout_response_parser
logout response tests
1"""logout response tests""" 2 3import tracemalloc 4 5from django.test import SimpleTestCase 6 7from authentik.common.saml.exceptions import CannotHandleAssertion 8from authentik.common.saml.parsers.logout_response import LogoutResponseParser 9from authentik.providers.saml.utils.encoding import deflate_and_base64_encode 10 11 12class TestLogoutResponse(SimpleTestCase): 13 """Test LogoutResponse parser""" 14 15 def test_redirect_over_size_limit(self): 16 """Test that a redirect-binding response that inflates beyond the size limit is refused""" 17 response = deflate_and_base64_encode( 18 '<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ' 19 'ID="_1" Version="2.0" IssueInstant="2022-02-21T22:50:33.999Z"/>' 20 + " " * (32 * 1024 * 1024) 21 ) 22 23 tracemalloc.start() 24 self.addCleanup(tracemalloc.stop) 25 with self.assertRaises(CannotHandleAssertion): 26 LogoutResponseParser().parse_detached(response) 27 _, peak = tracemalloc.get_traced_memory() 28 29 self.assertLess(peak, 32 * 1024 * 1024)
class
TestLogoutResponse(django.test.testcases.SimpleTestCase):
13class TestLogoutResponse(SimpleTestCase): 14 """Test LogoutResponse parser""" 15 16 def test_redirect_over_size_limit(self): 17 """Test that a redirect-binding response that inflates beyond the size limit is refused""" 18 response = deflate_and_base64_encode( 19 '<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ' 20 'ID="_1" Version="2.0" IssueInstant="2022-02-21T22:50:33.999Z"/>' 21 + " " * (32 * 1024 * 1024) 22 ) 23 24 tracemalloc.start() 25 self.addCleanup(tracemalloc.stop) 26 with self.assertRaises(CannotHandleAssertion): 27 LogoutResponseParser().parse_detached(response) 28 _, peak = tracemalloc.get_traced_memory() 29 30 self.assertLess(peak, 32 * 1024 * 1024)
Test LogoutResponse parser
def
test_redirect_over_size_limit(self):
16 def test_redirect_over_size_limit(self): 17 """Test that a redirect-binding response that inflates beyond the size limit is refused""" 18 response = deflate_and_base64_encode( 19 '<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ' 20 'ID="_1" Version="2.0" IssueInstant="2022-02-21T22:50:33.999Z"/>' 21 + " " * (32 * 1024 * 1024) 22 ) 23 24 tracemalloc.start() 25 self.addCleanup(tracemalloc.stop) 26 with self.assertRaises(CannotHandleAssertion): 27 LogoutResponseParser().parse_detached(response) 28 _, peak = tracemalloc.get_traced_memory() 29 30 self.assertLess(peak, 32 * 1024 * 1024)
Test that a redirect-binding response that inflates beyond the size limit is refused