Skip to content

Commit e38af41

Browse files
committed
Properly normalize documents
1 parent 4a66f07 commit e38af41

39 files changed

+130
-132
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
"psr/http-message": "~2.0",
3232
"psr/log": "~2.3 || ~3.0",
3333
"simplesamlphp/assert": "~1.9",
34-
"simplesamlphp/xml-common": "~2.2",
34+
"simplesamlphp/xml-common": "~2.3",
3535
"simplesamlphp/xml-security": "~2.0",
3636
"simplesamlphp/xml-soap": "~2.0"
3737
},
3838
"require-dev": {
3939
"ext-intl": "*",
4040

41-
"beste/clock": "~3.0.0",
42-
"mockery/mockery": "~1.6.12",
43-
"simplesamlphp/simplesamlphp-test-framework": "~1.10.2"
41+
"beste/clock": "~3.0",
42+
"mockery/mockery": "~1.6",
43+
"simplesamlphp/simplesamlphp-test-framework": "~1.10"
4444
},
4545
"suggest": {
4646
"ext-soap": "*"
@@ -58,7 +58,7 @@
5858
},
5959
"extra": {
6060
"branch-alias": {
61-
"dev-master": "v6.0.x-dev"
61+
"dev-master": "v5.1.x-dev"
6262
}
6363
},
6464
"config": {

tests/SAML2/XML/md/EntityDescriptorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,16 @@ public function testMarshalling(): void
235235
public function testMarshallingWithAffiliationDescriptor(): void
236236
{
237237
$ns_md = C::NS_MD;
238+
$ns_mdrpi = C::NS_MDRPI;
238239
$entity_idp = C::ENTITY_IDP;
239240
$entity_other = C::ENTITY_OTHER;
240241

241242
$document = DOMDocumentFactory::fromString(
242243
<<<XML
243-
<md:EntityDescriptor xmlns:md="{$ns_md}" ID="_5A3CHB081" validUntil="2020-02-05T09:39:25Z"
244+
<md:EntityDescriptor xmlns:md="{$ns_md}" xmlns:mdrpi="{$ns_mdrpi}" ID="_5A3CHB081" validUntil="2020-02-05T09:39:25Z"
244245
cacheDuration="P2Y6M5DT12H35M30S" entityID="{$entity_idp}">
245246
<md:Extensions>
246-
<mdrpi:PublicationInfo xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
247-
publisher="http://publisher.ra/" creationInstant="2020-02-03T13:46:24Z">
247+
<mdrpi:PublicationInfo publisher="http://publisher.ra/" creationInstant="2020-02-03T13:46:24Z">
248248
<mdrpi:UsagePolicy xml:lang="en">http://publisher.ra/policy.txt</mdrpi:UsagePolicy>
249249
</mdrpi:PublicationInfo>
250250
</md:Extensions>

tests/SAML2/XML/md/KeyDescriptorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public function testMarshallingWithoutOptionalParameters(): void
9797

9898
$this->assertEquals(
9999
<<<XML
100-
<md:KeyDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
101-
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
100+
<md:KeyDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
101+
<ds:KeyInfo>
102102
<ds:KeyName>IdentityProvider.com SSO Key</ds:KeyName>
103103
</ds:KeyInfo>
104104
</md:KeyDescriptor>
@@ -134,8 +134,8 @@ public function testUnmarshallingWithoutOptionalParameters(): void
134134
{
135135
$document = DOMDocumentFactory::fromString(
136136
<<<XML
137-
<md:KeyDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
138-
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
137+
<md:KeyDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
138+
<ds:KeyInfo>
139139
<ds:KeyName>IdentityProvider.com SSO Key</ds:KeyName>
140140
</ds:KeyInfo>
141141
</md:KeyDescriptor>

tests/SAML2/XML/saml/AssertionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,9 @@ public function testNameIdEncryption(): void
11821182

11831183
$identifier = $assertionToVerify->getSubject()?->getIdentifier();
11841184
$this->assertInstanceOf(EncryptedID::class, $identifier);
1185-
1185+
//var_dump( $identifier->getEncryptedData()->getKeyInfo()->getInfo() );
1186+
// This contains a Chunk instead of an EncryptedKey-object
1187+
// ToDo: figure out why
11861188
$decryptor = (new KeyTransportAlgorithmFactory())->getAlgorithm(
11871189
$identifier->getEncryptedKeys()[0]->getEncryptionMethod()?->getAlgorithm()->getValue(),
11881190
PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::PRIVATE_KEY),

tests/SAML2/XML/saml/AttributeValueTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,13 @@ public function testMarshallingNull(): void
149149
/**
150150
* Verifies that supplying an empty string as attribute value will
151151
* generate a tag with no content (instead of e.g. an empty tag).
152-
*
153152
*/
154153
public function testEmptyStringAttribute(): void
155154
{
156155
$av = new AttributeValue('');
157156
$xmlRepresentation = clone self::$xmlRepresentation;
158157
$xmlRepresentation->documentElement->textContent = '';
159-
// $this->assertEqualXMLStructure(
160-
// $this->xmlRepresentation->documentElement,
161-
// $av->toXML(),
162-
// );
158+
163159
$this->assertEquals('', $av->getValue());
164160
$this->assertEquals('xs:string', $av->getXsiType());
165161
}
@@ -203,22 +199,22 @@ public function testSerializeEncryptedID(): void
203199
{
204200
$document = DOMDocumentFactory::fromString(
205201
<<<XML
206-
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
202+
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
207203
<saml:EncryptedID>
208-
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="_4ea05f00adb06c642e0cb52f063e2570-1" Type="http://www.w3.org/2001/04/xmlenc#Element">
204+
<xenc:EncryptedData Id="_4ea05f00adb06c642e0cb52f063e2570-1" Type="http://www.w3.org/2001/04/xmlenc#Element">
209205
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
210-
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
206+
<ds:KeyInfo>
211207
<ds:RetrievalMethod URI="#_dc9043a7cbec55c6fcc61f1cf64cf868-1" Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey"/>
212208
</ds:KeyInfo>
213209
<xenc:CipherData>
214210
<xenc:CipherValue>vErnRkA0oSmtQGamjZGa9RFN25SUx1UVLsLAOtopt7pyywTD7wu9pyocfD4HqduXCsvaiZpJykz11utZdvtJ0sOdm9oE+lAtNTUnKzGSNoSopGCzwNu5pqwhIEvWEWeilmJayAC2elpRYOnUs/rePxibz0Wbqa7BItLt6ZkKTtMkv0U0PpgGenF1pWzsahRtw6Y5tFq7xFQkG/z0Lz5rJ+IxExYXgB3LN6FBmVcB1ioahk2ovOwbLQ+lNAdqUMhpZx6fgdL2v7g4OYPK0rDgSALU3gU3dvU4hC/Kk9N5Rkw=</xenc:CipherValue>
215211
</xenc:CipherData>
216212
</xenc:EncryptedData>
217-
<xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="_dc9043a7cbec55c6fcc61f1cf64cf868-1" Recipient="urn:nl-eid-gdi:1.0:DV:00000009900006840000:entities:9780">
213+
<xenc:EncryptedKey Id="_dc9043a7cbec55c6fcc61f1cf64cf868-1" Recipient="urn:nl-eid-gdi:1.0:DV:00000009900006840000:entities:9780">
218214
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
219-
<ds:DigestMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
215+
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
220216
</xenc:EncryptionMethod>
221-
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
217+
<ds:KeyInfo>
222218
<ds:KeyName>_b420654655d491b49555c698f80efb7bda3ac6ef</ds:KeyName>
223219
</ds:KeyInfo>
224220
<xenc:CipherData>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<alg:DigestMethod xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" Algorithm="http://www.w3.org/2001/04/xmlenc#sha256">
2-
<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>
1+
<alg:DigestMethod xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" xmlns:ssp="urn:x-simplesamlphp:namespace" Algorithm="http://www.w3.org/2001/04/xmlenc#sha256">
2+
<ssp:Chunk>Some</ssp:Chunk>
33
</alg:DigestMethod>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<alg:SigningMethod xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" MinKeySize="1024" MaxKeySize="4096">
2-
<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>
1+
<alg:SigningMethod xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" xmlns:ssp="urn:x-simplesamlphp:namespace" Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" MinKeySize="1024" MaxKeySize="4096">
2+
<ssp:Chunk>Some</ssp:Chunk>
33
</alg:SigningMethod>

tests/resources/xml/ecp_Request.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<ecp:Request xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:mustUnderstand="1" SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" ProviderName="PHPUnit" IsPassive="1">
2-
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" NameQualifier="urn:x-simplesamlphp:namequalifier" SPNameQualifier="urn:x-simplesamlphp:spnamequalifier" Format="urn:the:format" SPProvidedID="TheSPProvidedID">urn:x-simplesamlphp:issuer</saml:Issuer>
3-
<samlp:IDPList xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
1+
<ecp:Request xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" SOAP-ENV:mustUnderstand="1" SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" ProviderName="PHPUnit" IsPassive="1">
2+
<saml:Issuer NameQualifier="urn:x-simplesamlphp:namequalifier" SPNameQualifier="urn:x-simplesamlphp:spnamequalifier" Format="urn:the:format" SPProvidedID="TheSPProvidedID">urn:x-simplesamlphp:issuer</saml:Issuer>
3+
<samlp:IDPList>
44
<samlp:IDPEntry ProviderID="urn:some:requester1" Name="testName1" Loc="urn:test:testLoc1"/>
55
<samlp:IDPEntry ProviderID="urn:some:requester2" Name="testName2" Loc="urn:test:testLoc2"/>
66
<samlp:GetComplete>https://some/location</samlp:GetComplete>

tests/resources/xml/ecp_SubjectConfirmation.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<ecp:SubjectConfirmation xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:mustUnderstand="1" SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
2-
<saml:SubjectConfirmationData xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" NotBefore="2001-04-19T04:25:21Z" NotOnOrAfter="2009-02-13T23:31:30Z" Recipient="https://simplesamlphp.org/sp/metadata" InResponseTo="SomeRequestID" Address="127.0.0.1" test:attr1="testval1" test:attr2="testval2" xmlns:test="urn:test:something">
3-
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
1+
<ecp:SubjectConfirmation xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="urn:test:something" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" SOAP-ENV:mustUnderstand="1" SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
2+
<saml:SubjectConfirmationData NotBefore="2001-04-19T04:25:21Z" NotOnOrAfter="2009-02-13T23:31:30Z" Recipient="https://simplesamlphp.org/sp/metadata" InResponseTo="SomeRequestID" Address="127.0.0.1" test:attr1="testval1" test:attr2="testval2" xmlns:test="urn:test:something">
3+
<ds:KeyInfo>
44
<ds:KeyName>SomeKey</ds:KeyName>
55
</ds:KeyInfo>
66
<some>Arbitrary Element</some>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<idpdisc:DiscoveryResponse xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" xmlns:ssp="urn:x-simplesamlphp:namespace" Binding="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" Location="https://simplesamlphp.org/some/endpoint" index="43" isDefault="false" ssp:attr1="testval1">
2-
<some:Ext xmlns:some="urn:mace:some:metadata:1.0">SomeExtension</some:Ext>
1+
<idpdisc:DiscoveryResponse xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:some="urn:mace:some:metadata:1.0" Binding="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" Location="https://simplesamlphp.org/some/endpoint" index="43" isDefault="false" ssp:attr1="testval1">
2+
<some:Ext>SomeExtension</some:Ext>
33
</idpdisc:DiscoveryResponse>

0 commit comments

Comments
 (0)