From b37be750ae2b6f75072f3fc251742a0b852fa1b5 Mon Sep 17 00:00:00 2001 From: Martijn van de Streek Date: Tue, 21 May 2024 16:00:17 +0200 Subject: [PATCH] Include `xml:lang` attribute in ServiceName and ServiceDescription 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 --- lib/Net/SAML2/AttributeConsumingService.pm | 4 ++-- t/02-create-sp.t | 2 ++ t/28-attribute-consuming-service.t | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Net/SAML2/AttributeConsumingService.pm b/lib/Net/SAML2/AttributeConsumingService.pm index 54b9729..abf4876 100644 --- a/lib/Net/SAML2/AttributeConsumingService.pm +++ b/lib/Net/SAML2/AttributeConsumingService.pm @@ -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 }, ); } diff --git a/t/02-create-sp.t b/t/02-create-sp.t index 82aad65..088cd6c 100644 --- a/t/02-create-sp.t +++ b/t/02-create-sp.t @@ -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"); diff --git a/t/28-attribute-consuming-service.t b/t/28-attribute-consuming-service.t index 62afc2f..b612a61 100644 --- a/t/28-attribute-consuming-service.t +++ b/t/28-attribute-consuming-service.t @@ -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');