Skip to content

Commit 26a8c12

Browse files
committed
updates after the cherry pick for phpunit and phpcs to be happy
1 parent d86ab17 commit 26a8c12

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

modules/saml/src/Controller/ServiceProvider.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,10 @@ protected function loginHandler(
180180
/**
181181
* Try to authenticate
182182
*/
183-
$authSource->requireAuth($options);
184-
185-
$response = $as->requireAuth($options);
183+
$response = $authSource->requireAuth($options);
186184
if ($response === null) {
187185
// We are already authenticated
188-
return $httpUtils->redirectTrustedURL($returnTo);
186+
return $httpUtils->redirectTrustedURL($options['ReturnTo']);
189187
}
190188

191189
return $response;

tests/modules/saml/src/Controller/ServiceProviderTest.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function callHandleLogin(
103103
Auth\Simple $authSource,
104104
Auth\Source $spSource,
105105
Utils\HTTP $httpUtils
106-
): string {
106+
): RedirectResponse {
107107
return $this->loginHandler($request, $authSource, $spSource, $httpUtils);
108108
}
109109
};
@@ -236,58 +236,58 @@ public static function loginNotAuthenticatedDataProvider(): array
236236
'no query params' => [
237237
[], // If no query params are provided, it should default to the RelayState
238238
[
239-
'ReturnTo' => self::RELAY_STATE
240-
]
239+
'ReturnTo' => self::RELAY_STATE,
240+
],
241241
],
242242
'entityID=example.edu' => [
243243
[
244244
'entityID' => 'example.edu',
245245
],
246246
[
247247
'ReturnTo' => self::RELAY_STATE,
248-
'saml:idp' => 'example.edu'
249-
]
248+
'saml:idp' => 'example.edu',
249+
],
250250
],
251251
'entityID=example.edu&forceAuthn=false&isPassive=false' => [
252252
[
253253
'entityID' => 'example.edu',
254254
'forceAuthn' => 'false',
255-
'isPassive' => 'false'
255+
'isPassive' => 'false',
256256
],
257257
[
258258
'ReturnTo' => self::RELAY_STATE,
259259
'saml:idp' => 'example.edu',
260260
'ForceAuthn' => false,
261-
'isPassive' => false
262-
]
261+
'isPassive' => false,
262+
],
263263
],
264264
'entityID=other.edu' => [
265265
[
266266
'entityID' => 'other.edu',
267267
],
268268
[
269269
'ReturnTo' => self::RELAY_STATE,
270-
'saml:idp' => 'other.edu'
271-
]
270+
'saml:idp' => 'other.edu',
271+
],
272272
],
273273
'forceAuthn=true&target=/some/url' => [
274274
[
275275
'target' => '/some/url',
276-
'forceAuthn' => 'true'
276+
'forceAuthn' => 'true',
277277
],
278278
[
279279
'ReturnTo' => 'http://localhost/some/url',
280-
'ForceAuthn' => true
280+
'ForceAuthn' => true,
281281
],
282-
false
282+
false,
283283
],
284284
'target=https://evil.com' => [
285285
[
286-
'target' => 'https://evil.com'
286+
'target' => 'https://evil.com',
287287
],
288288
[],
289-
true
290-
]
289+
true,
290+
],
291291
];
292292
}
293293

@@ -339,7 +339,8 @@ public function testLoginHandleNotAuthenticated(
339339
$as->expects($this->once())->method('requireAuth')->with($options);
340340
/** @psalm-suppress UndefinedMethod method defined in anonymous class */
341341
$returnsTo = $this->serviceProvider
342-
->callHandleLogin($request, $as, $spSource, $this->httpUtils);
342+
->callHandleLogin($request, $as, $spSource, $this->httpUtils)
343+
->getTargetUrl();
343344
$this->assertEquals($options['ReturnTo'], $returnsTo);
344345
}
345346
}
@@ -355,7 +356,7 @@ public static function loginAuthenticatedDataProvider(): array
355356
[
356357
'ReturnTo' => self::RELAY_STATE,
357358
],
358-
false
359+
false,
359360
],
360361
'entityID=example.edu' => [
361362
[
@@ -364,48 +365,48 @@ public static function loginAuthenticatedDataProvider(): array
364365
[
365366
'ReturnTo' => self::RELAY_STATE,
366367
],
367-
false
368+
false,
368369
],
369370
'entityID=example.edu&forceAuthn=false&isPassive=false' => [
370371
[
371372
'entityID' => 'example.edu',
372373
'forceAuthn' => 'false',
373-
'isPassive' => 'false'
374+
'isPassive' => 'false',
374375
],
375376
[
376377
'ReturnTo' => self::RELAY_STATE,
377378
],
378-
false
379+
false,
379380
],
380381
'entityID=other.edu' => [
381382
[
382383
'entityID' => 'other.edu',
383384
],
384385
[
385386
'ReturnTo' => self::RELAY_STATE,
386-
'saml:idp' => 'other.edu'
387+
'saml:idp' => 'other.edu',
387388
],
388-
true
389+
true,
389390
],
390391
'forceAuthn=true&target=/some/url' => [
391392
[
392393
'target' => '/some/url',
393-
'forceAuthn' => 'true'
394+
'forceAuthn' => 'true',
394395
],
395396
[
396397
'ReturnTo' => 'http://localhost/some/url',
397-
'ForceAuthn' => true
398+
'ForceAuthn' => true,
398399
],
399-
true
400+
true,
400401
],
401402
'target=https://evil.com' => [
402403
[
403-
'target' => 'https://evil.com'
404+
'target' => 'https://evil.com',
404405
],
405406
[],
406407
false,
407-
true
408-
]
408+
true,
409+
],
409410
];
410411
}
411412

@@ -463,7 +464,8 @@ public function testLoginHandleAuthenticated(
463464
}
464465
/** @psalm-suppress UndefinedMethod method defined in anonymous class */
465466
$returnsTo = $this->serviceProvider
466-
->callHandleLogin($request, $as, $spSource, $this->httpUtils);
467+
->callHandleLogin($request, $as, $spSource, $this->httpUtils)
468+
->getTargetUrl();
467469
$this->assertEquals($options['ReturnTo'], $returnsTo);
468470
}
469471
}

0 commit comments

Comments
 (0)