summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2016-02-03 13:51:01 +0100
committerJaime Perez Crespo <jaime.perez@uninett.no>2016-02-03 13:51:01 +0100
commitf7eacaf88fee9fcbf3a9cc304db6d49f9e55c309 (patch)
treebc3a0685353db71025fdc58d8d158759903fc1f2
parent68cba56c7f276c6f1f5ce434804bbcd0fd8129b2 (diff)
downloadsimplesamlphp-f7eacaf88fee9fcbf3a9cc304db6d49f9e55c309.zip
simplesamlphp-f7eacaf88fee9fcbf3a9cc304db6d49f9e55c309.tar.gz
simplesamlphp-f7eacaf88fee9fcbf3a9cc304db6d49f9e55c309.tar.bz2
Add more tests for SimpleSAML_Configuration::getDefaultEndpoint() and SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint().
-rw-r--r--tests/lib/SimpleSAML/ConfigurationTest.php57
1 files changed, 55 insertions, 2 deletions
diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php
index c22fd57..0037660 100644
--- a/tests/lib/SimpleSAML/ConfigurationTest.php
+++ b/tests/lib/SimpleSAML/ConfigurationTest.php
@@ -553,6 +553,20 @@ class Test_SimpleSAML_Configuration extends PHPUnit_Framework_TestCase
'Binding' => SAML2_Const::BINDING_HTTP_REDIRECT,
),
),
+ // make sure endpoints with invalid bindings are ignored and those marked as NOT default are still used
+ array(
+ array(
+ 'index' => 1,
+ 'Location' => 'https://www1.example.com/endpoint.php',
+ 'Binding' => 'invalid_binding',
+ ),
+ array(
+ 'index' => 2,
+ 'isDefault' => false,
+ 'Location' => 'https://www2.example.com/endpoint.php',
+ 'Binding' => SAML2_Const::BINDING_HTTP_POST,
+ ),
+ ),
);
$acs_expected_eps = array(
// output should be completed with the default binding (HTTP-POST for ACS)
@@ -589,20 +603,41 @@ class Test_SimpleSAML_Configuration extends PHPUnit_Framework_TestCase
'isDefault' => true,
'index' => 2,
),
+ // the first valid enpoint should be used even if it's marked as NOT default
+ array(
+ 'index' => 2,
+ 'isDefault' => false,
+ 'Location' => 'https://www2.example.com/endpoint.php',
+ 'Binding' => SAML2_Const::BINDING_HTTP_POST,
+ )
);
$a = array(
'metadata-set' => 'saml20-sp-remote',
'ArtifactResolutionService' => 'https://example.com/ars',
'SingleSignOnService' => 'https://example.com/sso',
- 'SingleLogoutService' => 'https://example.com/slo',
+ 'SingleLogoutService' => array(
+ 'Location' => 'https://example.com/slo',
+ 'Binding' => 'valid_binding', // test unknown bindings if we don't specify a list of valid ones
+ ),
+ );
+
+ $valid_bindings = array(
+ SAML2_Const::BINDING_HTTP_POST,
+ SAML2_Const::BINDING_HTTP_REDIRECT,
+ SAML2_Const::BINDING_HOK_SSO,
+ SAML2_Const::BINDING_HTTP_ARTIFACT.
+ SAML2_Const::BINDING_SOAP,
);
// run all general tests with AssertionConsumerService endpoint type
foreach ($acs_eps as $i => $ep) {
$a['AssertionConsumerService'] = $ep;
$c = SimpleSAML_Configuration::loadFromArray($a);
- $this->assertEquals($acs_expected_eps[$i], $c->getDefaultEndpoint('AssertionConsumerService'));
+ $this->assertEquals($acs_expected_eps[$i], $c->getDefaultEndpoint(
+ 'AssertionConsumerService',
+ $valid_bindings
+ ));
}
// now make sure SingleSignOnService, SingleLogoutService and ArtifactResolutionService works fine
@@ -629,6 +664,24 @@ class Test_SimpleSAML_Configuration extends PHPUnit_Framework_TestCase
),
$c->getDefaultEndpoint('SingleLogoutService')
);
+
+ // test for no valid endpoints specified
+ $a['SingleLogoutService'] = array(
+ array(
+ 'Location' => 'https://example.com/endpoint.php',
+ 'Binding' => 'invalid_binding',
+ 'isDefault' => true,
+ ),
+ );
+ $c = SimpleSAML_Configuration::loadFromArray($a);
+ try {
+
+ $c->getDefaultEndpoint('SingleLogoutService', $valid_bindings);
+ $this->fail('Failed to detect invalid endpoint binding.');
+ } catch (Exception $e) {
+ $this->assertEquals('[ARRAY][\'SingleLogoutService\']:Could not find a supported SingleLogoutService '.
+ 'endpoint.', $e->getMessage());
+ }
}
/**