Skip to content

Commit

Permalink
Include xml:lang attribute in ServiceName and ServiceDescription
Browse files Browse the repository at this point in the history
The SAML2 metadata documentation states that these fields are of the
`localizedNameType` type. This means that an `xml:lang` attribute
that indicates which language the text is written in, is required.

This change adds this attribute, with a value of `en` (just like for
md:OrganizationName etc.)

Fixes perl-net-saml2/perl-Net-SAML2#233
  • Loading branch information
Martijn van de Streek committed May 21, 2024
1 parent a19257d commit b37be75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Net/SAML2/AttributeConsumingService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ sub to_xml {
index => $self->index,
isDefault => $self->default,
},
$xml->ServiceName($self->namespace, undef, $self->service_name),
$self->_has_service_description ? $xml->ServiceDescription($self->namespace, undef, $self->service_description) : (),
$xml->ServiceName($self->namespace, { 'xml:lang' => 'en' }, $self->service_name),
$self->_has_service_description ? $xml->ServiceDescription($self->namespace, { 'xml:lang' => 'en' }, $self->service_description) : (),
map { $_->to_xml } @{ $self->attributes },
);
}
Expand Down
2 changes: 2 additions & 0 deletions t/02-create-sp.t
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ use URN::OASIS::SAML2 qw(:bindings :urn);
'Net::SAML2 testsuite',
".. with the correct value"
);
is($child[0]->getAttribute("xml:lang"),
"en", ".. and xml:lang is set");

is($child[1]->nodeName, "md:RequestedAttribute",
"Requested attribute found");
Expand Down
5 changes: 5 additions & 0 deletions t/28-attribute-consuming-service.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ is(
"Net::SAML2 testsuite",
".. and has the correct content"
);
is(
$node->getAttribute('xml:lang'),
"en",
".. and has the correct xml:lang"
);

$node = get_single_node_ok($xpath,
'/md:AttributeConsumingService/md:RequestedAttribute');
Expand Down

0 comments on commit b37be75

Please sign in to comment.