Skip to content

Commit 3392644

Browse files
committed
Add element xenc:P
1 parent 79d3329 commit 3392644

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

1

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
pick 7612dde Refactor ds:KeyInfo
2+
pick 396cecd Add element xenc:OriginatorKeyInfo
3+
pick 26d0811 Add element xenc:RecipientKeyInfo
4+
pick 3fbdc66 Add element xenc:AgreementMethod
5+
s 25beba4 Add element xenc:AgreementMethod
6+
7+
# Rebase 271d943..25beba4 onto 271d943 (5 commands)
8+
#
9+
# Commands:
10+
# p, pick <commit> = use commit
11+
# r, reword <commit> = use commit, but edit the commit message
12+
# e, edit <commit> = use commit, but stop for amending
13+
# s, squash <commit> = use commit, but meld into previous commit
14+
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
15+
# commit's log message, unless -C is used, in which case
16+
# keep only this commit's message; -c is same as -C but
17+
# opens the editor
18+
# x, exec <command> = run command (the rest of the line) using shell
19+
# b, break = stop here (continue rebase later with 'git rebase --continue')
20+
# d, drop <commit> = remove commit
21+
# l, label <label> = label current HEAD with a name
22+
# t, reset <label> = reset HEAD to a label
23+
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
24+
# create a merge commit using the original merge commit's
25+
# message (or the oneline, if no original merge commit was
26+
# specified); use -c <commit> to reword the commit message
27+
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
28+
# to this position in the new commits. The <ref> is
29+
# updated at the end of the rebase
30+
#
31+
# These lines can be re-ordered; they are executed from top to bottom.
32+
#
33+
# If you remove a line here THAT COMMIT WILL BE LOST.
34+
#
35+
# However, if you remove everything, the rebase will be aborted.
36+
#

src/XML/xenc/P.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\XML\xenc;
6+
7+
use SimpleSAML\XML\Base64ElementTrait;
8+
9+
/**
10+
* Class representing a xenc:P element.
11+
*
12+
* @package simplesaml/xml-security
13+
*/
14+
final class P extends AbstractXencElement
15+
{
16+
use Base64ElementTrait;
17+
18+
19+
/**
20+
* @param string $content
21+
*/
22+
public function __construct(string $content)
23+
{
24+
$this->setContent($content);
25+
}
26+
}

tests/XML/xenc/PTest.php

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Test\XML\xenc;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\Assert\AssertionFailedException;
10+
use SimpleSAML\XML\DOMDocumentFactory;
11+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12+
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
13+
use SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement;
14+
use SimpleSAML\XMLSecurity\XML\xenc\P;
15+
16+
use function dirname;
17+
use function strval;
18+
19+
/**
20+
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\PTest
21+
*
22+
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement
23+
* @covers \SimpleSAML\XMLSecurity\XML\xenc\P
24+
*
25+
* @package simplesamlphp/xml-security
26+
*/
27+
#[CoversClass(AbstractXencElement::class)]
28+
#[CoversClass(P::class)]
29+
final class PTest extends TestCase
30+
{
31+
use SerializableElementTestTrait;
32+
33+
/**
34+
*/
35+
public static function setUpBeforeClass(): void
36+
{
37+
self::$testedClass = P::class;
38+
39+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
40+
dirname(__FILE__, 3) . '/resources/xml/xenc_P.xml',
41+
);
42+
}
43+
44+
45+
/**
46+
*/
47+
public function testMarshalling(): void
48+
{
49+
$p = new P('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
50+
51+
$this->assertEquals(
52+
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
53+
strval($p),
54+
);
55+
}
56+
57+
58+
/**
59+
*/
60+
public function testMarshallingNotBase64(): void
61+
{
62+
$this->expectException(AssertionFailedException::class);
63+
new P('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
64+
}
65+
}

tests/resources/xml/xenc_P.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<xenc:P xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</xenc:P>

0 commit comments

Comments
 (0)