Skip to content
Snippets Groups Projects
Commit 6d80abf1 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Add tests for AttributeConsumingService isDefault and index options

parent 30a9c739
No related branches found
No related tags found
No related merge requests found
......@@ -136,6 +136,92 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase
}
}
/**
* Test the working of the isDefault config option
*/
public function testAttributeConsumingServiceDefault()
{
$entityId = 'https://entity.example.com/id';
$set = 'saml20-sp-remote';
$metadata = array(
'entityid' => $entityId,
'name' => array('en' => 'Test SP'),
'metadata-set' => $set,
'attributes' => array(
'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10',
'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6',
),
);
$samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId);
$samlBuilder->addMetadata($set, $metadata);
$spDesc = $samlBuilder->getEntityDescriptor();
$acs = $spDesc->getElementsByTagName("AttributeConsumingService");
$acs1 = $acs->item(0);
$this->assertFalse($acs1->hasAttribute("isDefault"));
$metadata['attributes.isDefault'] = true;
$samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId);
$samlBuilder->addMetadata($set, $metadata);
$spDesc = $samlBuilder->getEntityDescriptor();
$acs = $spDesc->getElementsByTagName("AttributeConsumingService");
$acs1 = $acs->item(0);
$this->assertTrue($acs1->hasAttribute("isDefault"));
$this->assertEquals("true", $acs1->getAttribute("isDefault"));
$metadata['attributes.isDefault'] = false;
$samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId);
$samlBuilder->addMetadata($set, $metadata);
$spDesc = $samlBuilder->getEntityDescriptor();
$acs = $spDesc->getElementsByTagName("AttributeConsumingService");
$acs1 = $acs->item(0);
$this->assertTrue($acs1->hasAttribute("isDefault"));
$this->assertEquals("false", $acs1->getAttribute("isDefault"));
}
/**
* Test the index option is used correctly.
*/
public function testAttributeConsumingServiceIndex()
{
$entityId = 'https://entity.example.com/id';
$set = 'saml20-sp-remote';
$metadata = array(
'entityid' => $entityId,
'name' => array('en' => 'Test SP'),
'metadata-set' => $set,
'attributes' => array(
'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10',
'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6',
),
);
$samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId);
$samlBuilder->addMetadata($set, $metadata);
$spDesc = $samlBuilder->getEntityDescriptor();
$acs = $spDesc->getElementsByTagName("AttributeConsumingService");
$acs1 = $acs->item(0);
$this->assertTrue($acs1->hasAttribute("index"));
$this->assertEquals("0", $acs1->getAttribute("index"));
$metadata['attributes.index'] = 15;
$samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId);
$samlBuilder->addMetadata($set, $metadata);
$spDesc = $samlBuilder->getEntityDescriptor();
$acs = $spDesc->getElementsByTagName("AttributeConsumingService");
$acs1 = $acs->item(0);
$this->assertTrue($acs1->hasAttribute("index"));
$this->assertEquals("15", $acs1->getAttribute("index"));
}
/**
* Test the required protocolSupportEnumeration in AttributeAuthorityDescriptor
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment