@@ -11,9 +11,8 @@ my $xpath = get_xpath(
1111 ds => ' http://www.w3.org/2000/09/xmldsig#'
1212);
1313
14- my $nodes = $xpath -> findnodes(' //md:EntityDescriptor/md:SPSSODescriptor' );
15- is($nodes -> size, 1, " We have one PSSODescriptor" );
16- my $node = $nodes -> get_node(1);
14+ my $node
15+ = get_single_node_ok($xpath , ' //md:EntityDescriptor/md:SPSSODescriptor' );
1716ok(!$node -> getAttribute(' WantAssertionsSigned' ),
1817 ' Wants assertions to be signed' );
1918ok(
@@ -37,54 +36,129 @@ if (is(@ssos, 2, "Got two assertionConsumerService(s)")) {
3736 );
3837}
3938
39+ get_single_node_ok($xpath , ' //ds:Signature' );
40+
41+ {
42+ my $sp = net_saml2_sp(sign_metadata => 0);
43+ my $xpath = get_xpath(
44+ $sp -> metadata,
45+ md => ' urn:oasis:names:tc:SAML:2.0:metadata' ,
46+ ds => ' http://www.w3.org/2000/09/xmldsig#'
47+ );
48+
49+ my $nodes = $xpath -> findnodes(' //ds:Signature' );
50+ is($nodes -> size(), 0, " We don't have any ds:Signature present" );
51+
52+ }
53+
4054{
4155 my $sp = Net::SAML2::SP-> new(
42- id => ' http://localhost:3000' ,
43- url => ' http://localhost:3000' ,
44- cert => ' t/sign-nopw-cert.pem' ,
45- key => ' t/sign-nopw-cert.pem' ,
46- cacert => ' t/cacert.pem' ,
47- org_name => ' Test' ,
48- org_display_name => ' Test' ,
56+ id => ' Some entity ID' ,
57+ url => ' http://localhost:3000' ,
58+ cert => ' t/sign-nopw-cert.pem' ,
59+ key => ' t/sign-nopw-cert.pem' ,
60+ cacert => ' t/cacert.pem' ,
61+
62+ org_name => ' Net::SAML2::SP' ,
63+ org_display_name => ' Net::SAML2::SP testsuite' ,
4964 org_contact => ' test@example.com' ,
65+
5066 org_url => ' http://www.example.com' ,
5167 slo_url_soap => ' /slo-soap' ,
5268 slo_url_redirect => ' /sls-redirect-response' ,
5369 slo_url_post => ' /sls-post-response' ,
5470 acs_url_post => ' /consumer-post' ,
5571 acs_url_artifact => ' /consumer-artifact' ,
56- org_name => ' Net::SAML2 Saml2Test' ,
57- org_display_name => ' Saml2Test app for Net::SAML2' ,
58- org_contact => ' saml2test@example.com' ,
5972 error_url => ' /error' ,
6073 );
6174
62- my $xpath = get_xpath($sp -> metadata,
63- md => ' urn:oasis:names:tc:SAML:2.0:metadata' );
64- my $nodes = $xpath -> findnodes(' //md:EntityDescriptor/md:SPSSODescriptor' );
65- is($nodes -> size, 1, " We have one PSSODescriptor" );
66- my $node = $nodes -> get_node(1);
67- ok($node -> getAttribute(' WantAssertionsSigned' ),
68- ' Wants assertions to be signed' );
69- ok(
70- $node -> getAttribute(' AuthnRequestsSigned' ),
71- ' .. and also authn requests to be signed'
72- );
73- }
74-
75- $nodes = $xpath -> findnodes(' //ds:Signature' );
76- is($nodes -> size(), 1, " We have a signed metadata document ds:Signature present" );
77-
78- {
79- my $sp = net_saml2_sp(sign_metadata => 0);
8075 my $xpath = get_xpath(
8176 $sp -> metadata,
8277 md => ' urn:oasis:names:tc:SAML:2.0:metadata' ,
8378 ds => ' http://www.w3.org/2000/09/xmldsig#'
8479 );
8580
86- my $nodes = $xpath -> findnodes(' //ds:Signature' );
87- is($nodes -> size(), 0, " We don't have any ds:Signature present" );
81+ my $node = get_single_node_ok($xpath , ' /md:EntityDescriptor' );
82+ is(
83+ $node -> getAttribute(' entityID' ),
84+ ' Some entity ID' ,
85+ ' .. has the correct entity ID'
86+ );
87+
88+ ok($node -> getAttribute(' ID' ), ' .. has an ID' );
89+
90+ {
91+ # Test ContactPerson
92+ my $node = get_single_node_ok($xpath , ' /node()/md:ContactPerson' );
93+ my $p = $node -> nodePath();
94+
95+ my $company = get_single_node_ok($xpath , " $p /md:Company" );
96+ is(
97+ $company -> textContent,
98+ ' Net::SAML2::SP testsuite' ,
99+ " Got the correct company name for the contact person"
100+ );
101+
102+ my $email = get_single_node_ok($xpath , " $p /md:EmailAddress" );
103+ is($email -> textContent, ' test@example.com' ,
104+ " .. and the correct email" );
105+ }
106+
107+ {
108+ # Test Organisation
109+ my $node = get_single_node_ok($xpath , ' /node()/md:Organization' );
110+ my $p = $node -> nodePath();
111+
112+ my $name = get_single_node_ok($xpath , " $p /md:OrganizationName" );
113+ is($name -> textContent, ' Net::SAML2::SP' ,
114+ " Got the correct company name" );
115+
116+ my $display_name
117+ = get_single_node_ok($xpath , " $p /md:OrganizationDisplayName" );
118+ is(
119+ $display_name -> textContent,
120+ ' Net::SAML2::SP testsuite' ,
121+ " .. and the correct display name"
122+ );
123+
124+ my $url = get_single_node_ok($xpath , " $p /md:OrganizationURL" );
125+ is($url -> textContent, ' http://www.example.com' ,
126+ " .. and the correct URI" );
127+ }
128+
129+ {
130+ # Test SPSSODescriptor
131+ my $node = get_single_node_ok($xpath , ' /node()/md:SPSSODescriptor' );
132+ is($node -> getAttribute(' AuthnRequestsSigned' ),
133+ ' 1' , ' .. and authn request needs signing' );
134+ is($node -> getAttribute(' WantAssertionsSigned' ),
135+ ' 1' , ' .. as does assertions' );
136+ is($node -> getAttribute(' errorURL' ),
137+ ' http://localhost:3000/error' , ' Got the correct error URI' );
138+
139+ my $p = $node -> nodePath();
140+
141+ my $kd = get_single_node_ok($xpath , " $p /md:KeyDescriptor" );
142+
143+ is($kd -> getAttribute(' use' ),
144+ " signing" , " Key descriptor is there for signing only" );
145+
146+ my $ki = get_single_node_ok($xpath , $kd -> nodePath() . " /ds:KeyInfo" );
147+
148+ my $cert = get_single_node_ok($xpath ,
149+ $ki -> nodePath() . " /ds:X509Data/ds:X509Certificate" );
150+ ok($cert -> textContent, " And we have the certificate data" );
151+
152+ my $keyname
153+ = get_single_node_ok($xpath , $ki -> nodePath() . " /ds:KeyName" );
154+ ok($keyname -> textContent, " ... and we have a key name" );
155+ }
156+
157+ }
158+
159+ {
160+ # Test Signature
161+ my $node = get_single_node_ok($xpath , ' /node()/ds:Signature' );
88162
89163}
90164
0 commit comments