Skip to content

Commit 52f5439

Browse files
committed
Added some more tests
1 parent 2749128 commit 52f5439

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ In addition to the required settings data (idp, sp), there is extra information
320320

321321
// In some environment you will need to set how long the published metadata of the Service Provider gonna be valid.
322322
// is possible to not set the 2 following parameters (or set to null) and default values will be set (2 days, 1 week)
323-
// Provide the desire TimeStamp, for example 2015-06-26T20:00:00Z
323+
// Provide the desired Timestamp, for example 2015-06-26T20:00:00Z
324324
'metadataValidUntil': null,
325-
// Provide the desire Duration, for example PT518400S (6 days)
325+
// Provide the desired duration, for example PT518400S (6 days)
326326
'metadataCacheDuration': null
327327
},
328328

tests/src/OneLogin/saml2_tests/settings_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,23 @@ def testGetSPMetadataSigned(self):
371371
settings_info = self.loadSettingsJSON()
372372
if 'security' not in settings_info:
373373
settings_info['security'] = {}
374+
375+
# Use custom cert/key
376+
settings_info['security']['signMetadata'] = {
377+
"keyFileName": "sp.key",
378+
"certFileName": "sp.crt"
379+
}
380+
self.generateAndCheckMetadata(settings_info)
381+
382+
# Default cert/key
374383
settings_info['security']['signMetadata'] = True
375384
self.generateAndCheckMetadata(settings_info)
376385

386+
# Now try again with SP keys set directly from files that no exists:
387+
settings_info['custom_base_path'] = '../path/not/exists/'
388+
with self.assertRaises(OneLogin_Saml2_Error):
389+
OneLogin_Saml2_Settings(settings_info).get_sp_metadata()
390+
377391
# Now try again with SP keys set directly in settings and not from files:
378392
del settings_info['custom_base_path']
379393
# Now the keys should not be found, so metadata generation won't work:
@@ -384,6 +398,11 @@ def testGetSPMetadataSigned(self):
384398
settings_info['sp']['privateKey'] = self.file_contents(join(self.data_path, 'customPath', 'certs', 'sp.key'))
385399
self.generateAndCheckMetadata(settings_info)
386400

401+
# Now fails due no privateKey
402+
del settings_info['sp']['privateKey']
403+
with self.assertRaises(OneLogin_Saml2_Error):
404+
OneLogin_Saml2_Settings(settings_info).get_sp_metadata()
405+
387406
def generateAndCheckMetadata(self, settings):
388407
"""
389408
Helper method: Given some settings, generate metadata and validate it

0 commit comments

Comments
 (0)