-
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
4 changed files
with
106 additions
and
1 deletion.
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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\WSSecurity\XML\fed; | ||
|
||
use DOMElement; | ||
use SimpleSAML\Assert\Assert; | ||
use SimpleSAML\XML\Exception\InvalidDOMElementException; | ||
use SimpleSAML\XML\StringElementTrait; | ||
|
||
use function sprintf; | ||
|
||
/** | ||
* A Realm element | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class Realm extends AbstractFedElement | ||
{ | ||
use StringElementTrait; | ||
|
||
|
||
/** | ||
* @param string $content | ||
*/ | ||
public function __construct(string $content) | ||
{ | ||
$this->setContent($content); | ||
} | ||
|
||
|
||
/** | ||
* Validate the content of the element. | ||
* | ||
* @param string $content The value to go in the XML textContent | ||
* @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure | ||
* @return void | ||
*/ | ||
protected function validateContent(string $content): void | ||
{ | ||
Assert::validURI($content, SchemaViolationException::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
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\WSSecurity\XML\sp; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Test\WSSecurity\Constants as C; | ||
use SimpleSAML\WSSecurity\XML\fed\Realm; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
|
||
/** | ||
* Class \SimpleSAML\WSSecurity\XML\fed\RealmTest | ||
* | ||
* @covers \SimpleSAML\WSSecurity\XML\fed\Realm | ||
* @covers \SimpleSAML\WSSecurity\XML\fed\AbstractFedElement | ||
* | ||
* @package tvdijen/ws-security | ||
*/ | ||
final class RealmTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 5) . '/resources/schemas/ws-federation.xsd'; | ||
|
||
self::$testedClass = Realm::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 4) . '/resources/xml/fed_Realm.xml', | ||
); | ||
} | ||
|
||
|
||
// test marshalling | ||
|
||
|
||
/** | ||
* Test creating a Realm object from scratch. | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$realm = new Realm(C::NAMESPACE); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($realm), | ||
); | ||
} | ||
} |
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 @@ | ||
<fed:Realm xmlns:fed="http://docs.oasis-open.org/wsfed/federation/200706">urn:x-simplesamlphp:namespace</fed:Realm> |