|
11 | 11 | from zlib import decompress |
12 | 12 |
|
13 | 13 | from onelogin.saml2.authn_request import OneLogin_Saml2_Authn_Request |
| 14 | +from onelogin.saml2.constants import OneLogin_Saml2_Constants |
14 | 15 | from onelogin.saml2.settings import OneLogin_Saml2_Settings |
15 | 16 | from onelogin.saml2.utils import OneLogin_Saml2_Utils |
16 | 17 |
|
@@ -61,6 +62,31 @@ def testCreateRequest(self): |
61 | 62 | self.assertRegexpMatches(inflated, '^<samlp:AuthnRequest') |
62 | 63 | self.assertNotIn('ProviderName="SP test"', inflated) |
63 | 64 |
|
| 65 | + def testCreateRequestAuthContext(self): |
| 66 | + """ |
| 67 | + Tests the OneLogin_Saml2_Authn_Request Constructor. |
| 68 | + The creation of a deflated SAML Request with defined AuthContext |
| 69 | + """ |
| 70 | + saml_settings = self.loadSettingsJSON() |
| 71 | + settings = OneLogin_Saml2_Settings(saml_settings) |
| 72 | + authn_request = OneLogin_Saml2_Authn_Request(settings) |
| 73 | + authn_request_encoded = authn_request.get_request() |
| 74 | + decoded = b64decode(authn_request_encoded) |
| 75 | + inflated = decompress(decoded, -15) |
| 76 | + self.assertRegexpMatches(inflated, '^<samlp:AuthnRequest') |
| 77 | + self.assertIn(OneLogin_Saml2_Constants.AC_PASSWORD, inflated) |
| 78 | + self.assertNotIn(OneLogin_Saml2_Constants.AC_X509, inflated) |
| 79 | + |
| 80 | + saml_settings['sp']['AuthnContextClassRef'] = OneLogin_Saml2_Constants.AC_X509 |
| 81 | + settings = OneLogin_Saml2_Settings(saml_settings) |
| 82 | + authn_request = OneLogin_Saml2_Authn_Request(settings) |
| 83 | + authn_request_encoded = authn_request.get_request() |
| 84 | + decoded = b64decode(authn_request_encoded) |
| 85 | + inflated = decompress(decoded, -15) |
| 86 | + self.assertRegexpMatches(inflated, '^<samlp:AuthnRequest') |
| 87 | + self.assertNotIn(OneLogin_Saml2_Constants.AC_PASSWORD, inflated) |
| 88 | + self.assertIn(OneLogin_Saml2_Constants.AC_X509, inflated) |
| 89 | + |
64 | 90 | def testCreateDeflatedSAMLRequestURLParameter(self): |
65 | 91 | """ |
66 | 92 | Tests the OneLogin_Saml2_Authn_Request Constructor. |
|
0 commit comments