diff --git a/config-templates/config.php b/config-templates/config.php index 679c1b0234924bb298f64cba5ca79ec61c3a96f1..6153dcd548366cf3282a530aac0b39681b85c8da 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -3,6 +3,7 @@ /** * The configuration of SimpleSAMLphp */ + $httpUtils = new \SimpleSAML\Utils\HTTP(); $config = [ diff --git a/lib/SimpleSAML/Compat/Logger.php b/lib/SimpleSAML/Compat/Logger.php index 0b0bede4ecd36ae2ef25091fbf3da2bb45703c62..91ea0ffa3b2b67574f67973af92c84cca6eab596 100644 --- a/lib/SimpleSAML/Compat/Logger.php +++ b/lib/SimpleSAML/Compat/Logger.php @@ -183,4 +183,3 @@ class Logger implements LoggerInterface } } } - diff --git a/lib/SimpleSAML/Kernel.php b/lib/SimpleSAML/Kernel.php index 2c13a76c34a5185672ea3053688f76cbdbbe3b1b..01b45b288efd5225345b75512adefd8c504de204 100644 --- a/lib/SimpleSAML/Kernel.php +++ b/lib/SimpleSAML/Kernel.php @@ -48,7 +48,8 @@ class Kernel extends BaseKernel public function getCacheDir(): string { $configuration = Configuration::getInstance(); - $cachePath = $configuration->getString('tempdir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->module; + $cachePath = $configuration->getString('tempdir') . DIRECTORY_SEPARATOR + . 'cache' . DIRECTORY_SEPARATOR . $this->module; $sysUtils = new System(); if ($sysUtils->isAbsolutePath($cachePath)) { diff --git a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php index 3ad20afe83af6f45b873bad6bd3c617d5dddb336..0ccf91d2354f3bb1262f4baabf50dbc209948c48 100644 --- a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php @@ -46,7 +46,11 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface public function __construct(Configuration $config) { // Remove any non-printable characters before storing - $this->processname = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $config->getString('logging.processname', 'SimpleSAMLphp')); + $this->processname = preg_replace( + '/[\x00-\x1F\x7F\xA0]/u', + '', + $config->getString('logging.processname', 'SimpleSAMLphp') + ); } diff --git a/lib/SimpleSAML/Logger/FileLoggingHandler.php b/lib/SimpleSAML/Logger/FileLoggingHandler.php index 0771ce3395ecf4d1013aa7007e7d48efb99521d6..44b3dcbf2e97bf9ef77de73008593f9e3331d8c8 100644 --- a/lib/SimpleSAML/Logger/FileLoggingHandler.php +++ b/lib/SimpleSAML/Logger/FileLoggingHandler.php @@ -57,7 +57,11 @@ class FileLoggingHandler implements LoggingHandlerInterface $config->getString('logging.logfile', 'simplesamlphp.log'); // Remove any non-printable characters before storing - $this->processname = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $config->getString('logging.processname', 'SimpleSAMLphp')); + $this->processname = preg_replace( + '/[\x00-\x1F\x7F\xA0]/u', + '', + $config->getString('logging.processname', 'SimpleSAMLphp') + ); if (@file_exists($this->logFile)) { if (!@is_writeable($this->logFile)) { diff --git a/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php b/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php index e2a8f93a06df1dccc2f7514ab38ec79ff5c44075..2083f9d3224bee76769a208a27316169b49fa682 100644 --- a/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php +++ b/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php @@ -23,7 +23,11 @@ class StandardErrorLoggingHandler extends FileLoggingHandler public function __construct(Configuration $config) { // Remove any non-printable characters before storing - $this->processname = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $config->getString('logging.processname', 'SimpleSAMLphp')); + $this->processname = preg_replace( + '/[\x00-\x1F\x7F\xA0]/u', + '', + $config->getString('logging.processname', 'SimpleSAMLphp') + ); $this->logFile = 'php://stderr'; } } diff --git a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php index b08328ab29681c155de940043249fbd94ce081a9..cdfcf0aa3686c1c6cad259ebb8cc544777547d86 100644 --- a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php @@ -30,7 +30,11 @@ class SyslogLoggingHandler implements LoggingHandlerInterface $facility = $config->getInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER); // Remove any non-printable characters before storing - $processname = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $config->getString('logging.processname', 'SimpleSAMLphp')); + $processname = preg_replace( + '/[\x00-\x1F\x7F\xA0]/u', + '', + $config->getString('logging.processname', 'SimpleSAMLphp') + ); // Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems $sysUtils = new Utils\System(); diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index 4139c9dbd763b5c50164426b7d4593f5c7a6edff..6388cc80066b7163bc9d5d07420fe848156b19a5 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -424,10 +424,10 @@ class Module } } elseif (!in_array($tmp[0], self::getModules())) { // Module not installed - throw new \Exception('No module named \'' . $tmp[0]. '\' has been installed.'); + throw new \Exception('No module named \'' . $tmp[0] . '\' has been installed.'); } elseif (!self::isModuleEnabled($tmp[0])) { // Module installed, but not enabled - throw new \Exception('The module \'' . $tmp[0]. '\' is not enabled.'); + throw new \Exception('The module \'' . $tmp[0] . '\' is not enabled.'); } else { // should be a module // make sure empty types are handled correctly diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index 97db3639ae50df73b1081acb15d10f8ffd01edfa..ca947bdb2e99c253c6e239b0045cc84aecb22b00 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -48,7 +48,10 @@ class SessionHandlerPHP extends SessionHandler parent::__construct(); $config = Configuration::getInstance(); - $this->cookie_name = $config->getString('session.phpsession.cookiename', ini_get('session.name') ?? 'PHPSESSID'); + $this->cookie_name = $config->getString( + 'session.phpsession.cookiename', + ini_get('session.name') ?? 'PHPSESSID' + ); if (session_status() === PHP_SESSION_ACTIVE) { if (session_name() === $this->cookie_name || $this->cookie_name === null) { diff --git a/lib/SimpleSAML/Store/SQLStore.php b/lib/SimpleSAML/Store/SQLStore.php index 640bbb5dafcb56c2041cb7b27cc696b76bd32e72..eef08f25bf542b72a7b1d433804e64439b3a5271 100644 --- a/lib/SimpleSAML/Store/SQLStore.php +++ b/lib/SimpleSAML/Store/SQLStore.php @@ -109,7 +109,10 @@ class SQLStore implements StoreInterface if ($tableVer === 2) { return; } elseif ($tableVer < 2 && $tableVer > 0) { - throw new Exception('No upgrade path available. Please migrate to the latest 1.16+ version of SimpleSAMLphp first before upgrading to 2.x.'); + throw new Exception( + 'No upgrade path available. Please migrate to the latest 1.16+ ' + . 'version of SimpleSAMLphp first before upgrading to 2.x.' + ); } $text_t = 'TEXT'; diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index dbddd18b4c0ad2041487aa8b53b0ab35b8f02b3a..278211d6a454a8afa67c4adb98e30565754814a8 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -666,7 +666,7 @@ class HTTP $protocol .= ($this->getServerHTTPS()) ? 's' : ''; $protocol .= '://'; - $hostname =$this->getServerHost(); + $hostname = $this->getServerHost(); $port = $this->getServerPort(); $path = $globalConfig->getBasePath(); diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 24ee27082e132ce91967d193dd68a7e58ecf74d6..c490e08c6babc30da7947e4a05c2fbd5ec7c695e 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -360,7 +360,13 @@ class Template extends Response $themeDir = Module::getModuleDir($this->theme['module']) . '/themes/' . $this->theme['name']; $subdirs = @scandir($themeDir); if (empty($subdirs)) { - Logger::warning('Theme directory for theme "' . $this->theme['name'] . '" (' . $themeDir . ') is not readable or is empty.'); + Logger::warning( + sprintf( + 'Theme directory for theme "%s" (%s) is not readable or is empty.', + $this->theme['name'], + $themeDir + ) + ); return []; } @@ -602,7 +608,7 @@ class Template extends Response { $tryLanguages = $this->translator->getLanguage()->getPreferredLanguages(); - foreach($tryLanguages as $language) { + foreach ($tryLanguages as $language) { if (isset($data['UIInfo']['DisplayName'][$language])) { return $data['UIInfo']['DisplayName'][$language]; } elseif (isset($data['name'][$language])) { @@ -625,7 +631,7 @@ class Template extends Response { $tryLanguages = $this->translator->getLanguage()->getPreferredLanguages(); - foreach($tryLanguages as $language) { + foreach ($tryLanguages as $language) { if (isset($data[$property][$language])) { return $data[$property][$language]; } diff --git a/metadata-templates/saml20-sp-remote.php b/metadata-templates/saml20-sp-remote.php index c95da84d78072a8f757778eac4a2531df0362195..ef2f81e96fc7395c6292a212d49847e9cdfa1035 100644 --- a/metadata-templates/saml20-sp-remote.php +++ b/metadata-templates/saml20-sp-remote.php @@ -17,8 +17,9 @@ $metadata['https://saml2sp.example.org'] = [ /* * This example shows an example config that works with Google Workspace (G Suite / Google Apps) for education. * What is important is that you have an attribute in your IdP that maps to the local part of the email address at - * Google Workspace. In example, if your Google account is foo.com, and you have a user that has an email john@foo.com, then you - * must set the simplesaml.nameidattribute to be the name of an attribute that for this user has the value of 'john'. + * Google Workspace. In example, if your Google account is foo.com, and you have a user that has an email john@foo.com, + * then you must set the simplesaml.nameidattribute to be the name of an attribute that for this user has the + * value of 'john'. */ $metadata['google.com'] = [ 'AssertionConsumerService' => 'https://www.google.com/a/g.feide.no/acs', diff --git a/modules/admin/lib/Controller/Config.php b/modules/admin/lib/Controller/Config.php index b94d40f6d14548d6f7cd1927443777f653173e41..721d9b34e4a20a4d4a8592a3643a6dd4d0a9535b 100644 --- a/modules/admin/lib/Controller/Config.php +++ b/modules/admin/lib/Controller/Config.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Module\admin\Controller; +use Exception; use SimpleSAML\Configuration; use SimpleSAML\HTTP\RunnableResponse; use SimpleSAML\Locale\Translate; @@ -348,15 +349,15 @@ class Config $handler = MetaDataStorageHandler::getMetadataHandler(); try { $metadata = $handler->getMetaDataCurrent('saml20-idp-hosted'); - } catch (\Exception $e) { + } catch (Exception $e) { $matrix[] = [ 'required' => 'required', 'descr' => Translate::noop('Hosted IdP metadata present'), - 'enabled'=>false + 'enabled' => false ]; } - if(isset($metadata)) { + if (isset($metadata)) { $metadata_config = Configuration::loadfromArray($metadata); $private = $cryptoUtils->loadPrivateKey($metadata_config, false); $public = $cryptoUtils->loadPublicKey($metadata_config, false); @@ -387,7 +388,6 @@ class Config 'descr' => Translate::noop('Matching key-pair for signing metadata'), 'enabled' => $this->matchingKeyPair($public['PEM'], $private['PEM'], $private['password']), ]; - } return $matrix; @@ -496,7 +496,11 @@ class Config * @param string|null $password * @return bool */ - private function matchingKeyPair(string $publicKey, string $privateKey, ?string $password = null) : bool { + private function matchingKeyPair( + string $publicKey, + string $privateKey, + ?string $password = null + ): bool { return openssl_x509_check_private_key($publicKey, [$privateKey, $password]); } } diff --git a/modules/core/lib/Controller/Login.php b/modules/core/lib/Controller/Login.php index 8d08cf91b201e968971a3dc1ef19fbd84db01a90..26ea0131b4dd1f16cffc56f0451b97efc9045229 100644 --- a/modules/core/lib/Controller/Login.php +++ b/modules/core/lib/Controller/Login.php @@ -189,7 +189,7 @@ class Login $params = [ 'ErrorURL' => $url, 'ReturnTo' => $url, - ]; + ]; return new RunnableResponse([$auth, 'login'], [$params]); } diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index 295d8ae678fc94d2d0d01a4f9c5394a1ce308d6b..906b4173680d6f0f10f64f30164b0a3a449ba3cf 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -177,7 +177,7 @@ class MultiAuth extends Auth\Source Constants::STATUS_RESPONDER, 'No authentication sources exist for the requested AuthnContextClassRefs: ' . implode(', ', $refs) ); - } else if ($number_of_sources === 1) { + } elseif ($number_of_sources === 1) { MultiAuth::delegateAuthentication($new_sources[0]['source'], $state); } } diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index 2ff01ea528853e035b84f0f5a100f03eb2ed4804..3074dc85c4d184708c3c1bfb7349c922be2f88ff 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -243,7 +243,8 @@ class Message * @param \SimpleSAML\Configuration $srcMetadata The metadata of the sender (IdP). * @param \SimpleSAML\Configuration $dstMetadata The metadata of the recipient (SP). * @psalm-suppress UndefinedDocblockClass This can be removed after upgrading to saml2v5 - * @param \SimpleSAML\SAML2\XML\xenc\EncryptionMethod|null $encryptionMethod The EncryptionMethod from the assertion. + * @param \SimpleSAML\SAML2\XML\xenc\EncryptionMethod|null $encryptionMethod + * The EncryptionMethod from the assertion. * * @return array Array of decryption keys. */ diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index e6205ce6e7c35c788fc76c8ad3ab0be3059f882b..6911e0eb70b452dafc8fd48c1c592e50408cce50 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -35,7 +35,10 @@ class LogoutStore if ($tableVer === 4) { return; } elseif ($tableVer < 4 && $tableVer > 0) { - throw new Exception('No upgrade path available. Please migrate to the latest 1.18+ version of SimpleSAMLphp first before upgrading to 2.x.'); + throw new Exception( + 'No upgrade path available. Please migrate to the latest 1.18+ ' + . 'version of SimpleSAMLphp first before upgrading to 2.x.' + ); } $query = 'CREATE TABLE ' . $store->prefix . '_saml_LogoutStore ( diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e916d45f3ac24b4875a40250ae92acc4e72dea9d..76e5b5f97efa2ff1f6ebd08a0b32009a64f0de9b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,4 +11,3 @@ include($projectRoot . '/tests/Utils/ClearStateTestCase.php'); // set the SAML2 container $container = new \SimpleSAML\Compat\SspContainer(); \SAML2\Compat\ContainerSingleton::setContainer($container); - diff --git a/tests/lib/SimpleSAML/Locale/LanguageTest.php b/tests/lib/SimpleSAML/Locale/LanguageTest.php index c82cd1ffdd88a215014c908804cf974458055cef..5893a72b7c1a7351285e09765971ddbdd3e41ee8 100644 --- a/tests/lib/SimpleSAML/Locale/LanguageTest.php +++ b/tests/lib/SimpleSAML/Locale/LanguageTest.php @@ -195,5 +195,4 @@ class LanguageTest extends TestCase $l->setLanguage('nn'); $this->assertEquals([0 => 'nn', 2 => 'en'], $l->getPreferredLanguages()); } - } diff --git a/tests/lib/SimpleSAML/Utils/CryptoTest.php b/tests/lib/SimpleSAML/Utils/CryptoTest.php index dcc25aebe4a4882f37e2bb0f0ea1075031f44410..cdf10416227d5112523c08b755b9227a63606a67 100644 --- a/tests/lib/SimpleSAML/Utils/CryptoTest.php +++ b/tests/lib/SimpleSAML/Utils/CryptoTest.php @@ -188,7 +188,10 @@ CIPHER; */ public function testFormatConversion(): void { - $this->assertEquals(trim($this->pem), trim($this->cryptoUtils->der2pem($this->cryptoUtils->pem2der($this->pem)))); + $this->assertEquals( + trim($this->pem), + trim($this->cryptoUtils->der2pem($this->cryptoUtils->pem2der($this->pem))) + ); } diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php index 71fd7ca2bbfb7fa5a85b37934aa4909b71bfd578..03a40a7b4d50fee8d97a7fb82736d79755e154a4 100644 --- a/tests/lib/SimpleSAML/Utils/HTTPTest.php +++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php @@ -215,7 +215,10 @@ class HTTPTest extends ClearStateTestCase $httpUtils->getSelfURL() ); $this->assertEquals('https://example.com', $httpUtils->getSelfURLHost()); - $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php', $httpUtils->getSelfURLNoQuery()); + $this->assertEquals( + 'https://example.com/simplesaml/module.php/module/file.php', + $httpUtils->getSelfURLNoQuery() + ); $this->assertTrue($httpUtils->isHTTPS()); $this->assertEquals('https://' . $httpUtils->getSelfHostWithNonStandardPort(), $httpUtils->getSelfURLHost()); @@ -228,7 +231,10 @@ class HTTPTest extends ClearStateTestCase $httpUtils->getSelfURL() ); $this->assertEquals('https://example.com', $httpUtils->getSelfURLHost()); - $this->assertEquals('https://example.com/simplesaml/module.php/module/file.php', $httpUtils->getSelfURLNoQuery()); + $this->assertEquals( + 'https://example.com/simplesaml/module.php/module/file.php', + $httpUtils->getSelfURLNoQuery() + ); $this->assertTrue($httpUtils->isHTTPS()); $this->assertEquals('https://' . $httpUtils->getSelfHostWithNonStandardPort(), $httpUtils->getSelfURLHost()); @@ -255,7 +261,10 @@ class HTTPTest extends ClearStateTestCase $httpUtils->getSelfURL() ); $this->assertEquals('http://www.example.org', $httpUtils->getSelfURLHost()); - $this->assertEquals('http://www.example.org/simplesaml/module.php/module/file.php', $httpUtils->getSelfURLNoQuery()); + $this->assertEquals( + 'http://www.example.org/simplesaml/module.php/module/file.php', + $httpUtils->getSelfURLNoQuery() + ); $this->assertFalse($httpUtils->isHTTPS()); $this->assertEquals('http://' . $httpUtils->getSelfHostWithNonStandardPort(), $httpUtils->getSelfURLHost()); @@ -269,7 +278,10 @@ class HTTPTest extends ClearStateTestCase $httpUtils->getSelfURL() ); $this->assertEquals('http://example.org:8080', $httpUtils->getSelfURLHost()); - $this->assertEquals('http://example.org:8080/simplesaml/module.php/module/file.php', $httpUtils->getSelfURLNoQuery()); + $this->assertEquals( + 'http://example.org:8080/simplesaml/module.php/module/file.php', + $httpUtils->getSelfURLNoQuery() + ); $this->assertFalse($httpUtils->isHTTPS()); $this->assertEquals('http://' . $httpUtils->getSelfHostWithNonStandardPort(), $httpUtils->getSelfURLHost()); diff --git a/tests/lib/SimpleSAML/Utils/TimeTest.php b/tests/lib/SimpleSAML/Utils/TimeTest.php index c50e3144e42f245d4f442254798c5f1635883f0d..b3d04f6a720dcd26ded55456e94259b225a0e163 100644 --- a/tests/lib/SimpleSAML/Utils/TimeTest.php +++ b/tests/lib/SimpleSAML/Utils/TimeTest.php @@ -28,7 +28,10 @@ class TimeTest extends TestCase $this->assertEquals('2016-03-03T14:48:05Z', $timeUtils->generateTimestamp(1457016485)); // test timestamp generation for current time - $this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', $timeUtils->generateTimestamp()); + $this->assertMatchesRegularExpression( + '/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', + $timeUtils->generateTimestamp() + ); } @@ -101,25 +104,53 @@ class TimeTest extends TestCase $this->assertEquals($base + (60 * 60) + 60 + 1, $timeUtils->parseDuration('P0Y0M0DT1H1M1S', $base)); // test seconds - $this->assertEquals($second, $timeUtils->parseDuration('PT1S', $base), "Failure checking for 1 second duration."); + $this->assertEquals( + $second, + $timeUtils->parseDuration('PT1S', $base), + "Failure checking for 1 second duration." + ); // test minutes - $this->assertEquals($minute, $timeUtils->parseDuration('PT1M', $base), "Failure checking for 1 minute duration."); + $this->assertEquals( + $minute, + $timeUtils->parseDuration('PT1M', $base), + "Failure checking for 1 minute duration." + ); // test hours - $this->assertEquals($hour, $timeUtils->parseDuration('PT1H', $base), "Failure checking for 1 hour duration."); + $this->assertEquals( + $hour, + $timeUtils->parseDuration('PT1H', $base), + "Failure checking for 1 hour duration." + ); // test days - $this->assertEquals($day, $timeUtils->parseDuration('P1D', $base), "Failure checking for 1 day duration."); + $this->assertEquals( + $day, + $timeUtils->parseDuration('P1D', $base), + "Failure checking for 1 day duration." + ); // test weeks - $this->assertEquals($week, $timeUtils->parseDuration('P1W', $base), "Failure checking for 1 week duration."); + $this->assertEquals( + $week, + $timeUtils->parseDuration('P1W', $base), + "Failure checking for 1 week duration." + ); // test month - $this->assertEquals($month, $timeUtils->parseDuration('P1M', $base), "Failure checking for 1 month duration."); + $this->assertEquals( + $month, + $timeUtils->parseDuration('P1M', $base), + "Failure checking for 1 month duration." + ); // test year - $this->assertEquals($year, $timeUtils->parseDuration('P1Y', $base), "Failure checking for 1 year duration."); + $this->assertEquals( + $year, + $timeUtils->parseDuration('P1Y', $base), + "Failure checking for 1 year duration." + ); // test months > 12 $this->assertEquals( diff --git a/tests/lib/SimpleSAML/XHTML/TemplateTest.php b/tests/lib/SimpleSAML/XHTML/TemplateTest.php index 0e84f40f0243d4c023e195a0030f6bcf16c0550d..320f1714148eb10b6b43ba78e547dc006267fd2b 100644 --- a/tests/lib/SimpleSAML/XHTML/TemplateTest.php +++ b/tests/lib/SimpleSAML/XHTML/TemplateTest.php @@ -16,28 +16,28 @@ class TemplateTest extends TestCase { private const TEMPLATE = 'sandbox.twig'; - function testSetup(): void + public function testSetup(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, self::TEMPLATE); $this->assertEquals(self::TEMPLATE, $t->getTemplateName()); } - function testNormalizeName(): void + public function testNormalizeName(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, 'sandbox'); $this->assertEquals(self::TEMPLATE, $t->getTemplateName()); } - function testTemplateModuleNamespace(): void + public function testTemplateModuleNamespace(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, 'core:login'); $this->assertEquals('core:login.twig', $t->getTemplateName()); } - function testGetEntityDisplayNameBasic(): void + public function testGetEntityDisplayNameBasic(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, self::TEMPLATE); @@ -55,7 +55,7 @@ class TemplateTest extends TestCase $this->assertEquals('Something', $name); } - function testGetEntityDisplayNamePriorities(): void + public function testGetEntityDisplayNamePriorities(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, self::TEMPLATE); @@ -73,7 +73,7 @@ class TemplateTest extends TestCase $this->assertEquals('urn:example.org', $name); $data['OrganizationName']['en'] = 'Example Org EN'; - + $name = $t->getEntityDisplayName($data); $this->assertEquals('Example Org EN', $name); @@ -88,7 +88,7 @@ class TemplateTest extends TestCase $this->assertEquals('UIname NL', $name); } - function testGetEntityPropertyTranslation(): void + public function testGetEntityPropertyTranslation(): void { $c = Configuration::loadFromArray([], '', 'simplesaml'); $t = new Template($c, self::TEMPLATE); diff --git a/tests/modules/exampleauth/lib/Controller/ExampleAuthTest.php b/tests/modules/exampleauth/lib/Controller/ExampleAuthTest.php index 3772184d900b4c32c7498cb93d84db355d283028..53fd690fe027d591faa61ec50eb31358965a2686 100644 --- a/tests/modules/exampleauth/lib/Controller/ExampleAuthTest.php +++ b/tests/modules/exampleauth/lib/Controller/ExampleAuthTest.php @@ -150,7 +150,8 @@ class ExampleAuthTest extends TestCase /** - * Test that accessing the authpage-endpoint using POST-method and an incorrect password shows the login-screen again + * Test that accessing the authpage-endpoint using POST-method and + * an incorrect password shows the login-screen again * * @return void */ diff --git a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php index 2730453c3bb554b9f87f97dbe12e3d086a7a8df7..12deb77aad9c8ba69f9b34b47bc71c74015317a5 100644 --- a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php +++ b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php @@ -159,7 +159,6 @@ class FilterScopesTest extends TestCase ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); - } /** diff --git a/tests/modules/saml/lib/Auth/Source/SPTest.php b/tests/modules/saml/lib/Auth/Source/SPTest.php index 312895a7f84e40b99ec8f40f3a6a3347597a10a3..0e9c28a5f6883728186daee197668c430edcefb1 100644 --- a/tests/modules/saml/lib/Auth/Source/SPTest.php +++ b/tests/modules/saml/lib/Auth/Source/SPTest.php @@ -458,8 +458,11 @@ class SPTest extends ClearStateTestCase $this->assertIsArray($md['SingleLogoutService']); $this->assertArrayHasKey('AssertionConsumerService', $md); $this->assertIsArray($md['AssertionConsumerService']); - foreach($md['AssertionConsumerService'] as $acs) { - $this->assertEquals('http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/' . $spId, $acs['Location']); + foreach ($md['AssertionConsumerService'] as $acs) { + $this->assertEquals( + 'http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/' . $spId, + $acs['Location'] + ); $this->assertStringStartsWith('urn:oasis:names:tc:SAML:2.0:bindings', $acs['Binding']); $this->assertIsInt($acs['index']); } @@ -522,7 +525,10 @@ class SPTest extends ClearStateTestCase $this->assertEquals('+31SECOPS', $contact['telephoneNumber']); $this->assertEquals('Acme Inc', $contact['company']); $this->assertIsArray($contact['attributes']); - $attrs = ['xmlns:remd' => 'http://refeds.org/metadata', 'remd:contactType' => 'http://refeds.org/metadata/contactType/security']; + $attrs = [ + 'xmlns:remd' => 'http://refeds.org/metadata', + 'remd:contactType' => 'http://refeds.org/metadata/contactType/security' + ]; $this->assertEquals($attrs, $contact['attributes']); $contact = $md['contacts'][1]; @@ -645,7 +651,10 @@ class SPTest extends ClearStateTestCase $md = $as->getHostedMetadata(); $this->assertCount(1, $md['AssertionConsumerService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['AssertionConsumerService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['AssertionConsumerService'][0]['Binding'] + ); } /** @@ -670,7 +679,10 @@ class SPTest extends ClearStateTestCase $md = $as->getHostedMetadata(); $this->assertCount(1, $md['AssertionConsumerService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['AssertionConsumerService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['AssertionConsumerService'][0]['Binding'] + ); } /** @@ -687,7 +699,10 @@ class SPTest extends ClearStateTestCase $md = $as->getHostedMetadata(); $this->assertCount(1, $md['SingleLogoutService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['SingleLogoutService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['SingleLogoutService'][0]['Binding'] + ); } /** @@ -714,13 +729,19 @@ class SPTest extends ClearStateTestCase $spId = 'myhosted-sp'; $info = ['AuthId' => $spId]; $config = [ - 'SingleLogoutServiceBinding' => ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', 'urn:this:doesnotexist'], - ]; + 'SingleLogoutServiceBinding' => [ + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + 'urn:this:doesnotexist' + ], + ]; $as = new SpTester($info, $config); $md = $as->getHostedMetadata(); $this->assertCount(2, $md['SingleLogoutService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['SingleLogoutService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['SingleLogoutService'][0]['Binding'] + ); $this->assertEquals('urn:this:doesnotexist', $md['SingleLogoutService'][1]['Binding']); } @@ -732,14 +753,20 @@ class SPTest extends ClearStateTestCase $spId = 'myhosted-sp'; $info = ['AuthId' => $spId]; $config = [ - 'SingleLogoutServiceBinding' => ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', 'urn:this:doesnotexist'], - 'SingleLogoutServiceLocation' => 'https://sp.example.org/logout', - ]; + 'SingleLogoutServiceBinding' => [ + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + 'urn:this:doesnotexist' + ], + 'SingleLogoutServiceLocation' => 'https://sp.example.org/logout', + ]; $as = new SpTester($info, $config); $md = $as->getHostedMetadata(); $this->assertCount(2, $md['SingleLogoutService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['SingleLogoutService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['SingleLogoutService'][0]['Binding'] + ); $this->assertEquals('urn:this:doesnotexist', $md['SingleLogoutService'][1]['Binding']); $this->assertEquals('https://sp.example.org/logout', $md['SingleLogoutService'][0]['Location']); $this->assertEquals('https://sp.example.org/logout', $md['SingleLogoutService'][1]['Location']); @@ -771,12 +798,18 @@ class SPTest extends ClearStateTestCase $md = $as->getHostedMetadata(); $this->assertCount(2, $md['AssertionConsumerService']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', $md['AssertionConsumerService'][0]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', + $md['AssertionConsumerService'][0]['Binding'] + ); $this->assertEquals('https://sp.example.org/ACS', $md['AssertionConsumerService'][0]['Location']); $this->assertEquals(1, $md['AssertionConsumerService'][0]['index']); $this->assertTrue($md['AssertionConsumerService'][0]['isDefault']); - $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', $md['AssertionConsumerService'][1]['Binding']); + $this->assertEquals( + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', + $md['AssertionConsumerService'][1]['Binding'] + ); $this->assertEquals('https://sp.example.org/ACSeventeen', $md['AssertionConsumerService'][1]['Location']); $this->assertEquals(17, $md['AssertionConsumerService'][1]['index']); $this->assertArrayNotHasKey('isDefault', $md['AssertionConsumerService'][1]);