Skip to content

Commit 596881a

Browse files
committed
Fix phpstan-dev issues and generate a baseline
1 parent c07a327 commit 596881a

14 files changed

+122
-66
lines changed

phpstan-baseline-dev.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: "#^Dead catch \\- SimpleSAML\\\\Assert\\\\AssertionFailedException is never thrown in the try block\\.$#"
5+
count: 1
6+
path: tests/InterOperability/EntityDescriptorTest.php
7+
38
-
49
message: "#^PHPDoc tag @var for property SimpleSAML\\\\Test\\\\SAML2\\\\Assertion\\\\Transformer\\\\NameIdDecryptionTransformerTest\\:\\:\\$validator with type SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\Validator is incompatible with native type SimpleSAML\\\\SAML2\\\\Signature\\\\Validator\\.$#"
510
count: 1
@@ -74,3 +79,8 @@ parameters:
7479
message: "#^Parameter \\#1 \\$xml of static method SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\Assertion\\:\\:fromXML\\(\\) expects DOMElement, DOMNode\\|null given\\.$#"
7580
count: 2
7681
path: tests/SAML2/Response/XmlSignatureWrappingTest.php
82+
83+
-
84+
message: "#^Parameter \\#1 \\$keywords of static method SimpleSAML\\\\SAML2\\\\Type\\\\ListOfStringsValue\\:\\:fromArray\\(\\) expects array\\<SimpleSAML\\\\SAML2\\\\Type\\\\SAMLStringValue\\>, array\\<int, string\\> given\\.$#"
85+
count: 1
86+
path: tests/SAML2/XML/mdui/KeywordsTest.php

src/Type/ListOfStringsValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function validateValue(string $value): void
4848
/**
4949
* Convert an array of xs:string items into a mdui:ListOfStrings
5050
*
51-
* @param array<\SimpleSAML\SAML2\Type\SAMLStringValue> $keywords
51+
* @param string[] $keywords
5252
* @return static
5353
*/
5454
public static function fromArray(array $keywords): static

tests/SAML2/Binding/HTTPRedirectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ public function testSendAuthnResponseBespokeDestination(): void
337337
*/
338338
public function testDuplicateQueryParameters(): void
339339
{
340-
/* @phpstan-ignore array.duplicateKey */
341340
$q = [
341+
/* @phpstan-ignore array.duplicateKey */
342342
'SAMLRequest' => 'nVLBauMwEP0Vo7sjW7FpKpJA2rBsoNuGOruHXhZFHm8EsuRqxtv27yvbWWgvYelFgjfvzbx5zBJVazu56enkHuG5B6TktbUO5VhYsT446RUalE61gJK0rDY/7qSYZbILnrz2ln2QXFYoRAhkvGPJbrtiv7VoygJEoTJ9LOusXDSFuJ4vdH6cxwoIEGUjsrqoFUt+QcCoXLHYKMoRe9g5JOUoQlleprlI8/yQz6W4ksXiiSXbuI1xikbViahDyfkRSM2wD40DmjnL0bSdhcE6Hx7BTd3xqnqoIPw1GmbdqWPJNx80jCGtGIUeWLL5t8mtd9i3EM78n493/zWr9XVvx+58mj39IlUaR/QmKOPq4Dtkyf4c9E1EjPtzOePjREL5/XDYp/uH6sDWy6G3HDML66+5ayO7VlHx2dySf2y9nM7pPprabffeGv02ZNcquux5QEydNiNVUlAODTiKMVvrX24DKIJz8nw9jfx8tOt3',
343343
'SAMLRequest' => 'hVLLbttADPwVYe+ylJXsyAvbgBujqIG0MWK3h1wCVkvFC+xDXVJp+/ddywmS9uCeCJAznOGACwJne7Ue+Ojv8ceAxNkvZz2pcbAUQ/QqABlSHhyS4lbt159vlZyUqo+BQxuseEe5zAAijGyCF9l2sxSPjZ41jW5npZxjpWvsrisoZ9ddV8NU6is5nTczXTfTeS2ybxgpMZciLUp0ogG3nhg8p1Ypq7y8ymV1kJUqa1XJB5Ft0jXGA4+sI3NPqiiM7icuhBxiezTPOPG2cEEPFif9sS9OJ5wgBRn/ZHFvnvyd32N8Ni2KbP1q/yZ4GhzGl8nX+9s3AY0u/E+BzlXm0NLY1djBYDmnXmS7l1g/GK+Ti8uJfj+DSH06HHb57m5/EKvFabcaE4qrV1v/OEoOHDJoYFgU7/GL80d8SUrbzS5Y0/7OPobogC8bOXWMzrsRqjiCJ4OeU2jWhp83EYFxKTgOKIrVWfLvv1v9AQ==',
344344
'RelayState' => 'https://demo.moo-archive.nl/module.php/admin/test/default-sp',
@@ -352,8 +352,8 @@ public function testDuplicateQueryParameters(): void
352352
$hr = new HTTPRedirect();
353353
$hr->receive($request);
354354

355-
/* @phpstan-ignore array.duplicateKey */
356355
$q = [
356+
/* @phpstan-ignore array.duplicateKey */
357357
'SAMLRequest' => 'hVLLbttADPwVYe+ylJXsyAvbgBujqIG0MWK3h1wCVkvFC+xDXVJp+/ddywmS9uCeCJAznOGACwJne7Ue+Ojv8ceAxNkvZz2pcbAUQ/QqABlSHhyS4lbt159vlZyUqo+BQxuseEe5zAAijGyCF9l2sxSPjZ41jW5npZxjpWvsrisoZ9ddV8NU6is5nTczXTfTeS2ybxgpMZciLUp0ogG3nhg8p1Ypq7y8ymV1kJUqa1XJB5Ft0jXGA4+sI3NPqiiM7icuhBxiezTPOPG2cEEPFif9sS9OJ5wgBRn/ZHFvnvyd32N8Ni2KbP1q/yZ4GhzGl8nX+9s3AY0u/E+BzlXm0NLY1djBYDmnXmS7l1g/GK+Ti8uJfj+DSH06HHb57m5/EKvFabcaE4qrV1v/OEoOHDJoYFgU7/GL80d8SUrbzS5Y0/7OPobogC8bOXWMzrsRqjiCJ4OeU2jWhp83EYFxKTgOKIrVWfLvv1v9AQ==',
358358
'SAMLRequest' => 'nVLBauMwEP0Vo7sjW7FpKpJA2rBsoNuGOruHXhZFHm8EsuRqxtv27yvbWWgvYelFgjfvzbx5zBJVazu56enkHuG5B6TktbUO5VhYsT446RUalE61gJK0rDY/7qSYZbILnrz2ln2QXFYoRAhkvGPJbrtiv7VoygJEoTJ9LOusXDSFuJ4vdH6cxwoIEGUjsrqoFUt+QcCoXLHYKMoRe9g5JOUoQlleprlI8/yQz6W4ksXiiSXbuI1xikbViahDyfkRSM2wD40DmjnL0bSdhcE6Hx7BTd3xqnqoIPw1GmbdqWPJNx80jCGtGIUeWLL5t8mtd9i3EM78n493/zWr9XVvx+58mj39IlUaR/QmKOPq4Dtkyf4c9E1EjPtzOePjREL5/XDYp/uH6sDWy6G3HDML66+5ayO7VlHx2dySf2y9nM7pPprabffeGv02ZNcquux5QEydNiNVUlAODTiKMVvrX24DKIJz8nw9jfx8tOt3',
359359
'RelayState' => 'https://demo.moo-archive.nl/module.php/admin/test/default-sp',

tests/SAML2/CustomRoleDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class CustomRoleDescriptor extends AbstractRoleDescriptor
4646
/**
4747
* CustomRoleDescriptor constructor.
4848
*
49-
* @param \SimpleSAML\XML\Chunk[] $chunk
49+
* @param \SimpleSAML\XML\SerializableElementInterface[] $chunk
5050
* @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
5151
* @param \SimpleSAML\XML\Type\IDValue|null $ID The ID for this document. Defaults to null.
5252
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
@@ -101,7 +101,7 @@ public function __construct(
101101
/**
102102
* Get the value of the chunk-attribute.
103103
*
104-
* @return \SimpleSAML\XML\Chunk[]
104+
* @return \SimpleSAML\XML\SerializableElementInterface[]
105105
*/
106106
public function getChunk(): array
107107
{

tests/SAML2/XML/md/RoleDescriptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function testUnmarshallingUnregistered(): void
267267
$element = clone self::$xmlRepresentation->documentElement;
268268
$element->setAttributeNS(C::NS_XSI, 'xsi:type', 'ssp:UnknownRoleDescriptorType');
269269

270-
$type = new XMLAttribute(C::NS_XSI, 'xsi', 'type', 'ssp:UnknownRoleDescriptorType');
270+
$type = new XMLAttribute(C::NS_XSI, 'xsi', 'type', StringValue::fromString('ssp:UnknownRoleDescriptorType'));
271271
$type->toXML($element);
272272

273273
$descriptor = AbstractRoleDescriptor::fromXML($element);

tests/SAML2/XML/md/ServiceNameTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PHPUnit\Framework\Attributes\{CoversClass, Group};
88
use PHPUnit\Framework\TestCase;
99
use SimpleSAML\SAML2\Constants as C;
10-
use SimplesAML\SAML2\Type\SAMLStringValue;
10+
use SimpleSAML\SAML2\Type\SAMLStringValue;
1111
use SimpleSAML\SAML2\XML\md\{AbstractLocalizedName, AbstractMdElement, ServiceName};
1212
use SimpleSAML\XML\DOMDocumentFactory;
1313
use SimpleSAML\XML\Exception\MissingAttributeException;

tests/bin/authnrequest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use DateTimeZone;
88
use SimpleSAML\SAML2\Compat\ContainerSingleton;
99
use SimpleSAML\SAML2\Compat\MockContainer;
10+
use SimpleSAML\SAML2\Type\{SAMLAnyURIValue, SAMLDateTimeValue, SAMLStringValue};
1011
use SimpleSAML\SAML2\XML\saml\EncryptedID;
1112
use SimpleSAML\SAML2\XML\saml\Issuer;
1213
use SimpleSAML\SAML2\XML\saml\NameID;
1314
use SimpleSAML\SAML2\XML\saml\Subject;
1415
use SimpleSAML\SAML2\XML\samlp\AuthnRequest;
16+
use SimpleSAML\XML\Type\IDValue;
1517
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
1618
use SimpleSAML\XMLSecurity\Constants as C;
1719
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
@@ -25,18 +27,18 @@
2527
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY),
2628
);
2729

28-
$nid = new NameID('very secret');
30+
$nid = new NameID(SAMLStringValue::fromString('very secret'));
2931
$eid = new EncryptedID($nid->encrypt($encryptor));
3032

31-
$issuer = new Issuer('https://gateway.example.org/saml20/sp/metadata');
33+
$issuer = new Issuer(SAMLStringValue::fromString('https://gateway.example.org/saml20/sp/metadata'));
3234
$subject = new Subject($eid);
3335

3436
$authnRequest = new AuthnRequest(
3537
subject: $subject,
36-
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
38+
issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))),
3739
issuer: $issuer,
38-
id: '123',
39-
destination: 'https://tiqr.example.org/idp/profile/saml2/Redirect/SSO',
40+
id: IDValue::fromString('123'),
41+
destination: SAMLAnyURIValue::fromString('https://tiqr.example.org/idp/profile/saml2/Redirect/SSO'),
4042
);
4143

4244
$authnRequest = $authnRequest->toXML();

tests/bin/encryptedattribute.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use SimpleSAML\SAML2\Compat\ContainerSingleton;
77
use SimpleSAML\SAML2\Compat\MockContainer;
8+
use SimpleSAML\SAML2\Type\SAMLStringValue;
89
use SimpleSAML\SAML2\XML\saml\Attribute;
910
use SimpleSAML\SAML2\XML\saml\AttributeValue;
1011
use SimpleSAML\SAML2\XML\saml\EncryptedAttribute;
@@ -21,8 +22,10 @@
2122
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::PUBLIC_KEY),
2223
);
2324
$attribute = new Attribute(
24-
name: 'urn:encrypted:attribute',
25-
attributeValue: [new AttributeValue('very secret data')],
25+
name: SAMLStringValue::fromString('urn:encrypted:attribute'),
26+
attributeValue: [
27+
new AttributeValue(SAMLStringValue::fromString('very secret data')),
28+
],
2629
);
2730
$encAttribute = new EncryptedAttribute($attribute->encrypt($encryptor));
2831

tests/bin/encryptedid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use SimpleSAML\SAML2\Compat\ContainerSingleton;
77
use SimpleSAML\SAML2\Compat\MockContainer;
8+
use SimpleSAML\SAML2\Type\SAMLStringValue;
89
use SimpleSAML\SAML2\XML\saml\EncryptedID;
910
use SimpleSAML\SAML2\XML\saml\NameID;
1011
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
@@ -19,7 +20,7 @@
1920
C::KEY_TRANSPORT_OAEP,
2021
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY),
2122
);
22-
$nid = new NameID('very secret');
23+
$nid = new NameID(SAMLStringValue::fromString('very secret'));
2324
$eid = new EncryptedID($nid->encrypt($encryptor));
2425

2526
echo $eid->toXML()->ownerDocument->saveXML();

tests/bin/entityattributes.php

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use DateTimeImmutable;
77
use DateTimeZone;
88
use SimpleSAML\SAML2\Constants as C;
9+
use SimpleSAML\SAML2\Type\{SAMLAnyURIValue, SAMLDateTimeValue, SAMLStringValue};
910
use SimpleSAML\SAML2\XML\mdattr\EntityAttributes;
1011
use SimpleSAML\SAML2\XML\saml\Assertion;
1112
use SimpleSAML\SAML2\XML\saml\Attribute;
@@ -17,6 +18,7 @@
1718
use SimpleSAML\SAML2\XML\saml\Issuer;
1819
use SimpleSAML\SAML2\XML\saml\NameID;
1920
use SimpleSAML\SAML2\XML\saml\Subject;
21+
use SimpleSAML\XML\Type\IDValue;
2022
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
2123
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
2224

@@ -28,61 +30,81 @@
2830
);
2931

3032
$unsignedAssertion = new Assertion(
31-
issuer: new Issuer('urn:x-simplesamlphp:issuer'),
32-
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
33-
id: '_93af655219464fb403b34436cfb0c5cb1d9a5502',
33+
issuer: new Issuer(SAMLStringValue::fromString('urn:x-simplesamlphp:issuer')),
34+
issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))),
35+
id: IDValue::fromString('_93af655219464fb403b34436cfb0c5cb1d9a5502'),
3436
subject: new Subject(new NameID(
35-
value: 'some:entity',
36-
Format: C::NAMEID_ENTITY,
37+
value: SAMLStringValue::fromString('some:entity'),
38+
Format: SAMLAnyURIValue::fromString(C::NAMEID_ENTITY),
3739
)),
3840
conditions: new Conditions(
3941
condition: [],
4042
audienceRestriction: [
4143
new AudienceRestriction([
42-
new Audience('https://simplesamlphp.org/idp/metadata'),
43-
new Audience('urn:x-simplesamlphp:phpunit:entity'),
44+
new Audience(SAMLAnyURIValue::fromString('https://simplesamlphp.org/idp/metadata')),
45+
new Audience(SAMLAnyURIValue::fromString('urn:x-simplesamlphp:phpunit:entity')),
4446
]),
4547
],
4648
),
4749
statements: [new AttributeStatement([
4850
new Attribute(
49-
name: 'urn:mace:dir:attribute-def:uid',
50-
nameFormat: C::NAMEFORMAT_URI,
51-
attributeValue: [new AttributeValue('student2')],
51+
name: SAMLStringValue::fromString('urn:mace:dir:attribute-def:uid'),
52+
nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI),
53+
attributeValue: [
54+
new AttributeValue(SAMLStringValue::fromString('student2')),
55+
],
5256
),
5357
new Attribute(
54-
name: 'urn:mace:terena.org:attribute-def:schacHomeOrganization',
55-
nameFormat: C::NAMEFORMAT_URI,
56-
attributeValue: [new AttributeValue('university.example.org'), new AttributeValue('bbb.cc')],
58+
name: SAMLStringValue::fromString('urn:mace:terena.org:attribute-def:schacHomeOrganization'),
59+
nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI),
60+
attributeValue: [
61+
new AttributeValue(SAMLStringValue::fromString('university.example.org')),
62+
new AttributeValue(SAMLStringValue::fromString('bbb.cc')),
63+
],
5764
),
5865
new Attribute(
59-
name: 'urn:schac:attribute-def:schacPersonalUniqueCode',
60-
nameFormat: C::NAMEFORMAT_URI,
66+
name: SAMLStringValue::fromString('urn:schac:attribute-def:schacPersonalUniqueCode'),
67+
nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI),
6168
attributeValue: [
62-
new AttributeValue('urn:schac:personalUniqueCode:nl:local:uvt.nl:memberid:524020'),
63-
new AttributeValue('urn:schac:personalUniqueCode:nl:local:surfnet.nl:studentid:12345'),
69+
new AttributeValue(
70+
SAMLStringValue::fromString('urn:schac:personalUniqueCode:nl:local:uvt.nl:memberid:524020'),
71+
),
72+
new AttributeValue(
73+
SAMLStringValue::fromString('urn:schac:personalUniqueCode:nl:local:surfnet.nl:studentid:12345'),
74+
),
6475
],
6576
),
6677
new Attribute(
67-
name: 'urn:mace:dir:attribute-def:eduPersonAffiliation',
68-
nameFormat: C::NAMEFORMAT_URI,
69-
attributeValue: [new AttributeValue('member'), new AttributeValue('student')],
78+
name: SAMLStringValue::fromString('urn:mace:dir:attribute-def:eduPersonAffiliation'),
79+
nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_URI),
80+
attributeValue: [
81+
new AttributeValue(SAMLStringValue::fromString('member')),
82+
new AttributeValue(SAMLStringValue::fromString('student')),
83+
],
7084
),
7185
])],
7286
);
7387
$unsignedAssertion->sign($signer);
7488
$signedAssertion = Assertion::fromXML($unsignedAssertion->toXML());
7589
$entityAttributes = new EntityAttributes([
7690
new Attribute(
77-
name: 'attrib1',
78-
nameFormat: C::NAMEFORMAT_BASIC,
79-
attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')],
91+
name: SAMLStringValue::fromString('attrib1'),
92+
nameFormat: SAMLAnyURIValue::fromString(C::NAMEFORMAT_BASIC),
93+
attributeValue: [
94+
new AttributeValue(SAMLStringValue::fromString('is')),
95+
new AttributeValue(SAMLStringValue::fromString('really')),
96+
new AttributeValue(SAMLStringValue::fromString('cool')),
97+
],
8098
),
8199
$signedAssertion,
82100
new Attribute(
83-
name: 'foo',
84-
nameFormat: 'urn:simplesamlphp:v1:simplesamlphp',
85-
attributeValue: [new AttributeValue('is'), new AttributeValue('really'), new AttributeValue('cool')],
101+
name: SAMLStringValue::fromString('foo'),
102+
nameFormat: SAMLAnyURIValue::fromString('urn:simplesamlphp:v1:simplesamlphp'),
103+
attributeValue: [
104+
new AttributeValue(SAMLStringValue::fromString('is')),
105+
new AttributeValue(SAMLStringValue::fromString('really')),
106+
new AttributeValue(SAMLStringValue::fromString('cool')),
107+
],
86108
),
87109
]);
88110

tests/bin/logoutrequest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use DateTimeZone;
88
use SimpleSAML\SAML2\Compat\ContainerSingleton;
99
use SimpleSAML\SAML2\Compat\MockContainer;
10+
use SimpleSAML\SAML2\Type\{SAMLDateTimeValue, SAMLStringValue};
1011
use SimpleSAML\SAML2\XML\saml\EncryptedID;
1112
use SimpleSAML\SAML2\XML\saml\Issuer;
1213
use SimpleSAML\SAML2\XML\saml\NameID;
1314
use SimpleSAML\SAML2\XML\samlp\LogoutRequest;
1415
use SimpleSAML\SAML2\XML\samlp\SessionIndex;
16+
use SimpleSAML\XML\Type\IDValue;
1517
use SimpleSAML\XMLSecurity\Alg\KeyTransport\KeyTransportAlgorithmFactory;
1618
use SimpleSAML\XMLSecurity\Constants as C;
1719
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
@@ -24,14 +26,18 @@
2426
C::KEY_TRANSPORT_OAEP,
2527
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::SELFSIGNED_PUBLIC_KEY),
2628
);
27-
$nid = new NameID('very secret');
29+
$nid = new NameID(SAMLStringValue::fromString('very secret'));
2830
$eid = new EncryptedID($nid->encrypt($encryptor));
2931

3032
$logoutRequest = new LogoutRequest(
33+
id: IDValue::fromString('abc123'),
3134
identifier: $eid,
32-
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
33-
sessionIndexes: [new SessionIndex('SomeSessionIndex1'), new SessionIndex('SomeSessionIndex2')],
34-
issuer: new Issuer('urn:test:TheIssuer'),
35+
issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))),
36+
sessionIndexes: [
37+
new SessionIndex(SAMLStringValue::fromString('SomeSessionIndex1')),
38+
new SessionIndex(SAMLStringValue::fromString('SomeSessionIndex2')),
39+
],
40+
issuer: new Issuer(SAMLStringValue::fromString('urn:test:TheIssuer')),
3541
);
3642

3743
$logoutRequest = $logoutRequest->toXML();

tests/bin/signedresponse_with_signedassertion.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
require_once(dirname(__FILE__, 3) . '/vendor/autoload.php');
55

6+
use SimpleSAML\SAML2\Type\{SAMLAnyURIValue, SAMLDateTimeValue, SAMLStringValue};
67
use SimpleSAML\SAML2\XML\saml\Assertion;
78
use SimpleSAML\SAML2\XML\saml\Issuer;
89
use SimpleSAML\SAML2\XML\samlp\Response;
910
use SimpleSAML\SAML2\XML\samlp\Status;
1011
use SimpleSAML\SAML2\XML\samlp\StatusCode;
1112
use SimpleSAML\Test\SAML2\Constants as C;
1213
use SimpleSAML\XML\DOMDocumentFactory;
14+
use SimpleSAML\XML\Type\{IDValue, NCNameValue};
1315
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
1416
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1517

@@ -24,13 +26,15 @@
2426
$signedAssertion = Assertion::fromXML($unsignedAssertion->toXML());
2527

2628
$unsignedResponse = new Response(
27-
status: new Status(new StatusCode(C::STATUS_SUCCESS)),
28-
issuer: new Issuer('https://IdentityProvider.com'),
29-
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
30-
id: 'abc123',
31-
inResponseTo: 'PHPUnit',
32-
destination: C::ENTITY_OTHER,
33-
consent: C::ENTITY_SP,
29+
status: new Status(
30+
new StatusCode(SAMLAnyURIValue::fromString(C::STATUS_SUCCESS)),
31+
),
32+
issuer: new Issuer(SAMLStringValue::fromString('https://IdentityProvider.com')),
33+
issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))),
34+
id: IDValue::fromString('abc123'),
35+
inResponseTo: NCNameValue::fromString('PHPUnit'),
36+
destination: SAMLAnyURIValue::fromString(C::ENTITY_OTHER),
37+
consent: SAMLAnyURIValue::fromString(C::ENTITY_SP),
3438
assertions: [$signedAssertion],
3539
);
3640

tests/bin/signedresponse_with_unsignedassertion.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@
33

44
require_once(dirname(__FILE__, 3) . '/vendor/autoload.php');
55

6+
use SimpleSAML\SAML2\Type\{SAMLAnyURIValue, SAMLDateTimeValue, SAMLStringValue};
67
use SimpleSAML\SAML2\XML\saml\Assertion;
78
use SimpleSAML\SAML2\XML\saml\Issuer;
89
use SimpleSAML\SAML2\XML\samlp\Response;
910
use SimpleSAML\SAML2\XML\samlp\Status;
1011
use SimpleSAML\SAML2\XML\samlp\StatusCode;
1112
use SimpleSAML\Test\SAML2\Constants as C;
1213
use SimpleSAML\XML\DOMDocumentFactory;
14+
use SimpleSAML\XML\Type\{IDValue, NCNameValue};
1315
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
1416
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1517

1618
$document = DOMDocumentFactory::fromFile(dirname(__FILE__, 2) . '/resources/xml/saml_Assertion.xml');
1719
$unsignedAssertion = Assertion::fromXML($document->documentElement);
1820

1921
$unsignedResponse = new Response(
20-
status: new Status(new StatusCode(C::STATUS_SUCCESS)),
21-
issuer: new Issuer('https://IdentityProvider.com'),
22-
issueInstant: new DateTimeImmutable('now', new DateTimeZone('Z')),
23-
id: 'abc123',
24-
inResponseTo: 'PHPUnit',
25-
destination: C::ENTITY_OTHER,
26-
consent: C::ENTITY_SP,
22+
status: new Status(
23+
new StatusCode(SAMLAnyURIValue::fromString(C::STATUS_SUCCESS)),
24+
),
25+
issuer: new Issuer(SAMLStringValue::fromString('https://IdentityProvider.com')),
26+
issueInstant: SAMLDateTimeValue::fromDateTime(new DateTimeImmutable('now', new DateTimeZone('Z'))),
27+
id: IDValue::fromString('abc123'),
28+
inResponseTo: NCNameValue::fromString('PHPUnit'),
29+
destination: SAMLAnyURIValue::fromString(C::ENTITY_OTHER),
30+
consent: SAMLAnyURIValue::fromString(C::ENTITY_SP),
2731
assertions: [$unsignedAssertion],
2832
);
2933

0 commit comments

Comments
 (0)