-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\wst; | ||
|
||
/** | ||
* A IssuedTokens element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class IssuedTokens extends AbstractRequestSecurityTokenResponseCollectionType | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\wst; | ||
|
||
use SimpleSAML\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\XML\wsa\AbstractEndpointReferenceType; | ||
|
||
/** | ||
* An Issuer element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class Issuer extends AbstractEndpointReferenceType | ||
{ | ||
/** @var string */ | ||
public const NS = C::NS_TRUST; | ||
|
||
/** @var string */ | ||
public const NS_PREFIX = 'wst'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\wst; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\SOAP\Constants as SOAP; | ||
use SimpleSAML\Test\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\XML\wsa\MessageID; | ||
use SimpleSAML\WSSecurity\XML\wst\RequestSecurityTokenResponse; | ||
use SimpleSAML\WSSecurity\XML\wst\IssuedTokens; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\WSSecurity\XML\wst\IssuedTokensTest | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\wst\IssuedTokens | ||
* @covers \SimpleSAML\WSSecurity\XML\wst\AbstractIssuedTokensType | ||
* @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class IssuedTokensTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-trust.xsd'; | ||
|
||
self::$testedClass = IssuedTokens::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/wst_IssuedTokens.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Test creating a IssuedTokens object from scratch. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr1 = new XMLAttribute(SOAP::NS_SOAP_ENV_11, 'soapenv', 'mustUnderstand', '1'); | ||
$attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'testval1'); | ||
$attr3 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'testval2'); | ||
$msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$attr1]); | ||
|
||
$requestSecurityTokenResponse = new RequestSecurityTokenResponse(C::NAMESPACE, [$msgId], [$attr2]); | ||
|
||
$issuedTokens = new IssuedTokens( | ||
[$requestSecurityTokenResponse], | ||
[$attr3], | ||
); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($issuedTokens), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\wst; | ||
|
||
use DOMElement; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\WSSecurity\XML\wst\Issuer; | ||
use SimpleSAML\WSSecurity\XML\wsa\Address; | ||
use SimpleSAML\WSSecurity\XML\wsa\Metadata; | ||
use SimpleSAML\WSSecurity\XML\wsa\ReferenceParameters; | ||
use SimpleSAML\XML\Attribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Tests for wst:Issuer. | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\wst\Issuer | ||
* @covers \SimpleSAML\WSSecurity\XML\wsa\AbstractEndpointReferenceType | ||
* @covers \SimpleSAML\WSSecurity\XML\wsa\AbstractWsaElement | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class IssuerTest extends TestCase | ||
{ | ||
use SerializableElementTestTrait; | ||
|
||
/** @var \DOMElement $referenceParametersContent */ | ||
protected static DOMElement $referenceParametersContent; | ||
|
||
/** @var \DOMElement $metadataContent */ | ||
protected static DOMElement $metadataContent; | ||
|
||
/** @var \DOMElement $customContent */ | ||
protected static DOMElement $customContent; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$testedClass = Issuer::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::FromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/wst_Issuer.xml' | ||
); | ||
|
||
self::$referenceParametersContent = DOMDocumentFactory::fromString( | ||
'<m:GetPrice xmlns:m="https://www.w3schools.com/prices"><m:Item>Pears</m:Item></m:GetPrice>' | ||
)->documentElement; | ||
|
||
self::$metadataContent = DOMDocumentFactory::fromString( | ||
'<m:GetPrice xmlns:m="https://www.w3schools.com/prices"><m:Item>Apples</m:Item></m:GetPrice>' | ||
)->documentElement; | ||
|
||
self::$customContent = DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>' | ||
)->documentElement; | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Test creating an Issuer object from scratch. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', 'value1'); | ||
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', 'value2'); | ||
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', 'value3'); | ||
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', 'value4'); | ||
|
||
$referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]); | ||
$metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]); | ||
$chunk = new Chunk(self::$customContent); | ||
|
||
$issuer = new Issuer( | ||
new Address('https://login.microsoftonline.com/login.srf', [$attr2]), | ||
[$referenceParameters], | ||
[$metadata], | ||
[$chunk], | ||
[$attr1], | ||
); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($issuer) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<wst:IssuedTokens xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512/" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr2="testval2"> | ||
<wst:RequestSecurityTokenResponse Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> | ||
<wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> | ||
</wst:RequestSecurityTokenResponse> | ||
</wst:IssuedTokens> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<wst:IssuedTokens xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512/" xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ssp:attr2="testval2"> | ||
<wst:RequestSecurityTokenResponse Context="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> | ||
<wsa:MessageID soapenv:mustUnderstand="1">uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de</wsa:MessageID> | ||
</wst:RequestSecurityTokenResponse> | ||
</wst:IssuedTokens> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<wst:Issuer xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512/" xmlns:ssp="urn:x-simplesamlphp:namespace" ssp:test1="value1"> | ||
<wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test2="value2">https://login.microsoftonline.com/login.srf</wsa:Address> | ||
<wsa:ReferenceParameters xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test4="value4"> | ||
<m:GetPrice xmlns:m="https://www.w3schools.com/prices"> | ||
<m:Item>Pears</m:Item> | ||
</m:GetPrice> | ||
</wsa:ReferenceParameters> | ||
<wsa:Metadata xmlns:wsa="http://www.w3.org/2005/08/addressing" ssp:test3="value3"> | ||
<m:GetPrice xmlns:m="https://www.w3schools.com/prices"> | ||
<m:Item>Apples</m:Item> | ||
</m:GetPrice> | ||
</wsa:Metadata> | ||
<ssp:Chunk>SomeChunk</ssp:Chunk> | ||
</wst:Issuer> |