@@ -39,7 +39,7 @@ if (is(@ssos, 2, "Got two assertionConsumerService(s)")) {
3939get_single_node_ok($xpath , ' //ds:Signature' );
4040
4141{
42- my $sp = net_saml2_sp(sign_metadata => 0);
42+ my $sp = net_saml2_sp(sign_metadata => 0);
4343 my $xpath = get_xpath(
4444 $sp -> metadata,
4545 md => ' urn:oasis:names:tc:SAML:2.0:metadata' ,
@@ -72,13 +72,13 @@ get_single_node_ok($xpath, '//ds:Signature');
7272 error_url => ' /error' ,
7373 );
7474
75- my $xpc = get_xpath(
75+ my $xpath = get_xpath(
7676 $sp -> metadata,
7777 md => ' urn:oasis:names:tc:SAML:2.0:metadata' ,
7878 ds => ' http://www.w3.org/2000/09/xmldsig#'
7979 );
8080
81- my $node = get_single_node_ok($xpc , ' /md:EntityDescriptor' );
81+ my $node = get_single_node_ok($xpath , ' /md:EntityDescriptor' );
8282 is(
8383 $node -> getAttribute(' entityID' ),
8484 ' Some entity ID' ,
@@ -89,68 +89,77 @@ get_single_node_ok($xpath, '//ds:Signature');
8989
9090 {
9191 # Test ContactPerson
92- my $node = get_single_node_ok($xpc , ' /node()/md:ContactPerson' );
92+ my $node = get_single_node_ok($xpath , ' /node()/md:ContactPerson' );
9393 my $p = $node -> nodePath();
9494
95- my $company = get_single_node_ok($xpc , " $p /md:Company" );
95+ my $company = get_single_node_ok($xpath , " $p /md:Company" );
9696 is(
9797 $company -> textContent,
9898 ' Net::SAML2::SP testsuite' ,
9999 " Got the correct company name for the contact person"
100100 );
101101
102- my $email = get_single_node_ok($xpc , " $p /md:EmailAddress" );
102+ my $email = get_single_node_ok($xpath , " $p /md:EmailAddress" );
103103 is($email -> textContent, ' test@example.com' ,
104104 " .. and the correct email" );
105105 }
106106
107107 {
108108 # Test Organisation
109- my $node = get_single_node_ok($xpc , ' /node()/md:Organization' );
109+ my $node = get_single_node_ok($xpath , ' /node()/md:Organization' );
110110 my $p = $node -> nodePath();
111111
112- my $name = get_single_node_ok($xpc , " $p /md:OrganizationName" );
113- is(
114- $name -> textContent,
115- ' Net::SAML2::SP' ,
116- " Got the correct company name"
117- );
112+ my $name = get_single_node_ok($xpath , " $p /md:OrganizationName" );
113+ is($name -> textContent, ' Net::SAML2::SP' ,
114+ " Got the correct company name" );
118115
119116 my $display_name
120- = get_single_node_ok($xpc , " $p /md:OrganizationDisplayName" );
117+ = get_single_node_ok($xpath , " $p /md:OrganizationDisplayName" );
121118 is(
122119 $display_name -> textContent,
123120 ' Net::SAML2::SP testsuite' ,
124121 " .. and the correct display name"
125122 );
126123
127- my $url = get_single_node_ok($xpc , " $p /md:OrganizationURL" );
124+ my $url = get_single_node_ok($xpath , " $p /md:OrganizationURL" );
128125 is($url -> textContent, ' http://www.example.com' ,
129126 " .. and the correct URI" );
130127 }
131128
132129 {
133130 # Test SPSSODescriptor
134- my $node = get_single_node_ok($xpc , ' /node()/md:SPSSODescriptor' );
131+ my $node = get_single_node_ok($xpath , ' /node()/md:SPSSODescriptor' );
135132 is($node -> getAttribute(' AuthnRequestsSigned' ),
136133 ' 1' , ' .. and authn request needs signing' );
137134 is($node -> getAttribute(' WantAssertionsSigned' ),
138135 ' 1' , ' .. as does assertions' );
139- is(
140- $node -> getAttribute(' errorURL' ),
141- ' http://localhost:3000/error' ,
142- ' Got the correct error URI'
143- );
136+ is($node -> getAttribute(' errorURL' ),
137+ ' http://localhost:3000/error' , ' Got the correct error URI' );
144138
145- # TODO: Add more tests for other metadata parts
139+ my $p = $node -> nodePath();
146140
147- }
141+ my $kd = get_single_node_ok( $xpath , " $p /md:KeyDescriptor " );
148142
149- {
150- # Test Signature
151- my $node = get_single_node_ok($xpc , ' /node()/ds:Signature' );
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" );
152155 }
153156
154157}
155158
159+ {
160+ # Test Signature
161+ my $node = get_single_node_ok($xpath , ' /node()/ds:Signature' );
162+
163+ }
164+
156165done_testing;
0 commit comments