-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test cases with schema validation tests
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
- Loading branch information
1 parent
63fca12
commit 0b7d7c0
Showing
12 changed files
with
191 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:xs="http://www.w3.org/2001/XMLSchema" Destination="https://eidas-connector.at/post" ID="_5a15625de8618920748123042db52367" InResponseTo="_171ccc6b39b1e8f6e762c2e4ee4ded3a" IssueInstant="2015-04-30T19:27:20.159Z" Version="2.0"> | ||
<saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://eidas-service.eu</saml2:Issuer> | ||
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:SignedInfo> | ||
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> | ||
<ds:SignatureMethod Algorithm="http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1"/> | ||
<ds:Reference URI="#_5a15625de8618920748123042db52367"> | ||
<ds:Transforms> | ||
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> | ||
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> | ||
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="xs"/> | ||
</ds:Transform> | ||
</ds:Transforms> | ||
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> | ||
<ds:DigestValue>t5V4hqAh4Nxjd49H/rC+N9tN/dNHBNuCOco1v1GYfFc=</ds:DigestValue> | ||
</ds:Reference> | ||
</ds:SignedInfo> | ||
<ds:SignatureValue>fQ==</ds:SignatureValue> | ||
<ds:KeyInfo> | ||
<ds:X509Data> | ||
<ds:X509Certificate>fQ==</ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</ds:Signature> | ||
<saml2p:Status> | ||
<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> | ||
</saml2p:Status> | ||
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eidas="http://eidas.europa.eu/attributes/naturalperson" ID="_47482789069732322d02d825c9a2fafa" IssueInstant="2015-04-30T19:27:20.159Z" Version="2.0"> | ||
<saml2:Issuer Format="urn:oasis:names:tc:saml2:2.0:nameid-format:entity">https://eidas-service.eu</saml2:Issuer> | ||
<saml2:Subject> | ||
<saml2:NameID Format="urn:oasis:names:tc:saml2:2.0:nameid-format:persistent">ES/AT/02635542Y</saml2:NameID> | ||
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:saml2:2.0:cm:bearer"> | ||
<saml2:SubjectConfirmationData InResponseTo="_171ccc6b39b1e8f6e762c2e4ee4ded3a" NotOnOrAfter="2015-04-30T19:32:20.157Z" Recipient="https://eidas-connector.eu/post"/> | ||
</saml2:SubjectConfirmation> | ||
</saml2:Subject> | ||
<saml2:Conditions NotBefore="2015-04-30T19:27:20.159Z" NotOnOrAfter="2015-04-30T19:32:20.157Z"> | ||
<saml2:AudienceRestriction> | ||
<saml2:Audience>https://eidas-connector.eu/post</saml2:Audience> | ||
</saml2:AudienceRestriction> | ||
</saml2:Conditions> | ||
<saml2:AuthnStatement AuthnInstant="2015-04-30T19:27:20.159Z" SessionIndex="_5eeb319253e2d7d125e3dcc72806209a"> | ||
<saml2:AuthnContext> | ||
<saml2:AuthnContextClassRef>http://eidas.europa.eu/LoA/high</saml2:AuthnContextClassRef> | ||
</saml2:AuthnContext> | ||
</saml2:AuthnStatement> | ||
<saml2:AttributeStatement> | ||
<saml2:Attribute FriendlyName="PersonIdentifier" Name="http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier" NameFormat="urn:oasis:names:tc:saml2:2.0:attrname-format:uri"> | ||
<saml2:AttributeValue xsi:type="eidas:PersonIdentifierType">ES/AT/02635542Y</saml2:AttributeValue> | ||
</saml2:Attribute> | ||
<saml2:Attribute FriendlyName="FamilyName" Name="http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> | ||
<saml2:AttributeValue xsi:type="eidas:CurrentFamilyNameType">Onasis</saml2:AttributeValue> | ||
<saml2:AttributeValue eidas:LatinScript="false" xsi:type="eidas:CurrentFamilyNameType">Ωνάσης</saml2:AttributeValue> | ||
</saml2:Attribute> | ||
<saml2:Attribute FriendlyName="FirstName" Name="http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName" NameFormat="urn:oasis:names:tc:saml2:2.0:attrname-format:uri"> | ||
<saml2:AttributeValue xsi:type="eidas:CurrentGivenNameType">Sarah</saml2:AttributeValue> | ||
</saml2:Attribute> | ||
<saml2:Attribute FriendlyName="DateOfBirth" Name="http://eidas.europa.eu/attributes/naturalperson/DateOfBirth" NameFormat="urn:oasis:names:tc:saml2:2.0:attrname-format:uri"> | ||
<saml2:AttributeValue xsi:type="eidas:DateOfBirthType">1970-05-28</saml2:AttributeValue> | ||
</saml2:Attribute> | ||
</saml2:AttributeStatement> | ||
</saml2:Assertion> | ||
</saml2p:Response> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
this content is invalid | ||
<root>this content is invalid for a metadata file</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from pathutils import full_path as expand_full_path | ||
|
||
from pytest import raises | ||
from pytest import mark | ||
|
||
from saml2.xml.schema import validate as validate_doc_with_schema | ||
from saml2.xml.schema import XMLSchemaError | ||
|
||
|
||
@mark.parametrize("doc", ["invalid_metadata_file.xml", "empty_metadata_file.xml"]) | ||
def test_invalid_saml_metadata_doc(doc): | ||
with raises(XMLSchemaError): | ||
validate_doc_with_schema(expand_full_path(doc)) | ||
|
||
|
||
@mark.parametrize( | ||
"doc", | ||
[ | ||
"InCommon-metadata.xml", | ||
"idp.xml", | ||
"idp_2.xml", | ||
"idp_aa.xml", | ||
"idp_all.xml", | ||
"idp_example.xml", | ||
"idp_soap.xml", | ||
"entity_cat_re.xml", | ||
"entity_cat_re_nren.xml", | ||
"entity_cat_rs.xml", | ||
"entity_cat_sfs_hei.xml", | ||
"entity_esi_and_coco_sp.xml", | ||
"entity_no_friendly_name_sp.xml", | ||
"extended.xml", | ||
"idp_slo_redirect.xml", | ||
"idp_uiinfo.xml", | ||
"metadata.aaitest.xml", | ||
"metadata.xml", | ||
"metadata_cert.xml", | ||
"metadata_example.xml", | ||
"metadata_sp_1.xml", | ||
"metadata_sp_1_no_encryption.xml", | ||
"metadata_sp_2.xml", | ||
"metasp.xml", | ||
"pdp_meta.xml", | ||
"servera.xml", | ||
"sp.xml", | ||
"sp_slo_redirect.xml", | ||
# XXX "swamid-1.0.xml", | ||
# XXX "swamid-2.0.xml", | ||
# TODO include the fed namespace | ||
# TODO see https://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html | ||
"urn-mace-swami.se-swamid-test-1.0-metadata.xml", | ||
"uu.xml", | ||
"vo_metadata.xml", | ||
], | ||
) | ||
def test_valid_saml_metadata_doc(doc): | ||
result = validate_doc_with_schema(expand_full_path(doc)) | ||
assert result == None | ||
|
||
|
||
@mark.parametrize( | ||
"doc", | ||
[ | ||
"attribute_response.xml", | ||
"okta_response.xml", | ||
"simplesamlphp_authnresponse.xml", | ||
"saml2_response.xml", | ||
"saml_false_signed.xml", | ||
"saml_hok.xml", | ||
"saml_hok_invalid.xml", | ||
"saml_signed.xml", | ||
"saml_unsigned.xml", | ||
], | ||
) | ||
def test_valid_saml_response_doc(doc): | ||
result = validate_doc_with_schema(expand_full_path(doc)) | ||
assert result == None | ||
|
||
|
||
@mark.parametrize("doc", ["encrypted_attribute_statement.xml"]) | ||
def test_valid_saml_partial_doc(doc): | ||
result = validate_doc_with_schema(expand_full_path(doc)) | ||
assert result == None | ||
|
||
|
||
@mark.parametrize("doc", ["eidas_response.xml"]) | ||
def test_valid_eidas_saml_response_doc(doc): | ||
result = validate_doc_with_schema(expand_full_path(doc)) | ||
assert result == None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters