-
Notifications
You must be signed in to change notification settings - Fork 2
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
3 changed files
with
95 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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\XML\xenc; | ||
|
||
use SimpleSAML\XML\Base64ElementTrait; | ||
|
||
/** | ||
* Class representing a xenc:KA-Nonce element. | ||
* | ||
* @package simplesaml/xml-security | ||
*/ | ||
final class KANonce extends AbstractXencElement | ||
{ | ||
use Base64ElementTrait; | ||
|
||
/** @var string */ | ||
public const LOCALNAME = 'KA-Nonce'; | ||
|
||
|
||
/** | ||
* @param string $content | ||
*/ | ||
public function __construct(string $content) | ||
{ | ||
$this->setContent($content); | ||
} | ||
} |
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,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\Test\XML\xenc; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\Assert\AssertionFailedException; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper; | ||
use SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement; | ||
use SimpleSAML\XMLSecurity\XML\xenc\KANonce; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\KANonceTest | ||
* | ||
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement | ||
* @covers \SimpleSAML\XMLSecurity\XML\xenc\KANonce | ||
* | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
#[CoversClass(AbstractXencElement::class)] | ||
#[CoversClass(KANonce::class)] | ||
final class KANonceTest extends TestCase | ||
{ | ||
use SerializableElementTestTrait; | ||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$testedClass = KANonce::class; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 3) . '/resources/xml/xenc_KA-Nonce.xml', | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$kaNonce = new KANonce('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); | ||
|
||
$this->assertEquals( | ||
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation), | ||
strval($kaNonce), | ||
); | ||
} | ||
|
||
|
||
/** | ||
*/ | ||
public function testMarshallingNotBase64(): void | ||
{ | ||
$this->expectException(AssertionFailedException::class); | ||
new KANonce('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); | ||
} | ||
} |
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 @@ | ||
<xenc:KA-Nonce xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</xenc:KA-Nonce> |