Net-SAML2
view release on metacpan or search on metacpan
t/02-create-sp.t view on Meta::CPAN
like($xml, qr/^\<\?xml version="1.0" encoding="UTF-8"\?\>/, "Have XML version declaration");
my $xpath = get_xpath(
$xml,
md => URN_METADATA,
ds => URN_SIGNATURE,
);
my $node
= get_single_node_ok($xpath,
'//md:EntityDescriptor/md:SPSSODescriptor');
is($node->getAttribute('WantAssertionsSigned'), 'false',
'Wants assertions to be signed');
is(
$node->getAttribute('AuthnRequestsSigned'), 'false',
'.. and also authn requests to be signed'
);
my @ssos
= $xpath->findnodes(
'//md:EntityDescriptor/md:SPSSODescriptor/md:AssertionConsumerService'
);
if (is(@ssos, 2, "Got two assertionConsumerService(s)")) {
is(
$ssos[0]->getAttribute('Binding'),
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
"Returns the correct binding: HTTP-POST"
);
is(
$ssos[1]->getAttribute('Binding'),
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
"Returns the correct binding: HTTP-Artifact"
);
}
{
my $node = get_single_node_ok($xpath,
'//md:SingleLogoutService[@Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP"]'
);
is(
$node->getAttribute('Location'),
'http://localhost:3000/slo-soap',
".. with the correct location"
);
$node = get_single_node_ok($xpath,
'//md:SingleLogoutService[@Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"]'
);
is(
$node->getAttribute('Location'),
'http://localhost:3000/sls-post-response',
".. with the correct location"
);
}
my $root_node = get_single_node_ok($xpath, '/md:EntityDescriptor');
my $signature_node = $root_node->firstChild;
is($signature_node->nodeName(),
'dsig:Signature', "First node is the signature");
is(
'44e55d658c4b8bdf740cae7a0b200488',
$sp->key_name('signing'),
"Got a key name for the signing key"
);
is(
undef,
$sp->key_name('encryption'),
"... and there is no encryption key name"
);
}
{
my $sp = net_saml2_sp(sign_metadata => 0);
my $xml = $sp->metadata;
like($xml, qr/^\<\?xml version="1.0" encoding="UTF-8"\?\>/, "Have XML version declaration");
my $xpath = get_xpath(
$xml,
md => URN_METADATA,
ds => URN_SIGNATURE,
);
my $nodes = $xpath->findnodes('//ds:Signature');
is($nodes->size(), 0, "We don't have any ds:Signature present");
}
{
my $sp = net_saml2_sp();
my $xpath = get_xpath(
$sp->metadata,
md => URN_METADATA,
ds => URN_SIGNATURE,
);
my $node = get_single_node_ok($xpath, '/md:EntityDescriptor');
is(
$node->getAttribute('entityID'),
'Some entity ID',
'.. has the correct entity ID'
);
ok($node->getAttribute('ID'), '.. has an ID');
{
# Test ContactPerson
my $node = get_single_node_ok($xpath, '/node()/md:ContactPerson');
my $p = $node->nodePath();
my $company = get_single_node_ok($xpath, "$p/md:Company");
is(
$company->textContent,
'Net::SAML2::SP testsuite',
"Got the correct company name for the contact person"
);
( run in 1.342 second using v1.01-cache-2.11-cpan-5a3173703d6 )