From df789f6394bc465725d4a511f8caf1e6cd5ad2f3 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 16 Nov 2026 14:00:37 +0000 Subject: [PATCH] Fix reversed str_contains in debug mode error handling and report suppressed deprecations in tests --- docs/ChangeLog.md | 6 +++++ phpunit.xml | 3 ++- src/Controller/LoginController.php | 7 +++--- tests/src/Controller/LoginControllerTest.php | 24 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index b998f4c..2c7aa8a 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -6,6 +6,12 @@ - Debug mode (`debugMode=true`) now validates the ticket with the query parameters login used to issue it, so it works for a service given as `TARGET` and with `renew` set, and ignores parameters in the request body (Marko Ivančić) +- Debug mode no longer passes the validation XML to the error template for an unsupported debug mode + (the `str_contains()` check for the error template had its arguments reversed) + +### Changed + +- The test suite now reports deprecations, including those triggered with `@` such as Symfony's `trigger_deprecation()` ## [7.0.6] - 2026-11-10 diff --git a/phpunit.xml b/phpunit.xml index 8e3a666..f88e7aa 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,6 +5,7 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" backupGlobals="false" displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnTestsThatTriggerDeprecations="true" cacheDirectory=".phpunit.cache"> @@ -19,7 +20,7 @@ - + ./src diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 0ebd646..585e4f3 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -115,17 +115,18 @@ public function __construct( * @param bool $renew * @param bool $gateway * @param string|null $service - * @param string|null $TARGET Query parameter name for "service" used by older CAS clients' + * @param string|null $TARGET Query parameter name for "service" used by older CAS clients' * @param string|null $scope * @param string|null $language * @param string|null $entityId * @param string|null $debugMode * @param string|null $method - * @param string|null $pgtUrl Only used by debug mode, which passes it on to the ticket validation + * @param string|null $pgtUrl Only used by debug mode, which passes it on to the ticket validation * * @return \SimpleSAML\HTTP\RunnableResponse|\SimpleSAML\XHTML\Template * @throws \SimpleSAML\Error\ConfigurationError * @throws \SimpleSAML\Error\NoState + * @throws \Exception */ public function login( Request $request, @@ -268,7 +269,7 @@ public function login( ); $t = new Template($this->sspConfig, (string)$templateName); $t->data['debugMode'] = $debugMode === 'true' ? 'Default' : $debugMode; - if (!str_contains('error', (string)$templateName)) { + if (!str_contains((string)$templateName, 'error')) { $t->data['DebugModeXml'] = $DebugModeXmlString; } $t->data['statusCode'] = $statusCode; diff --git a/tests/src/Controller/LoginControllerTest.php b/tests/src/Controller/LoginControllerTest.php index 9ed9e08..c5dacb6 100644 --- a/tests/src/Controller/LoginControllerTest.php +++ b/tests/src/Controller/LoginControllerTest.php @@ -928,6 +928,30 @@ public function testDebugModeIgnoresTheRequestBody(array $queryParams, array $bo } + /** + * An unsupported debug mode renders the error template, without any XML to show. + * + * @throws \Exception + */ + public function testUnsupportedDebugModeRendersTheErrorWithoutXml(): void + { + $requestParams = [ + 'service' => 'https://example.com/ssp/module.php/cas/linkback.php', + 'debugMode' => 'unsupported', + ]; + $loginRequest = Request::create( + uri: Module::getModuleURL('casserver/login'), + parameters: $requestParams, + ); + $response = $this->callLogin($this->createDebugModeController(), $loginRequest, $requestParams); + + $this->assertInstanceOf(Template::class, $response); + $this->assertSame(Response::HTTP_BAD_REQUEST, $response->data['statusCode']); + $this->assertSame('unsupported', $response->data['debugMode']); + $this->assertArrayNotHasKey('DebugModeXml', $response->data); + } + + /** * A controller with debug mode enabled, for a user with an SSO session. */