Skip to content

Commit 2226201

Browse files
author
Rahul Raina
committed
Adding tests and new settings file
1 parent 0c4f846 commit 2226201

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

tests/settings/settings9.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"strict": false,
3+
"debug": false,
4+
"custom_base_path": "../../../tests/data/customPath/",
5+
"sp": {
6+
"entityId": "http://stuff.com/endpoints/metadata.php",
7+
"assertionConsumerService": {
8+
"url": "http://stuff.com/endpoints/endpoints/acs.php"
9+
},
10+
"singleLogoutService": {
11+
"url": "http://stuff.com/endpoints/endpoints/sls.php"
12+
},
13+
"NameIDFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
14+
},
15+
"idp": {
16+
"entityId": "http://idp.example.com/",
17+
"singleSignOnService": {
18+
"url": "http://idp.example.com/SSOService.php"
19+
},
20+
"singleLogoutService": {
21+
"url": "http://idp.example.com/SingleLogoutService.php"
22+
}
23+
},
24+
"security": {
25+
"authnRequestsSigned": false,
26+
"wantAssertionsSigned": false,
27+
"signMetadata": false
28+
},
29+
"contactPerson": {
30+
"technical": {
31+
"givenName": "technical_name",
32+
"emailAddress": "technical@example.com"
33+
},
34+
"support": {
35+
"givenName": "support_name",
36+
"emailAddress": "support@example.com"
37+
}
38+
},
39+
"organization": {
40+
"en-US": {
41+
"name": "sp_test",
42+
"displayname": "SP test",
43+
"url": "http://sp.example.com"
44+
}
45+
}
46+
}

tests/src/OneLogin/saml2_tests/settings_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,28 @@ def testGetSPKey(self):
222222
settings_3 = OneLogin_Saml2_Settings(settings_data, custom_base_path=custom_base_path)
223223
self.assertIsNone(settings_3.get_sp_key())
224224

225+
def testGetIDPCert(self):
226+
"""
227+
Tests the get_idp_cert method of the OneLogin_Saml2_Settings
228+
"""
229+
230+
settings = OneLogin_Saml2_Settings(self.loadSettingsJSON('settings9.json'))
231+
cert = "-----BEGIN CERTIFICATE-----\nMIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMC\nTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYD\nVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG\n9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4\nMTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xi\nZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2Zl\naWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5v\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LO\nNoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHIS\nKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d\n1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8\nBUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7n\nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2Qar\nQ4/67OZfHd7R+POBXhophSMv1ZOo\n-----END CERTIFICATE-----\n"
232+
self.assertEqual(cert, settings.get_idp_cert())
233+
234+
settings_data = self.loadSettingsJSON()
235+
236+
settings = OneLogin_Saml2_Settings(settings_data)
237+
settings_data['idp']['x509cert'] = cert
238+
self.assertEqual(cert, settings.get_sp_cert())
239+
240+
del settings_data['idp']['x509cert']
241+
del settings_data['custom_base_path']
242+
custom_base_path = dirname(__file__)
243+
244+
settings_3 = OneLogin_Saml2_Settings(settings_data, custom_base_path=custom_base_path)
245+
self.assertIsNone(settings_3.get_idp_cert())
246+
225247
def testFormatIdPCert(self):
226248
"""
227249
Tests the format_idp_cert method of the OneLogin_Saml2_Settings

0 commit comments

Comments
 (0)