Skip to content

Commit 161fab4

Browse files
committed
Fix some tests
1 parent 322d98d commit 161fab4

23 files changed

Lines changed: 52 additions & 43 deletions

‎src/SAML11/XML/saml/SubjectConfirmationData.php‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
use Dom;
88
use SimpleSAML\Assert\Assert;
9+
use SimpleSAML\SAML11\Constants as C;
910
use SimpleSAML\SAML11\Type\SAMLStringValue;
1011
use SimpleSAML\XML\AbstractElement;
12+
use SimpleSAML\XML\Attribute as XMLAttribute;
1113
use SimpleSAML\XML\Chunk;
1214
use SimpleSAML\XML\SchemaValidatableElementInterface;
1315
use SimpleSAML\XML\SchemaValidatableElementTrait;
1416
use SimpleSAML\XMLSchema\Constants as C_XSI;
1517
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
18+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
1619
use SimpleSAML\XMLSchema\Type\IntegerValue;
1720
use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface;
1821

@@ -146,21 +149,31 @@ public function toXML(?Dom\Element $parent = null): Dom\Element
146149
switch ($type) {
147150
case "integer":
148151
// make sure that the xs namespace is available in the SubjectConfirmationData
149-
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI);
150-
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xs', C_XSI::NS_XS);
152+
$xsi_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xsi', AnyURIValue::fromString(C_XSI::NS_XSI));
153+
$xsi_attr->toXML($e);
154+
155+
$xs_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xs', AnyURIValue::fromString(C_XSI::NS_XS));
156+
$xs_attr->toXML($e);
157+
151158
$e->setAttributeNS(C_XSI::NS_XSI, 'xsi:type', 'xs:integer');
152159
$e->textContent = strval($value);
153160
break;
154161
case "NULL":
155-
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI);
162+
$xs_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xs', C_XSI::NS_XS);
163+
$xs_attr->toXML($e);
164+
156165
$e->setAttributeNS(C_XSI::NS_XSI, 'xsi:nil', '1');
157166
$e->textContent = '';
158167
break;
159168
case "object":
160169
if ($value instanceof ValueTypeInterface) {
161170
if ($this->value instanceof IntegerValue) {
162-
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI);
163-
$e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xs', C_XSI::NS_XS);
171+
$xsi_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xsi', AnyURIValue::fromString(C_XSI::NS_XSI));
172+
$xsi_attr->toXML($e);
173+
174+
$xs_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xs', AnyURIValue::fromString(C_XSI::NS_XS));
175+
$xs_attr->toXML($e);
176+
164177
$e->setAttributeNS(C_XSI::NS_XSI, 'xsi:type', 'xs:integer');
165178
}
166179
$e->textContent = strval($value);

‎tests/resources/schemas/simplesamlphp.xsd‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!DOCTYPE schema
3-
PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd"
4-
[
5-
<!ATTLIST schema
6-
xmlns:ds CDATA #FIXED "urn:x-simplesamlphp:namespace">
7-
<!ENTITY ssp 'urn:x-simplesamlphp:namespace'>
8-
<!ENTITY % p ''>
9-
<!ENTITY % s ''>
10-
]>
112

123
<!-- Schema for SimpleSAMLphp dummy classes -->
134

14-
155
<schema xmlns="http://www.w3.org/2001/XMLSchema"
166
xmlns:ssp="urn:x-simplesamlphp:namespace"
177
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"

‎tests/resources/xml/saml_Advice.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</saml:SubjectConfirmation>
6363
</saml:Subject>
6464
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
65-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
65+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
6666
</saml:AuthenticationStatement>
6767
<saml:AttributeStatement>
6868
<saml:Subject>
@@ -129,7 +129,7 @@
129129
</saml:SubjectConfirmation>
130130
</saml:Subject>
131131
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
132-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
132+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
133133
</saml:AuthenticationStatement>
134134
<saml:AttributeStatement>
135135
<saml:Subject>

‎tests/resources/xml/saml_Assertion.xml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</saml:SubjectConfirmation>
7373
</saml:Subject>
7474
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
75-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
75+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
7676
</saml:AuthenticationStatement>
7777
<saml:AttributeStatement>
7878
<saml:Subject>
@@ -139,7 +139,7 @@
139139
</saml:SubjectConfirmation>
140140
</saml:Subject>
141141
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
142-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
142+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
143143
</saml:AuthenticationStatement>
144144
<saml:AttributeStatement>
145145
<saml:Subject>
@@ -206,7 +206,7 @@
206206
</saml:SubjectConfirmation>
207207
</saml:Subject>
208208
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
209-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
209+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
210210
</saml:AuthenticationStatement>
211211
<saml:AuthorizationDecisionStatement Resource="urn:x-simplesamlphp:resource" Decision="Permit">
212212
<saml:Subject>
@@ -278,7 +278,7 @@
278278
</saml:SubjectConfirmation>
279279
</saml:Subject>
280280
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
281-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
281+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
282282
</saml:AuthenticationStatement>
283283
<saml:AttributeStatement>
284284
<saml:Subject>

‎tests/resources/xml/saml_AuthenticationStatement.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
</saml:SubjectConfirmation>
1717
</saml:Subject>
1818
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
19-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
19+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
2020
</saml:AuthenticationStatement>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<saml:AuthorityBinding xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
1+
<saml:AuthorityBinding xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />

‎tests/resources/xml/saml_AuthorizationDecisionStatement.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</saml:SubjectConfirmation>
6969
</saml:Subject>
7070
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
71-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
71+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
7272
</saml:AuthenticationStatement>
7373
<saml:AttributeStatement>
7474
<saml:Subject>

‎tests/resources/xml/saml_Evidence.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<saml:Evidence xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol">
1+
<saml:Evidence xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol">
22
<saml:AssertionIDReference>_Test</saml:AssertionIDReference>
33
<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="EvidenceAssertionID" Issuer="urn:x-simplesamlphp:phpunit" IssueInstant="2023-01-24T09:42:26Z">
44
<saml:Conditions NotBefore="2023-01-24T09:42:26Z" NotOnOrAfter="2023-01-24T09:47:26Z">
@@ -50,7 +50,7 @@
5050
</saml:SubjectConfirmation>
5151
</saml:Subject>
5252
<saml:SubjectLocality IPAddress="127.0.0.1" DNSAddress="simplesamlphp.org" />
53-
<saml:AuthorityBinding AuthorityKind="samlp:AttributeQuery" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
53+
<saml:AuthorityBinding AuthorityKind="samlp:AssertionIdReference" Location="urn:x-simplesamlphp:location" Binding="urn:x-simplesamlphp:binding" />
5454
</saml:AuthenticationStatement>
5555
<saml:AttributeStatement>
5656
<saml:Subject>

‎tests/resources/xml/saml_SubjectConfirmation.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<saml:SubjectConfirmation xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ssp="urn:x-simplesamlphp:namespace">
1+
<saml:SubjectConfirmation xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ssp="urn:x-simplesamlphp:namespace">
22
<saml:ConfirmationMethod>_Test1</saml:ConfirmationMethod>
33
<saml:ConfirmationMethod>_Test2</saml:ConfirmationMethod>
4-
<saml:SubjectConfirmationData xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:integer" xsi:type="xs:integer">2</saml:SubjectConfirmationData>
4+
<saml:SubjectConfirmationData xsi:type="xs:integer">2</saml:SubjectConfirmationData>
55
<ds:KeyInfo Id="fed654">
66
<ds:KeyName>testkey</ds:KeyName>
77
<ds:X509Data>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<saml:SubjectConfirmationData xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:integer">2</saml:SubjectConfirmationData>
1+
<saml:SubjectConfirmationData xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:integer">2</saml:SubjectConfirmationData>

0 commit comments

Comments
 (0)