Skip to content

Commit 89e05f4

Browse files
committed
Make explicit what part of the config is wrong when non-array endpoint type encountered (#2335)
1 parent 818c9b4 commit 89e05f4

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/SimpleSAML/Configuration.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,9 +1204,14 @@ public function getEndpoints(string $endpointType): array
12041204
return [];
12051205
}
12061206

1207-
12081207
$eps = $this->configuration[$endpointType];
1209-
Assert::isArray($eps, Error\CriticalConfigurationError::class);
1208+
if (!is_array($eps)) {
1209+
$filename = explode('/', $loc)[0];
1210+
throw new Error\CriticalConfigurationError(
1211+
"Endpoint of type $endpointType is not an array in $loc.",
1212+
$filename,
1213+
);
1214+
}
12101215

12111216
$eps_count = count($eps);
12121217

tests/src/SimpleSAML/ConfigurationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ public function testGetEndpoints(): void
974974

975975
// define a set of exception messages to expect
976976
$msgs = [
977-
'The configuration is invalid: Expected an array. Got: integer',
977+
"The configuration ([ARRAY]['SingleSignOnService']:) is invalid: Endpoint of type " .
978+
"SingleSignOnService is not an array in [ARRAY]['SingleSignOnService']:.",
978979
'Expected a string or an array.',
979980
'Missing Location.',
980981
'Location must be a string.',

0 commit comments

Comments
 (0)