Skip to content

Commit 05ad9e3

Browse files
authored
Merge pull request #214 from waterkip/GH-213-update_typo
Correctly test NameID attributes
2 parents 4e6c8b6 + ca4fcda commit 05ad9e3

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ XML::Enc = 0.13
6060
XML::Sig = 0.64
6161
; Here because it isn't provided by Crypt::OpenSSL::RSA
6262
Crypt::OpenSSL::Bignum = 0
63-
URN::OASIS::SAML2 = 0.003
63+
URN::OASIS::SAML2 = 0.004
6464
XML::Generator = 1.13
6565

6666
[Prereqs / TestRequires]

lib/Net/SAML2/Protocol/LogoutRequest.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
77
use MooseX::Types::URI qw/ Uri /;
88
use Net::SAML2::XML::Util qw/ no_comments /;
99
use XML::Generator;
10-
use URN::OASIS::SAML2 qw(:urn);
10+
use URN::OASIS::SAML2 qw(:urn NAMEID_PERSISTENT);
1111
use XML::LibXML::XPathContext;
1212

1313
with 'Net::SAML2::Role::ProtocolMessage';
@@ -123,7 +123,7 @@ around BUILDARGS => sub {
123123
my $self = shift;
124124
my %args = @_;
125125

126-
if ($args{nameid_format} && $args{nameid_format} eq 'urn:oasis:names:tc:SAML:2.0:nameidformat:persistent') {
126+
if ($args{nameid_format} && $args{nameid_format} eq NAMEID_PERSISTENT()) {
127127
$args{include_name_qualifier} = 1;
128128
}
129129

t/07-logout-request.t

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use strict;
22
use warnings;
33
use Test::Lib;
44
use Test::Net::SAML2;
5-
use URN::OASIS::SAML2 qw(:urn);
5+
use URN::OASIS::SAML2 qw(:urn NAMEID_EMAIL);
66

77
use Net::SAML2::Protocol::LogoutRequest;
88

@@ -39,12 +39,34 @@ test_xml_attribute_ok($xpath, '/samlp:LogoutRequest/@IssueInstant', 'foo');
3939
my $name_id = get_single_node_ok($xpath, '/samlp:LogoutRequest/saml:NameID');
4040
is($name_id->getAttribute('Format'), $args{nameid_format});
4141

42-
foreach (qw(NameQualifier SPNameQualifier SPProvidedID)) {
43-
is(
44-
$name_id->getAttribute($_),
45-
undef,
46-
"We don't have $_ as an attribute in the nameid"
42+
foreach (qw(NameQualifier SPNameQualifier)) {
43+
isnt($name_id->getAttribute($_),
44+
undef, "We don't have $_ as an attribute in the nameid");
45+
}
46+
47+
is(
48+
$name_id->getAttribute('SPProvidedID'),
49+
undef,
50+
"We don't have SPProvidedID as an attribute in the nameid"
51+
);
52+
53+
{
54+
my $lor = Net::SAML2::Protocol::LogoutRequest->new(%args, nameid_format => NAMEID_EMAIL());
55+
my $xpath = get_xpath(
56+
$lor->as_xml,
57+
samlp => URN_PROTOCOL,
58+
saml => URN_ASSERTION,
4759
);
60+
test_xml_attribute_ok($xpath, '/samlp:LogoutRequest/@ID', qr/^NETSAML2_/);
61+
test_xml_attribute_ok($xpath, '/samlp:LogoutRequest/@IssueInstant', 'foo');
62+
my $name_id = get_single_node_ok($xpath, '/samlp:LogoutRequest/saml:NameID');
63+
is($name_id->getAttribute('Format'), NAMEID_EMAIL());
64+
65+
foreach (qw(NameQualifier SPNameQualifier SPProvidedID)) {
66+
is($name_id->getAttribute($_),
67+
undef, "We don't have $_ as an attribute in the nameid");
68+
}
69+
4870
}
4971

5072
{

0 commit comments

Comments
 (0)