-
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
5 changed files
with
147 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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\SAML11\XML\saml; | ||
|
||
use DOMElement; | ||
use SimpleSAML\Assert\Assert; | ||
use SimpleSAML\SAML11\XML\saml\AbstractConditionType; | ||
use SimpleSAML\SAML11\Constants as C; | ||
use SimpleSAML\XML\Exception\InvalidDOMElementException; | ||
use SimpleSAML\XML\Exception\MissingElementException; | ||
use SimpleSAML\XML\Exception\SchemaViolationException; | ||
|
||
use function array_pop; | ||
|
||
/** | ||
* @package simplesamlphp\saml11 | ||
*/ | ||
abstract class AbstractDoNotCacheConditionType extends AbstractConditionType | ||
{ | ||
/** | ||
* DoNotCacheConditionType constructor. | ||
*/ | ||
public function __construct( | ||
) { | ||
} | ||
|
||
|
||
/** | ||
* Convert XML into a DoNotCacheCondition | ||
* | ||
* @param \DOMElement $xml The XML element we should load | ||
* @return static | ||
* | ||
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException | ||
* if the qualified name of the supplied element is wrong | ||
*/ | ||
public static function fromXML(DOMElement $xml): static | ||
{ | ||
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); | ||
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); | ||
|
||
return new static(); | ||
} | ||
|
||
|
||
/** | ||
* Convert this DoNotCacheCondition to XML. | ||
* | ||
* @param \DOMElement $parent The element we are converting to XML. | ||
* @return \DOMElement The XML element after adding the data corresponding to this DoNotCacheCondition. | ||
*/ | ||
public function toXML(DOMElement $parent = null): DOMElement | ||
{ | ||
return $this->instantiateParentElement($parent); | ||
} | ||
} |
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\SAML11\XML\saml; | ||
|
||
/** | ||
* Class representing a saml:DoNotCacheCondition element. | ||
* | ||
* @package simplesamlphp/saml11 | ||
*/ | ||
final class DoNotCacheCondition extends AbstractDoNotCacheConditionType | ||
{ | ||
} |
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\SAML11\XML\saml; | ||
|
||
/** | ||
* Class representing a saml:DoNotCacheCondition element. | ||
* | ||
* @package simplesamlphp/saml11 | ||
*/ | ||
final class DoNotCacheCondition extends AbstractConditionType | ||
{ | ||
} |
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:DoNotCacheCondition xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" /> |
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\Test\SAML11\XML\saml; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\SAML11\XML\saml\DoNotCacheCondition; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Tests for DoNotCacheCondition elements. | ||
* | ||
* @covers \SimpleSAML\SAML11\XML\saml\DoNotCacheCondition | ||
* @covers \SimpleSAML\SAML11\XML\saml\AbstractConditionType | ||
* @covers \SimpleSAML\SAML11\XML\saml\AbstractSamlElement | ||
* | ||
* @package simplesamlphp/saml11 | ||
*/ | ||
final class DoNotCacheConditionTest 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 = DoNotCacheCondition::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 5) . '/resources/xml/saml_DoNotCacheCondition.xml', | ||
); | ||
} | ||
|
||
|
||
// marshalling | ||
|
||
|
||
/** | ||
* Test creating an DoNotCacheCondition from scratch | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$DoNotCacheCondition = new DoNotCacheCondition(); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($DoNotCacheCondition), | ||
); | ||
} | ||
} |