Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include xml:lang attribute in ServiceName and ServiceDescription #224

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead of hardcoding it to 'en' we can add it as an attribute (and default it to 'en'), so others can define their own language, eg, 'it', 'nl' etc?

@timlegge wdyt?

I could also accept this and change it in another commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we do need a way to specify a language but as @MartijnVdS pointed out it is hard coded in the generate_metadata so lets approve her and add an issue to fix everywhere.

$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