From 7bc9953c5c1c815908a2c38cdbe7c508bb02887e Mon Sep 17 00:00:00 2001 From: Patrick Radtke <patrick@cirrusidentity.com> Date: Wed, 5 Jul 2017 12:29:12 -0700 Subject: [PATCH] Updates based on PR comments --- lib/SimpleSAML/Configuration.php | 2 +- tests/config/no-options/config.php | 8 -------- tests/lib/SimpleSAML/ConfigurationTest.php | 9 ++++++--- tests/lib/SimpleSAML/Locale/LocalizationTest.php | 6 ++++-- tests/lib/SimpleSAML/Utils/XMLTest.php | 2 ++ tests/modules/consent/lib/Auth/Process/ConsentTest.php | 3 --- .../modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php | 1 - 7 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 tests/config/no-options/config.php diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index e2a9fdbc1..28737c58e 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -198,7 +198,7 @@ class SimpleSAML_Configuration implements \SimpleSAML\Utils\ClearableState /** - * Load a configuration file from a configuration set. + * Load a configuration file from a configuration set.XM * * @param string $filename The name of the configuration file. * @param string $configSet The configuration set. Optional, defaults to 'simplesaml'. diff --git a/tests/config/no-options/config.php b/tests/config/no-options/config.php deleted file mode 100644 index dddd7364c..000000000 --- a/tests/config/no-options/config.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -/* A configuration desigend for tests that need no configuration options set yet the SSP requires a config.php to have -been loaded. -*/ -$config = array( - // We need to set at least one key=value pair to avoid validation issues loading the file - 'some_example_option' => 'a', -); \ No newline at end of file diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index e93e96e2a..035c1b011 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -37,7 +37,10 @@ class Test_SimpleSAML_Configuration extends PHPUnit_Framework_TestCase } catch (\SimpleSAML\Error\CriticalConfigurationError $var) { // This exception is expected. } - //TODO: not sure this is correct. First call to getInstance() throw exception and the 2nd works?... + /* + * After the above failure an emergency configuration is create to allow core SSP components to function and + * possibly log/display the error. + */ $c = SimpleSAML_Configuration::getInstance(); $this->assertNotEmpty($c->toArray()); } @@ -105,8 +108,8 @@ class Test_SimpleSAML_Configuration extends PHPUnit_Framework_TestCase */ public function testGetBaseURL() { - // Need to set a configuration file because the SSP Logger attempts to load it. - putenv('SIMPLESAMLPHP_CONFIG_DIR=tests/config/no-options'); + // Need to set a default configuration because the SSP Logger attempts to use it. + SimpleSAML_Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); $c = SimpleSAML_Configuration::loadFromArray(array()); $this->assertEquals($c->getBaseURL(), 'simplesaml/'); diff --git a/tests/lib/SimpleSAML/Locale/LocalizationTest.php b/tests/lib/SimpleSAML/Locale/LocalizationTest.php index c852d0fce..a8ea072af 100644 --- a/tests/lib/SimpleSAML/Locale/LocalizationTest.php +++ b/tests/lib/SimpleSAML/Locale/LocalizationTest.php @@ -3,13 +3,15 @@ namespace SimpleSAML\Test\Locale; use SimpleSAML\Locale\Localization; +use \SimpleSAML_Configuration as Configuration; + class LocalizationTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - // Localization/Language code attempts to load a cookie, and looks to config.php for a name of the cookie - putenv('SIMPLESAMLPHP_CONFIG_DIR=tests/config/no-options'); + // Localization/Language code attempts to load a cookie, and looks in the config for a name of the cookie + Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); } diff --git a/tests/lib/SimpleSAML/Utils/XMLTest.php b/tests/lib/SimpleSAML/Utils/XMLTest.php index bd675b760..a812b964f 100644 --- a/tests/lib/SimpleSAML/Utils/XMLTest.php +++ b/tests/lib/SimpleSAML/Utils/XMLTest.php @@ -356,6 +356,8 @@ NOWDOC; */ public function testIsValidMetadata() { + \SimpleSAML_Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + $schema = 'saml-schema-metadata-2.0.xsd'; $dom = $this->getMockBuilder('\DOMDocument') diff --git a/tests/modules/consent/lib/Auth/Process/ConsentTest.php b/tests/modules/consent/lib/Auth/Process/ConsentTest.php index cf63fe675..e83659d22 100644 --- a/tests/modules/consent/lib/Auth/Process/ConsentTest.php +++ b/tests/modules/consent/lib/Auth/Process/ConsentTest.php @@ -37,9 +37,6 @@ class ConsentTest extends \PHPUnit_Framework_TestCase */ public function testCheckDisable() { - // Consent code path attempts to load metadata, which tries to find a config.php - putenv('SIMPLESAMLPHP_CONFIG_DIR=tests/config/no-options'); - // test consent disable regex with match $config = array(); diff --git a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php index b9b07c3c9..bb3d065db 100644 --- a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php +++ b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php @@ -125,7 +125,6 @@ class SP_Test extends \PHPUnit_Framework_TestCase ); $this->config = Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); - } -- GitLab