Skip to content

Commit c1dd40a

Browse files
authored
Fix reversed str_contains in debug mode error handling and report suppressed deprecations in tests (#88)
1 parent 0b2678f commit c1dd40a

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

‎docs/ChangeLog.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
- Debug mode (`debugMode=true`) now validates the ticket with the query parameters login used to issue it,
88
so it works for a service given as `TARGET` and with `renew` set, and ignores parameters in the request body (Marko Ivančić)
9+
- Debug mode no longer passes the validation XML to the error template for an unsupported debug mode
10+
(the `str_contains()` check for the error template had its arguments reversed)
11+
12+
### Changed
13+
14+
- The test suite now reports deprecations, including those triggered with `@` such as Symfony's `trigger_deprecation()`
915

1016
## [7.0.6] - 2026-11-10
1117

‎phpunit.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
66
backupGlobals="false"
77
displayDetailsOnTestsThatTriggerWarnings="true"
8+
displayDetailsOnTestsThatTriggerDeprecations="true"
89
cacheDirectory=".phpunit.cache">
910
<coverage>
1011
<report>
@@ -19,7 +20,7 @@
1920
</testsuite>
2021
</testsuites>
2122
<logging/>
22-
<source>
23+
<source ignoreSuppressionOfDeprecations="true">
2324
<include>
2425
<directory suffix=".php">./src</directory>
2526
</include>

‎src/Controller/LoginController.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,18 @@ public function __construct(
115115
* @param bool $renew
116116
* @param bool $gateway
117117
* @param string|null $service
118-
* @param string|null $TARGET Query parameter name for "service" used by older CAS clients'
118+
* @param string|null $TARGET Query parameter name for "service" used by older CAS clients'
119119
* @param string|null $scope
120120
* @param string|null $language
121121
* @param string|null $entityId
122122
* @param string|null $debugMode
123123
* @param string|null $method
124-
* @param string|null $pgtUrl Only used by debug mode, which passes it on to the ticket validation
124+
* @param string|null $pgtUrl Only used by debug mode, which passes it on to the ticket validation
125125
*
126126
* @return \SimpleSAML\HTTP\RunnableResponse|\SimpleSAML\XHTML\Template
127127
* @throws \SimpleSAML\Error\ConfigurationError
128128
* @throws \SimpleSAML\Error\NoState
129+
* @throws \Exception
129130
*/
130131
public function login(
131132
Request $request,
@@ -268,7 +269,7 @@ public function login(
268269
);
269270
$t = new Template($this->sspConfig, (string)$templateName);
270271
$t->data['debugMode'] = $debugMode === 'true' ? 'Default' : $debugMode;
271-
if (!str_contains('error', (string)$templateName)) {
272+
if (!str_contains((string)$templateName, 'error')) {
272273
$t->data['DebugModeXml'] = $DebugModeXmlString;
273274
}
274275
$t->data['statusCode'] = $statusCode;

‎tests/src/Controller/LoginControllerTest.php‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,30 @@ public function testDebugModeIgnoresTheRequestBody(array $queryParams, array $bo
928928
}
929929

930930

931+
/**
932+
* An unsupported debug mode renders the error template, without any XML to show.
933+
*
934+
* @throws \Exception
935+
*/
936+
public function testUnsupportedDebugModeRendersTheErrorWithoutXml(): void
937+
{
938+
$requestParams = [
939+
'service' => 'https://example.com/ssp/module.php/cas/linkback.php',
940+
'debugMode' => 'unsupported',
941+
];
942+
$loginRequest = Request::create(
943+
uri: Module::getModuleURL('casserver/login'),
944+
parameters: $requestParams,
945+
);
946+
$response = $this->callLogin($this->createDebugModeController(), $loginRequest, $requestParams);
947+
948+
$this->assertInstanceOf(Template::class, $response);
949+
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->data['statusCode']);
950+
$this->assertSame('unsupported', $response->data['debugMode']);
951+
$this->assertArrayNotHasKey('DebugModeXml', $response->data);
952+
}
953+
954+
931955
/**
932956
* A controller with debug mode enabled, for a user with an SSO session.
933957
*/

0 commit comments

Comments
 (0)