-
Notifications
You must be signed in to change notification settings - Fork 5
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
92 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
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\adfs\SAML11\XML\saml; | ||
|
||
use SimpleSAML\XML\StringElementTrait; | ||
|
||
/** | ||
* SAML Audience element. | ||
* | ||
* @package simplesamlphp/simplesamlphp-module-adfs | ||
*/ | ||
|
||
final class Audience extends AbstractSamlElement | ||
{ | ||
use StringElementTrait; | ||
|
||
|
||
/** | ||
* Initialize a saml:Action from scratch | ||
* | ||
* @param string $value | ||
*/ | ||
public function __construct( | ||
protected string $value | ||
) { | ||
$this->setContent($value); | ||
} | ||
} |
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 @@ | ||
<saml:Audience xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">urn:x-simplesamlphp:audience</saml:Audience> |
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Module\adfs\Test\SAML11\XML\saml; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Module\adfs\SAML11\XML\saml\Audience; | ||
use SimpleSAML\XML\Chunk; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Tests for Audience elements. | ||
* | ||
* @covers \SimpleSAML\Module\adfs\SAML11\XML\saml\Audience | ||
* @covers \SimpleSAML\Module\adfs\SAML11\XML\saml\AbstractSamlElement | ||
* | ||
* @package simplesamlphp/simplesamlphp-module-adfs | ||
*/ | ||
final class AudienceTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$schemaFile = dirname(__FILE__, 6) . '/resources/schemas/oasis-sstc-saml-schema-assertion-1.1.xsd'; | ||
|
||
self::$testedClass = Audience::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 5) . '/resources/xml/saml_Audience.xml', | ||
); | ||
} | ||
|
||
|
||
// marshalling | ||
|
||
|
||
/** | ||
* Test creating an Audience from scratch | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$audience = new Audience('urn:x-simplesamlphp:audience'); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($audience), | ||
); | ||
} | ||
} |