Skip to content

Commit e04cc05

Browse files
committed
Fix typo for AuthnRequest Assertion namespace
1 parent ebef6bc commit e04cc05

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/Net/SAML2/Protocol/AuthnRequest.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Returns the AuthnRequest as XML.
192192
=cut
193193

194194
my $samlp = ['samlp' => URN_PROTOCOL];
195-
my $saml = ['samlp' => URN_ASSERTION];
195+
my $saml = ['saml' => URN_ASSERTION];
196196

197197
sub as_xml {
198198
my ($self) = @_;

t/25-verify-authn-post-sign_xml.t

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use strict;
2+
use warnings;
3+
use Net::SAML2;
4+
use MIME::Base64 qw/decode_base64/;
5+
use XML::LibXML;
6+
7+
use Test::Lib;
8+
use Test::Net::SAML2;
9+
my $sp = net_saml2_sp();
10+
11+
my $metadata = path('t/idp-metadata.xml')->slurp;
12+
13+
my $idp = Net::SAML2::IdP->new_from_xml(
14+
xml => $metadata,
15+
cacert => 't/cacert.pem'
16+
);
17+
18+
my $authn = $sp->authn_request(
19+
$idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'),
20+
$idp->format || '', # default format.
21+
)->as_xml();
22+
23+
my $post = $sp->sp_post_binding($idp, 'SAMLRequest');
24+
25+
my $signed = decode_base64($post->sign_xml($authn));
26+
27+
my $dom = XML::LibXML->load_xml( string => $signed );
28+
29+
my $parser = XML::LibXML::XPathContext->new($dom);
30+
$parser->registerNs('saml2p', 'urn:oasis:names:tc:SAML:2.0:protocol');
31+
$parser->registerNs('saml2', 'urn:oasis:names:tc:SAML:2.0:assertion');
32+
$parser->registerNs('dsig', 'http://www.w3.org/2000/09/xmldsig#');
33+
ok($parser->exists('//dsig:Signature'), "The XML is now signed");
34+
35+
done_testing;

0 commit comments

Comments
 (0)