Skip to content

Commit 2438acb

Browse files
committed
Fix unit tests
1 parent 9cf770d commit 2438acb

4 files changed

Lines changed: 23 additions & 28 deletions

File tree

tests/SAML2/Binding/HTTPArtifactTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,6 @@ public function testArtifactMissingUrlParamThrowsException(): void
4747
}
4848

4949

50-
/**
51-
* Distinguish the legacy and the new signature-validation APIs:
52-
* - Legacy messages: validate(XMLSecurityKey $key)
53-
* - New XML model: verify($verifier) returning a verified instance
54-
*/
55-
public function testLegacyVsNewSignatureApiIsDifferent(): void
56-
{
57-
$legacyClass = \SAML2\Message::class;
58-
$newClass = \SimpleSAML\SAML2\XML\samlp\AbstractMessage::class;
59-
60-
/** @phpstan-ignore-next-line */
61-
$this->assertTrue(method_exists($legacyClass, 'validate'));
62-
$this->assertFalse(method_exists($legacyClass, 'verify'));
63-
64-
/** @phpstan-ignore-next-line */
65-
$this->assertTrue(method_exists($newClass, 'verify'));
66-
$this->assertFalse(method_exists($newClass, 'validate'));
67-
}
68-
69-
7050
/**
7151
* @return array<
7252
* string,

tests/SAML2/XML/saml/EncryptedAttributeTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ public function testMarshalling(): void
9191
$encryptedData = $encryptedAttribute->getEncryptedData();
9292

9393
$this->assertEquals(C::XMLENC_ELEMENT, $encryptedData->getType());
94-
95-
$expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
96-
$this->assertNotFalse($expectedXml);
97-
$actualXml = strval($encryptedAttribute);
98-
99-
$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
10094
}
10195

10296

tests/SAML2/XML/saml/SubjectTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ final class SubjectTest extends TestCase
5151
use SerializableElementTestTrait;
5252

5353

54+
/** @var \Dom\XMLDocument */
55+
private static Dom\XMLDocument $xmlRepresentationBaseId;
56+
5457
/** @var \Dom\XMLDocument */
5558
private static Dom\XMLDocument $subject;
5659

@@ -72,6 +75,10 @@ public function setup(): void
7275
dirname(__FILE__, 4) . '/resources/xml/saml_Subject.xml',
7376
);
7477

78+
self::$xmlRepresentationBaseId = DOMDocumentFactory::fromFile(
79+
dirname(__FILE__, 4) . '/resources/xml/saml_Subject_BaseID.xml',
80+
);
81+
7582
self::$subject = DOMDocumentFactory::fromString(
7683
<<<XML
7784
<saml:Subject xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"></saml:Subject>
@@ -245,7 +252,7 @@ public function testMarshallingBaseID(): void
245252
new SubjectConfirmation(
246253
SAMLAnyURIValue::fromString('urn:oasis:names:tc:SAML:2.0:cm:bearer'),
247254
new NameID(
248-
value: SAMLStringValue::fromString('SomeNameIDValue'),
255+
value: SAMLStringValue::fromString('SomeOtherNameIDValue'),
249256
SPNameQualifier: SAMLStringValue::fromString(
250257
'https://sp.example.org/authentication/sp/metadata',
251258
),
@@ -267,7 +274,7 @@ public function testMarshallingBaseID(): void
267274
SubjectConfirmation::fromXML(self::$subjectConfirmation->documentElement)->toXML($document->documentElement);
268275

269276
$this->assertEquals(
270-
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
277+
self::$xmlRepresentationBaseId->saveXML(self::$xmlRepresentationBaseId->documentElement),
271278
strval($subject),
272279
);
273280
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<saml:Subject xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:test="urn:test:something" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
2+
<saml:BaseID NameQualifier="urn:x-simplesamlphp:namequalifier" SPNameQualifier="urn:x-simplesamlphp:spnamequalifier" xsi:type="ssp:CustomBaseIDType">
3+
<saml:Audience>urn:some:audience</saml:Audience>
4+
</saml:BaseID>
5+
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
6+
<saml:NameID SPNameQualifier="https://sp.example.org/authentication/sp/metadata" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">SomeOtherNameIDValue</saml:NameID>
7+
<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">
8+
<ds:KeyInfo>
9+
<ds:KeyName>SomeKey</ds:KeyName>
10+
</ds:KeyInfo>
11+
<some>Arbitrary Element</some>
12+
</saml:SubjectConfirmationData>
13+
</saml:SubjectConfirmation>
14+
</saml:Subject>

0 commit comments

Comments
 (0)