-
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
8 changed files
with
285 additions
and
3 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
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\auth; | ||
|
||
/** | ||
* Class representing WS-authorization ValueInRangen. | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class ValueInRangen extends AbstractValueInRangeType | ||
{ | ||
} |
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\auth; | ||
|
||
/** | ||
* Class representing WS-authorization ValueOneOf. | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class ValueOneOf extends AbstractConstrainedManyValueType | ||
{ | ||
} |
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\auth; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Assert\AssertionFailedException; | ||
use SimpleSAML\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\XML\auth\StructuredValue; | ||
use SimpleSAML\WSSecurity\XML\auth\Value; | ||
use SimpleSAML\WSSecurity\XML\auth\ValueOneOf; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
|
||
/** | ||
* Tests for auth:ConstrainedManyValueType. | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractConstrainedManyValueType | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractAuthElement | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class ConstrainedManyValueTest extends TestCase | ||
{ | ||
/** | ||
* Test creating an object from scratch. | ||
* | ||
* @param class-string $class | ||
* | ||
* @dataProvider classProvider | ||
*/ | ||
public function testMarshallingEmpty(string $class): void | ||
{ | ||
$x = new $class([], []); | ||
$this->assertTrue($x->isEmptyElement()); | ||
} | ||
|
||
|
||
/** | ||
* Test creating an object from scratch with both Value and StructuredValue. | ||
* | ||
* @param class-string $class | ||
* | ||
* @dataProvider classProvider | ||
*/ | ||
public function testMarshallingIllegalCombination(string $class): void | ||
{ | ||
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'); | ||
$child = DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>', | ||
); | ||
|
||
$structuredValue = new StructuredValue( | ||
[new Chunk($child->documentElement)], | ||
[$attr1], | ||
); | ||
|
||
$value = new Value('MyValue'); | ||
|
||
$this->expectException(AssertionFailedException::class); | ||
new $class([$value], [$structuredValue]); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public static function classProvider(): array | ||
{ | ||
return [ | ||
'auth:ValueOneOf' => [ValueOneOf::class], | ||
]; | ||
} | ||
} |
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,92 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\auth; | ||
|
||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Assert\AssertionFailedException; | ||
use SimpleSAML\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\XML\auth\StructuredValue; | ||
use SimpleSAML\WSSecurity\XML\auth\Value; | ||
use SimpleSAML\WSSecurity\XML\auth\ValueInRangen; | ||
use SimpleSAML\WSSecurity\XML\auth\ValueLowerBound; | ||
use SimpleSAML\WSSecurity\XML\auth\ValueUpperBound; | ||
use SimpleSAML\XML\Attribute as XMLAttribute; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Tests for auth:ValueInRangen. | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\ValueInRangen | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractValueInRangeType | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractAuthElement | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class ValueInRangenTest extends TestCase | ||
{ | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$testedClass = ValueInRangen::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/auth_ValueInRangen.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Test creating a ValueInRangen object from scratch. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'); | ||
$child = DOMDocumentFactory::fromString( | ||
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">SomeChunk</ssp:Chunk>', | ||
); | ||
|
||
$structuredValue = new StructuredValue( | ||
[new Chunk($child->documentElement)], | ||
[$attr1], | ||
); | ||
|
||
$valueUpperBound = new ValueUpperBound(null, $structuredValue); | ||
$valueLowerBound = new ValueLowerBound(new Value('MyValue'), null); | ||
$valueInRangen = new ValueInRangen($valueUpperBound, $valueLowerBound); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($valueInRangen), | ||
); | ||
} | ||
|
||
|
||
// test unmarshalling | ||
|
||
|
||
/** | ||
* Test creating a ValueInRangen from XML. | ||
*/ | ||
public function testUnmarshalling(): void | ||
{ | ||
$valueInRangen = ValueInRangen::fromXML(self::$xmlRepresentation->documentElement); | ||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($valueInRangen), | ||
); | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\auth; | ||
|
||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Assert\AssertionFailedException; | ||
use SimpleSAML\WSSecurity\Constants; | ||
use SimpleSAML\WSSecurity\XML\auth\Value; | ||
use SimpleSAML\WSSecurity\XML\auth\ValueOneOf; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Tests for auth:Value. | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\ValueOneOf | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractConstrainedManyValueType | ||
* @covers \SimpleSAML\WSSecurity\XML\auth\AbstractAuthElement | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class ValueOneOfTest extends TestCase | ||
{ | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$testedClass = ValueOneOf::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/auth_ValueOneOf.xml' | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Test creating a ValueOneOf object from scratch. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$value1 = new Value('MyValue'); | ||
$value2 = new Value('MyOtherValue'); | ||
$valueOneOf = new ValueOneOf([$value1, $value2]); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($valueOneOf), | ||
); | ||
} | ||
|
||
|
||
// test unmarshalling | ||
|
||
|
||
/** | ||
* Test creating a ValueOneOf from XML. | ||
*/ | ||
public function testUnmarshalling(): void | ||
{ | ||
$valueOneOf = ValueOneOf::fromXML(self::$xmlRepresentation->documentElement); | ||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($valueOneOf), | ||
); | ||
} | ||
} |
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,10 @@ | ||
<auth:ValueInRangen xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706"> | ||
<auth:ValueUpperBound> | ||
<auth:StructuredValue xmlns:ssp="urn:x-simplesamlphp:namespace" ssp:attr1="testval1"> | ||
<ssp:Chunk>SomeChunk</ssp:Chunk> | ||
</auth:StructuredValue> | ||
</auth:ValueUpperBound> | ||
<auth:ValueLowerBound> | ||
<auth:Value>MyValue</auth:Value> | ||
</auth:ValueLowerBound> | ||
</auth:ValueInRangen> |
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,4 @@ | ||
<auth:ValueOneOf xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706"> | ||
<auth:Value>MyValue</auth:Value> | ||
<auth:Value>MyOtherValue</auth:Value> | ||
</auth:ValueOneOf> |