Skip to content

Commit

Permalink
Fix a few cases where the attribute-name didn't match the specified f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
tvdijen committed Jul 23, 2024
1 parent cda6610 commit d926eb0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/SAML2/XML/md/RequestedAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testMarshalling(): void
$ra = new RequestedAttribute(
'attr',
true,
C::NAMEFORMAT_URI,
C::NAMEFORMAT_BASIC,
'Attribute',
[new AttributeValue('value1')],
);
Expand Down
2 changes: 1 addition & 1 deletion tests/SAML2/XML/mdattr/EntityAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testMarshalling(): void
{
$attribute1 = new Attribute(
name: 'attrib1',
nameFormat: C::NAMEFORMAT_URI,
nameFormat: C::NAMEFORMAT_BASIC,
attributeValue: [
new AttributeValue('is'),
new AttributeValue('really'),
Expand Down
2 changes: 1 addition & 1 deletion tests/SAML2/XML/saml/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testMarshalling(): void

$attribute = new Attribute(
'TheName',
C::NAMEFORMAT_URI,
C::NAMEFORMAT_BASIC,
'TheFriendlyName',
[
new AttributeValue('FirstValue'),
Expand Down
12 changes: 6 additions & 6 deletions tests/SAML2/XML/samlp/AttributeQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public function testAttributeNameFormat(): void
attributes: [
new Attribute(
name: 'test1',
nameFormat: C::NAMEFORMAT_URI,
nameFormat: C::NAMEFORMAT_BASIC,
attributeValue: [
new AttributeValue('test1_attrv1'),
new AttributeValue('test1_attrv2'),
],
),
new Attribute(
name: 'test2',
nameFormat: C::NAMEFORMAT_URI,
nameFormat: C::NAMEFORMAT_BASIC,
attributeValue: [
new AttributeValue('test2_attrv1'),
new AttributeValue('test2_attrv2'),
Expand All @@ -147,7 +147,7 @@ public function testAttributeNameFormat(): void
),
new Attribute(
name: 'test3',
nameFormat: C::NAMEFORMAT_URI,
nameFormat: C::NAMEFORMAT_BASIC,
),
],
);
Expand All @@ -159,11 +159,11 @@ public function testAttributeNameFormat(): void
$attributes = XPath::xpQuery($attributeQueryElement, './saml_assertion:Attribute', $xpCache);
$this->assertCount(3, $attributes);
$this->assertEquals('test1', $attributes[0]->getAttribute('Name'));
$this->assertEquals(C::NAMEFORMAT_URI, $attributes[0]->getAttribute('NameFormat'));
$this->assertEquals(C::NAMEFORMAT_BASIC, $attributes[0]->getAttribute('NameFormat'));
$this->assertEquals('test2', $attributes[1]->getAttribute('Name'));
$this->assertEquals(C::NAMEFORMAT_URI, $attributes[1]->getAttribute('NameFormat'));
$this->assertEquals(C::NAMEFORMAT_BASIC, $attributes[1]->getAttribute('NameFormat'));
$this->assertEquals('test3', $attributes[2]->getAttribute('Name'));
$this->assertEquals(C::NAMEFORMAT_URI, $attributes[2]->getAttribute('NameFormat'));
$this->assertEquals(C::NAMEFORMAT_BASIC, $attributes[2]->getAttribute('NameFormat'));

// Sanity check: test if values are still ok
$av1 = XPath::xpQuery($attributes[0], './saml_assertion:AttributeValue', $xpCache);
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/xml/md_RequestedAttribute.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<md:RequestedAttribute xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" Name="attr" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="Attribute" isRequired="true">
<md:RequestedAttribute xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" Name="attr" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" FriendlyName="Attribute" isRequired="true">
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">value1</saml:AttributeValue>
</md:RequestedAttribute>
2 changes: 1 addition & 1 deletion tests/resources/xml/mdattr_EntityAttributes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<mdattr:EntityAttributes xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute">
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Name="attrib1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Name="attrib1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
<saml:AttributeValue>is</saml:AttributeValue>
<saml:AttributeValue>really</saml:AttributeValue>
<saml:AttributeValue>cool</saml:AttributeValue>
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/xml/saml_Attribute.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Name="TheName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" FriendlyName="TheFriendlyName" test:attr1="testval1" test:attr2="testval2" xmlns:test="urn:test:something">
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Name="TheName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" FriendlyName="TheFriendlyName" test:attr1="testval1" test:attr2="testval2" xmlns:test="urn:test:something">
<saml:AttributeValue>FirstValue</saml:AttributeValue>
<saml:AttributeValue>SecondValue</saml:AttributeValue>
</saml:Attribute>

0 comments on commit d926eb0

Please sign in to comment.