File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ Returns the AuthnRequest as XML.
192
192
=cut
193
193
194
194
my $samlp = [' samlp' => URN_PROTOCOL];
195
- my $saml = [' samlp ' => URN_ASSERTION];
195
+ my $saml = [' saml ' => URN_ASSERTION];
196
196
197
197
sub as_xml {
198
198
my ($self ) = @_ ;
Original file line number Diff line number Diff line change
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;
You can’t perform that action at this time.
0 commit comments