|
14 | 14 |
|
15 | 15 | from onelogin.saml2.metadata import OneLogin_Saml2_Metadata |
16 | 16 | from onelogin.saml2.settings import OneLogin_Saml2_Settings |
| 17 | +from onelogin.saml2.constants import OneLogin_Saml2_Constants |
17 | 18 |
|
18 | 19 |
|
19 | 20 | class OneLogin_Saml2_Metadata_Test(unittest.TestCase): |
@@ -222,12 +223,32 @@ def testSignMetadata(self): |
222 | 223 |
|
223 | 224 | self.assertIn('<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>', signed_metadata) |
224 | 225 | self.assertIn('<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>', signed_metadata) |
| 226 | + self.assertIn('<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>', signed_metadata) |
225 | 227 | self.assertIn('<ds:Reference', signed_metadata) |
226 | 228 | self.assertIn('<ds:KeyInfo><ds:X509Data>\n<ds:X509Certificate>', signed_metadata) |
227 | 229 |
|
228 | 230 | with self.assertRaisesRegexp(Exception, 'Empty string supplied as input'): |
229 | 231 | OneLogin_Saml2_Metadata.sign_metadata('', key, cert) |
230 | 232 |
|
| 233 | + signed_metadata_2 = OneLogin_Saml2_Metadata.sign_metadata(metadata, key, cert, OneLogin_Saml2_Constants.RSA_SHA256, OneLogin_Saml2_Constants.SHA384) |
| 234 | + self.assertIn('<md:SPSSODescriptor', signed_metadata_2) |
| 235 | + self.assertIn('entityID="http://stuff.com/endpoints/metadata.php"', signed_metadata_2) |
| 236 | + self.assertIn('AuthnRequestsSigned="false"', signed_metadata_2) |
| 237 | + self.assertIn('WantAssertionsSigned="false"', signed_metadata_2) |
| 238 | + |
| 239 | + self.assertIn('<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"', signed_metadata_2) |
| 240 | + self.assertIn('Location="http://stuff.com/endpoints/endpoints/acs.php"', signed_metadata_2) |
| 241 | + self.assertIn('<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"', signed_metadata_2) |
| 242 | + self.assertIn(' Location="http://stuff.com/endpoints/endpoints/sls.php"/>', signed_metadata_2) |
| 243 | + |
| 244 | + self.assertIn('<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>', signed_metadata_2) |
| 245 | + |
| 246 | + self.assertIn('<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>', signed_metadata_2) |
| 247 | + self.assertIn('<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#sha384"/>', signed_metadata_2) |
| 248 | + self.assertIn('<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>', signed_metadata_2) |
| 249 | + self.assertIn('<ds:Reference', signed_metadata_2) |
| 250 | + self.assertIn('<ds:KeyInfo><ds:X509Data>\n<ds:X509Certificate>', signed_metadata_2) |
| 251 | + |
231 | 252 | def testAddX509KeyDescriptors(self): |
232 | 253 | """ |
233 | 254 | Tests the addX509KeyDescriptors method of the OneLogin_Saml2_Metadata |
|
0 commit comments