Skip to content

Commit 3de8544

Browse files
committed
Tests: Add InclusiveNamespaces handling in signature template
Enhanced existing test cases to include InclusiveNamespaces handling in the signature template. Each test case that verifies the signature now includes a Transform element with InclusiveNamespaces and a PrefixList attribute.
1 parent e229702 commit 3de8544

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

t/js_saml.t

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ sub digest_saml {
13341334
$xpc->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
13351335
$xpc->registerNs('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
13361336
$xpc->registerNs('ds', 'http://www.w3.org/2000/09/xmldsig#');
1337+
$xpc->registerNs('ec', 'http://www.w3.org/2001/10/xml-exc-c14n#');
13371338

13381339
my $parent_node = $signature_node->parentNode;
13391340

@@ -1351,6 +1352,12 @@ sub digest_saml {
13511352

13521353
my $with_comments = ($transform_algs[1] =~ /WithComments/);
13531354

1355+
my ($inclusive_ns) =
1356+
$xpc->findnodes('./ec:InclusiveNamespaces', $transforms[1]);
1357+
my $prefix_list = $inclusive_ns
1358+
? [split ' ', $inclusive_ns->getAttribute('PrefixList')]
1359+
: undef;
1360+
13541361
my $digest_method =
13551362
$xpc->findnodes('./ds:DigestMethod', $reference_node)->[0];
13561363
my $alg = $digest_method->getAttribute('Algorithm');
@@ -1359,7 +1366,8 @@ sub digest_saml {
13591366

13601367
my $next_sibling = $signature_node->nextSibling();
13611368
$signature_node->unbindNode();
1362-
my $parent_node_c14n = $parent_node->toStringEC14N($with_comments);
1369+
my $parent_node_c14n =
1370+
$parent_node->toStringEC14N($with_comments, undef, $xpc, $prefix_list);
13631371
$parent_node->insertBefore($signature_node, $next_sibling);
13641372

13651373
my %hash_func_map = (
@@ -1455,7 +1463,6 @@ sub signature_saml {
14551463
}
14561464

14571465
return $result;
1458-
14591466
}
14601467

14611468
sub get_time {
@@ -1520,7 +1527,9 @@ sub gen_tmpl {
15201527
<ds:Reference URI="#${id}">
15211528
<ds:Transforms>
15221529
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
1523-
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
1530+
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
1531+
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="xs example"/>
1532+
</ds:Transform>
15241533
</ds:Transforms>
15251534
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
15261535
<ds:DigestValue></ds:DigestValue>
@@ -1606,7 +1615,7 @@ END_XML
16061615
</saml:Attribute>
16071616
<saml:Attribute Name="http://schemas.example.com/identity/claims/foo"
16081617
>
1609-
<saml:AttributeValue xsi:type="xs:string">bar</saml:AttributeValue>
1618+
<saml:AttributeValue xsi:type="example:string">bar</saml:AttributeValue>
16101619
</saml:Attribute>
16111620
</saml:AttributeStatement>
16121621
</saml:Assertion>

0 commit comments

Comments
 (0)