-
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
9 changed files
with
309 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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\sp; | ||
|
||
use SimpleSAML\Assert\Assert; | ||
|
||
/** | ||
* An KerberosToken element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class KerberosToken extends AbstractTokenAssertionType | ||
{ | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\sp; | ||
|
||
use SimpleSAML\Assert\Assert; | ||
|
||
/** | ||
* An SecurityContextToken element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class SecurityContextToken extends AbstractTokenAssertionType | ||
{ | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\sp; | ||
|
||
use SimpleSAML\Assert\Assert; | ||
|
||
/** | ||
* An X509Token element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class X509Token extends AbstractTokenAssertionType | ||
{ | ||
} |
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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\sp; | ||
|
||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\Utils\XPath; | ||
use SimpleSAML\WSSecurity\XML\sp\IncludeToken; | ||
use SimpleSAML\WSSecurity\XML\sp\KerberosToken; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\WSSecurity\XML\sp\KerberosTokenTest | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\KerberosToken | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class KerberosTokenTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-securitypolicy-1.2.xsd'; | ||
|
||
self::$testedClass = KerberosToken::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/sp_KerberosToken.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Adding an empty KerberosToken element should yield an empty element. | ||
*/ | ||
public function testMarshallingEmptyElement(): void | ||
{ | ||
$spns = C::NS_SEC_POLICY; | ||
$kerberosToken = new KerberosToken(); | ||
$this->assertEquals( | ||
"<sp:KerberosToken xmlns:sp=\"$spns\"/>", | ||
strval($kerberosToken), | ||
); | ||
$this->assertTrue($kerberosToken->isEmptyElement()); | ||
} | ||
|
||
|
||
/** | ||
* Test that creating a KerberosToken from scratch works. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); | ||
$chunk = new Chunk(DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>' | ||
)->documentElement); | ||
|
||
$kerberosToken = new KerberosToken(IncludeToken::Always, [$chunk], [$attr]); | ||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($kerberosToken), | ||
); | ||
} | ||
} |
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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\sp; | ||
|
||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\Utils\XPath; | ||
use SimpleSAML\WSSecurity\XML\sp\IncludeToken; | ||
use SimpleSAML\WSSecurity\XML\sp\SecurityContextToken; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\WSSecurity\XML\sp\SecurityContextTokenTest | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\SecurityContextToken | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class SecurityContextTokenTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-securitypolicy-1.2.xsd'; | ||
|
||
self::$testedClass = SecurityContextToken::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/sp_SecurityContextToken.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Adding an empty SecurityContextToken element should yield an empty element. | ||
*/ | ||
public function testMarshallingEmptyElement(): void | ||
{ | ||
$spns = C::NS_SEC_POLICY; | ||
$securityContextToken = new SecurityContextToken(); | ||
$this->assertEquals( | ||
"<sp:SecurityContextToken xmlns:sp=\"$spns\"/>", | ||
strval($securityContextToken), | ||
); | ||
$this->assertTrue($securityContextToken->isEmptyElement()); | ||
} | ||
|
||
|
||
/** | ||
* Test that creating a SecurityContextToken from scratch works. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); | ||
$chunk = new Chunk(DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>' | ||
)->documentElement); | ||
|
||
$securityContextToken = new SecurityContextToken(IncludeToken::Always, [$chunk], [$attr]); | ||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($securityContextToken), | ||
); | ||
} | ||
} |
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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\sp; | ||
|
||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\Utils\XPath; | ||
use SimpleSAML\WSSecurity\XML\sp\IncludeToken; | ||
use SimpleSAML\WSSecurity\XML\sp\X509Token; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\WSSecurity\XML\sp\X509lTokenTest | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\X509Token | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType | ||
* @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class X509TokenTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-securitypolicy-1.2.xsd'; | ||
|
||
self::$testedClass = X509Token::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/sp_X509Token.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Adding an empty X509lToken element should yield an empty element. | ||
*/ | ||
public function testMarshallingEmptyElement(): void | ||
{ | ||
$spns = C::NS_SEC_POLICY; | ||
$x509Token = new X509Token(); | ||
$this->assertEquals( | ||
"<sp:X509Token xmlns:sp=\"$spns\"/>", | ||
strval($x509Token), | ||
); | ||
$this->assertTrue($x509Token->isEmptyElement()); | ||
} | ||
|
||
|
||
/** | ||
* Test that creating a X509Token from scratch works. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); | ||
$chunk = new Chunk(DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>' | ||
)->documentElement); | ||
|
||
$x509Token = new X509Token(IncludeToken::Always, [$chunk], [$attr]); | ||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($x509Token), | ||
); | ||
} | ||
} |
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,3 @@ | ||
<sp:KerberosToken xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:ssp="urn:x-simplesamlphp:namespace" IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Always" ssp:attr1="value1"> | ||
<ssp:Chunk>some</ssp:Chunk> | ||
</sp:KerberosToken> |
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,3 @@ | ||
<sp:SecurityContextToken xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:ssp="urn:x-simplesamlphp:namespace" IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Always" ssp:attr1="value1"> | ||
<ssp:Chunk>some</ssp:Chunk> | ||
</sp:SecurityContextToken> |
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,3 @@ | ||
<sp:X509Token xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:ssp="urn:x-simplesamlphp:namespace" IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Always" ssp:attr1="value1"> | ||
<ssp:Chunk>some</ssp:Chunk> | ||
</sp:X509Token> |