Skip to content

Commit

Permalink
saml11 elements
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Feb 13, 2024
1 parent e2234b4 commit 9562897
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SAML11/XML/saml/AbstractActionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use SimpleSAML\XML\StringElementTrait;

/**
* SAML AttributeType abstract data type.
* SAML ActionType abstract data type.
*
* @package simplesamlphp/simplesamlphp-module-adfs
*/
Expand Down
30 changes: 30 additions & 0 deletions src/SAML11/XML/saml/Audience.php
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);
}
}
1 change: 1 addition & 0 deletions tests/resources/xml/saml_Audience.xml
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>
60 changes: 60 additions & 0 deletions tests/src/SAML11/XML/saml/AudienceTest.php
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),
);
}
}

0 comments on commit 9562897

Please sign in to comment.