Skip to content

Commit

Permalink
tests: check namespace processing
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kanakarakis <[email protected]>
  • Loading branch information
c00kiemon5ter committed Jan 30, 2024
1 parent 5b09131 commit 3daa066
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_schema_validator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from pathutils import full_path as expand_full_path

from pytest import mark
from pytest import raises

from saml2 import create_class_from_xml_string
from saml2.saml import AttributeStatement
from saml2.sigver import validate_doc_with_schema
from saml2.xml.schema import XMLSchemaError
from saml2.xml.schema import validate as validate_doc_with_schema

Expand Down Expand Up @@ -86,3 +90,20 @@ def test_valid_saml_partial_doc(doc):
def test_valid_eidas_saml_response_doc(doc):
result = validate_doc_with_schema(expand_full_path(doc))
assert result == None


def test_namespace_processing():
elem = create_class_from_xml_string(
AttributeStatement,
"""
<saml:AttributeStatement xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<saml:Attribute Name="urn:mace:dir:attribute-def:uid" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue xsi:type="xs:string">alum11</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="urn:mace:terena.org:attribute-def:schacHomeOrganization" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue xsi:type="xs:string"/>
</saml:Attribute>
</saml:AttributeStatement>
""",
)
validate_doc_with_schema(str(elem))

0 comments on commit 3daa066

Please sign in to comment.