diff --git a/src/AuthenticationService.php b/src/AuthenticationService.php index f41c76cd..8560e783 100644 --- a/src/AuthenticationService.php +++ b/src/AuthenticationService.php @@ -197,7 +197,7 @@ public function authenticate(ServerRequestInterface $request): ResultInterface if ($result === null) { throw new RuntimeException( - 'No authenticators loaded. You need to load at least one authenticator.' + 'No authenticators loaded. You need to load at least one authenticator.', ); } @@ -247,7 +247,7 @@ public function clearIdentity(ServerRequestInterface $request, ResponseInterface public function persistIdentity( ServerRequestInterface $request, ResponseInterface $response, - ArrayAccess|array $identity + ArrayAccess|array $identity, ): array { foreach ($this->authenticators() as $authenticator) { if ($authenticator instanceof PersistenceInterface) { @@ -348,7 +348,7 @@ public function buildIdentity(ArrayAccess|array $identityData): IdentityInterfac throw new RuntimeException(sprintf( 'Object `%s` does not implement `%s`', get_class($identity), - IdentityInterface::class + IdentityInterface::class, )); } @@ -450,7 +450,7 @@ public function impersonate( ServerRequestInterface $request, ResponseInterface $response, ArrayAccess $impersonator, - ArrayAccess $impersonated + ArrayAccess $impersonated, ): array { $provider = $this->getImpersonationProvider(); @@ -499,7 +499,7 @@ protected function getImpersonationProvider(): ImpersonationInterface if (!($provider instanceof ImpersonationInterface)) { $className = get_class($provider); throw new InvalidArgumentException( - "The {$className} Provider must implement ImpersonationInterface in order to use impersonation." + "The {$className} Provider must implement ImpersonationInterface in order to use impersonation.", ); } diff --git a/src/Authenticator/CookieAuthenticator.php b/src/Authenticator/CookieAuthenticator.php index b820b393..e678987c 100644 --- a/src/Authenticator/CookieAuthenticator.php +++ b/src/Authenticator/CookieAuthenticator.php @@ -238,7 +238,7 @@ protected function _createCookie(mixed $value): CookieInterface return Cookie::create( $name, $value, - $options + $options, ); } } diff --git a/src/Authenticator/EnvironmentAuthenticator.php b/src/Authenticator/EnvironmentAuthenticator.php index b830ed2a..ceafd958 100644 --- a/src/Authenticator/EnvironmentAuthenticator.php +++ b/src/Authenticator/EnvironmentAuthenticator.php @@ -118,7 +118,7 @@ protected function _buildLoginUrlErrorResult(ServerRequestInterface $request): R sprintf( 'Login URL `%s` did not match `%s`.', $uri, - implode('` or `', (array)$this->getConfig('loginUrl')) + implode('` or `', (array)$this->getConfig('loginUrl')), ), ]; diff --git a/src/Authenticator/FormAuthenticator.php b/src/Authenticator/FormAuthenticator.php index ee25724d..eb970cee 100644 --- a/src/Authenticator/FormAuthenticator.php +++ b/src/Authenticator/FormAuthenticator.php @@ -100,7 +100,7 @@ protected function _buildLoginUrlErrorResult(ServerRequestInterface $request): R sprintf( 'Login URL `%s` did not match `%s`.', $uri, - implode('` or `', (array)$this->getConfig('loginUrl')) + implode('` or `', (array)$this->getConfig('loginUrl')), ), ]; diff --git a/src/Authenticator/HttpDigestAuthenticator.php b/src/Authenticator/HttpDigestAuthenticator.php index 4fa99e69..c5e053e3 100644 --- a/src/Authenticator/HttpDigestAuthenticator.php +++ b/src/Authenticator/HttpDigestAuthenticator.php @@ -185,7 +185,7 @@ public function generateResponseHash(array $digest, string $password, string $me return md5( $password . ':' . $digest['nonce'] . ':' . $digest['nc'] . ':' . $digest['cnonce'] . ':' . $digest['qop'] . ':' . - md5($method . ':' . $digest['uri']) + md5($method . ':' . $digest['uri']), ); } diff --git a/src/Authenticator/ImpersonationInterface.php b/src/Authenticator/ImpersonationInterface.php index 99fafc58..1a566384 100644 --- a/src/Authenticator/ImpersonationInterface.php +++ b/src/Authenticator/ImpersonationInterface.php @@ -35,7 +35,7 @@ public function impersonate( ServerRequestInterface $request, ResponseInterface $response, ArrayAccess $impersonator, - ArrayAccess $impersonated + ArrayAccess $impersonated, ): array; /** diff --git a/src/Authenticator/JwtAuthenticator.php b/src/Authenticator/JwtAuthenticator.php index 990f84c7..06be6164 100644 --- a/src/Authenticator/JwtAuthenticator.php +++ b/src/Authenticator/JwtAuthenticator.php @@ -84,7 +84,7 @@ public function authenticate(ServerRequestInterface $request): ResultInterface [ 'message' => $e->getMessage(), 'exception' => $e, - ] + ], ); } @@ -155,7 +155,7 @@ protected function decodeToken(string $token): ?object return JWT::decode( $token, - $keySet + $keySet, ); } diff --git a/src/Authenticator/PersistenceInterface.php b/src/Authenticator/PersistenceInterface.php index 15bacb19..3b9e7ee7 100644 --- a/src/Authenticator/PersistenceInterface.php +++ b/src/Authenticator/PersistenceInterface.php @@ -34,7 +34,7 @@ interface PersistenceInterface public function persistIdentity( ServerRequestInterface $request, ResponseInterface $response, - ArrayAccess|array $identity + ArrayAccess|array $identity, ): array; /** diff --git a/src/Authenticator/SessionAuthenticator.php b/src/Authenticator/SessionAuthenticator.php index 2181d163..cad0b9b0 100644 --- a/src/Authenticator/SessionAuthenticator.php +++ b/src/Authenticator/SessionAuthenticator.php @@ -133,7 +133,7 @@ public function impersonate( ServerRequestInterface $request, ResponseInterface $response, ArrayAccess $impersonator, - ArrayAccess $impersonated + ArrayAccess $impersonated, ): array { $sessionKey = $this->getConfig('sessionKey'); $impersonateSessionKey = $this->getConfig('impersonateSessionKey'); @@ -142,7 +142,7 @@ public function impersonate( if ($session->check($impersonateSessionKey)) { throw new UnauthorizedException( 'You are impersonating a user already. ' . - 'Stop the current impersonation before impersonating another user.' + 'Stop the current impersonation before impersonating another user.', ); } $session->write($impersonateSessionKey, $impersonator); diff --git a/src/Controller/Component/AuthenticationComponent.php b/src/Controller/Component/AuthenticationComponent.php index a9318340..d9ab5114 100644 --- a/src/Controller/Component/AuthenticationComponent.php +++ b/src/Controller/Component/AuthenticationComponent.php @@ -150,7 +150,7 @@ public function getAuthenticationService(): AuthenticationServiceInterface if ($service === null) { throw new Exception( 'The request object does not contain the required `authentication` attribute. Verify the ' . - 'AuthenticationMiddleware has been added.' + 'AuthenticationMiddleware has been added.', ); } @@ -303,7 +303,7 @@ public function setIdentity(ArrayAccess $identity) $result = $service->persistIdentity( $controller->getRequest(), $controller->getResponse(), - $identity + $identity, ); $controller->setRequest($result['request']); @@ -325,7 +325,7 @@ public function logout(): ?string /** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */ $result = $this->getAuthenticationService()->clearIdentity( $controller->getRequest(), - $controller->getResponse() + $controller->getResponse(), ); $controller->setRequest($result['request']); @@ -396,7 +396,7 @@ public function impersonate(ArrayAccess $impersonated) $controller->getRequest(), $controller->getResponse(), $impersonator, - $impersonated + $impersonated, ); if (!$service->isImpersonating($controller->getRequest())) { @@ -424,7 +424,7 @@ public function stopImpersonating() /** @psalm-var array{request: \Cake\Http\ServerRequest, response: \Cake\Http\Response} $result */ $result = $service->stopImpersonating( $controller->getRequest(), - $controller->getResponse() + $controller->getResponse(), ); if ($service->isImpersonating($controller->getRequest())) { @@ -453,7 +453,7 @@ public function isImpersonating(): bool $controller = $this->getController(); return $service->isImpersonating( - $controller->getRequest() + $controller->getRequest(), ); } @@ -469,7 +469,7 @@ protected function getImpersonationAuthenticationService(): ImpersonationInterfa if (!($service instanceof ImpersonationInterface)) { $className = get_class($service); throw new InvalidArgumentException( - "The {$className} must implement ImpersonationInterface in order to use impersonation." + "The {$className} must implement ImpersonationInterface in order to use impersonation.", ); } diff --git a/src/Identifier/CallbackIdentifier.php b/src/Identifier/CallbackIdentifier.php index cc6ccc3b..6b1509d9 100644 --- a/src/Identifier/CallbackIdentifier.php +++ b/src/Identifier/CallbackIdentifier.php @@ -58,7 +58,7 @@ protected function checkCallable(): void if (!is_callable($callback)) { throw new InvalidArgumentException(sprintf( 'The `callback` option is not a callable. Got `%s` instead.', - gettype($callback) + gettype($callback), )); } } @@ -83,7 +83,7 @@ public function identify(array $credentials): ArrayAccess|array|null throw new RuntimeException(sprintf( 'Invalid return type of `%s`. Expecting `%s` or `null`.', gettype($result), - ArrayAccess::class + ArrayAccess::class, )); } } diff --git a/src/Identifier/Ldap/ExtensionAdapter.php b/src/Identifier/Ldap/ExtensionAdapter.php index 3467970d..d9d2893f 100644 --- a/src/Identifier/Ldap/ExtensionAdapter.php +++ b/src/Identifier/Ldap/ExtensionAdapter.php @@ -184,7 +184,7 @@ protected function _setErrorHandler(): void function ($errorNumber, $errorText): void { throw new ErrorException($errorText); }, - E_ALL + E_ALL, ); } diff --git a/src/Identifier/LdapIdentifier.php b/src/Identifier/LdapIdentifier.php index e12a2e06..70398149 100644 --- a/src/Identifier/LdapIdentifier.php +++ b/src/Identifier/LdapIdentifier.php @@ -103,7 +103,7 @@ protected function _checkLdapConfig(): void if (!is_callable($this->_config['bindDN'])) { throw new InvalidArgumentException(sprintf( 'The `bindDN` config is not a callable. Got `%s` instead.', - gettype($this->_config['bindDN']) + gettype($this->_config['bindDN']), )); } if (!isset($this->_config['host'])) { @@ -126,7 +126,7 @@ protected function _buildLdapObject(): void if (!$class) { throw new RuntimeException(sprintf( 'Could not find LDAP identfier named `%s`', - $ldap + $ldap, )); } $ldap = new $class(); @@ -153,7 +153,7 @@ public function identify(array $credentials): ArrayAccess|array|null if ($isUsernameSet && $isPasswordSet) { return $this->_bindUser( $credentials[$fields[self::CREDENTIAL_USERNAME]], - $credentials[$fields[self::CREDENTIAL_PASSWORD]] + $credentials[$fields[self::CREDENTIAL_PASSWORD]], ); } @@ -182,7 +182,7 @@ protected function _connectLdap(): void $this->_ldap->connect( $config['host'], $config['port'], - (array)$this->getConfig('options') + (array)$this->getConfig('options'), ); } diff --git a/src/Identifier/TokenIdentifier.php b/src/Identifier/TokenIdentifier.php index 25cfcb45..29bef0d0 100644 --- a/src/Identifier/TokenIdentifier.php +++ b/src/Identifier/TokenIdentifier.php @@ -54,7 +54,7 @@ public function identify(array $credentials): ArrayAccess|array|null if ($this->getConfig('hashAlgorithm') !== null) { $credentials[$dataField] = Security::hash( $credentials[$dataField], - $this->getConfig('hashAlgorithm') + $this->getConfig('hashAlgorithm'), ); } diff --git a/src/Middleware/AuthenticationMiddleware.php b/src/Middleware/AuthenticationMiddleware.php index d987ad3f..e4ae26b9 100644 --- a/src/Middleware/AuthenticationMiddleware.php +++ b/src/Middleware/AuthenticationMiddleware.php @@ -59,7 +59,7 @@ class AuthenticationMiddleware implements MiddlewareInterface */ public function __construct( AuthenticationServiceInterface|AuthenticationServiceProviderInterface $subject, - ?ContainerInterface $container = null + ?ContainerInterface $container = null, ) { $this->subject = $subject; $this->container = $container; diff --git a/src/PasswordHasher/DefaultPasswordHasher.php b/src/PasswordHasher/DefaultPasswordHasher.php index 0c452118..0ec08354 100644 --- a/src/PasswordHasher/DefaultPasswordHasher.php +++ b/src/PasswordHasher/DefaultPasswordHasher.php @@ -48,7 +48,7 @@ public function hash(string $password): string return password_hash( $password, $this->_config['hashType'], - $this->_config['hashOptions'] + $this->_config['hashOptions'], ); } diff --git a/src/UrlChecker/UrlCheckerTrait.php b/src/UrlChecker/UrlCheckerTrait.php index fba0043b..36fe7be8 100644 --- a/src/UrlChecker/UrlCheckerTrait.php +++ b/src/UrlChecker/UrlCheckerTrait.php @@ -36,7 +36,7 @@ protected function _checkUrl(ServerRequestInterface $request): bool return $this->_getUrlChecker()->check( $request, $this->getConfig('loginUrl'), - (array)$this->getConfig('urlChecker') + (array)$this->getConfig('urlChecker'), ); } @@ -68,7 +68,7 @@ protected function _getUrlChecker(): UrlCheckerInterface throw new RuntimeException(sprintf( 'The provided URL checker class `%s` does not implement the `%s` interface.', $options['className'], - UrlCheckerInterface::class + UrlCheckerInterface::class, )); } diff --git a/src/View/Helper/IdentityHelper.php b/src/View/Helper/IdentityHelper.php index cf7ae038..42a8b24a 100644 --- a/src/View/Helper/IdentityHelper.php +++ b/src/View/Helper/IdentityHelper.php @@ -63,7 +63,7 @@ public function initialize(array $config): void if (!$this->_identity instanceof IdentityInterface) { throw new RuntimeException( - sprintf('Identity found in request does not implement %s', IdentityInterface::class) + sprintf('Identity found in request does not implement %s', IdentityInterface::class), ); } } diff --git a/tests/TestCase/AuthenticationServiceTest.php b/tests/TestCase/AuthenticationServiceTest.php index c8623ad5..4fa45df7 100644 --- a/tests/TestCase/AuthenticationServiceTest.php +++ b/tests/TestCase/AuthenticationServiceTest.php @@ -50,7 +50,7 @@ public function testAuthenticate() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $service = new AuthenticationService([ @@ -239,7 +239,7 @@ public function testClearIdentity() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -270,7 +270,7 @@ public function testClearIdentityWithCustomIdentityAttribute() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -301,7 +301,7 @@ public function testClearIdentityWithCustomIdentityAttributeShouldPreserveDefaul ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -336,7 +336,7 @@ public function testClearIdentityWithImpersonation() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -371,7 +371,7 @@ public function testPersistIdentity() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -389,7 +389,7 @@ public function testPersistIdentity() $this->assertSame( 'florian', - $result['request']->getAttribute('session')->read('Auth.username') + $result['request']->getAttribute('session')->read('Auth.username'), ); $identity = $result['request']->getAttribute('identity'); @@ -416,7 +416,7 @@ public function testPersistIdentityWithCustomIdentityAttribute() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -435,7 +435,7 @@ public function testPersistIdentityWithCustomIdentityAttribute() $this->assertSame( 'florian', - $result['request']->getAttribute('session')->read('Auth.username') + $result['request']->getAttribute('session')->read('Auth.username'), ); $identity = $result['request']->getAttribute('customIdentity'); @@ -463,7 +463,7 @@ public function testPersistIdentityWithCustomIdentityAttributeShouldPreserveDefa ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $response = new Response(); @@ -483,7 +483,7 @@ public function testPersistIdentityWithCustomIdentityAttributeShouldPreserveDefa $this->assertSame( 'florian', - $result['request']->getAttribute('session')->read('Auth.username') + $result['request']->getAttribute('session')->read('Auth.username'), ); $identity = $result['request']->getAttribute('customIdentity'); @@ -563,7 +563,7 @@ public function testGetResult() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $service = new AuthenticationService([ @@ -596,7 +596,7 @@ public function testNoAuthenticatorsLoadedException() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $service = new AuthenticationService([ @@ -672,7 +672,7 @@ public function testCallableIdentityProvider() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $callable = function () { @@ -707,7 +707,7 @@ public function testGetIdentity() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $service = new AuthenticationService([ @@ -794,7 +794,7 @@ public function testGetUnauthenticatedRedirectUrl() { $service = new AuthenticationService(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/secrets'] + ['REQUEST_URI' => '/secrets'], ); $service->setConfig('unauthenticatedRedirect', '/users/login'); $this->assertSame('/users/login', $service->getUnauthenticatedRedirectUrl($request)); @@ -802,26 +802,26 @@ public function testGetUnauthenticatedRedirectUrl() $service->setConfig('queryParam', 'redirect'); $this->assertSame( '/users/login?redirect=%2Fsecrets', - $service->getUnauthenticatedRedirectUrl($request) + $service->getUnauthenticatedRedirectUrl($request), ); $service->setConfig('unauthenticatedRedirect', '/users/login?foo=bar'); $this->assertSame( '/users/login?foo=bar&redirect=%2Fsecrets', - $service->getUnauthenticatedRedirectUrl($request) + $service->getUnauthenticatedRedirectUrl($request), ); $service->setConfig('unauthenticatedRedirect', '/users/login?foo=bar#fragment'); $this->assertSame( '/users/login?foo=bar&redirect=%2Fsecrets#fragment', - $service->getUnauthenticatedRedirectUrl($request) + $service->getUnauthenticatedRedirectUrl($request), ); } public function testGetUnauthenticatedRedirectUrlWithBasePath() { $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/secrets'] + ['REQUEST_URI' => '/secrets'], ); $request = $request->withAttribute('base', '/base'); @@ -831,7 +831,7 @@ public function testGetUnauthenticatedRedirectUrlWithBasePath() ]); $this->assertSame( '/users/login?redirect=%2Fsecrets', - $service->getUnauthenticatedRedirectUrl($request) + $service->getUnauthenticatedRedirectUrl($request), ); } @@ -843,38 +843,38 @@ public function testGetLoginRedirect() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/secrets'] + ['REQUEST_URI' => '/secrets'], ); $this->assertNull($service->getLoginRedirect($request)); $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/secrets'], - ['redirect' => ''] + ['redirect' => ''], ); $this->assertNull($service->getLoginRedirect($request)); $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/secrets'], - ['redirect' => 'http://evil.ca/evil/path'] + ['redirect' => 'http://evil.ca/evil/path'], ); $this->assertNull($service->getLoginRedirect($request)); $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/secrets'], - ['redirect' => 'ok.com/path'] + ['redirect' => 'ok.com/path'], ); $this->assertSame( '/ok.com/path', - $service->getLoginRedirect($request) + $service->getLoginRedirect($request), ); $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/secrets'], - ['redirect' => '/path/with?query=string'] + ['redirect' => '/path/with?query=string'], ); $this->assertSame( '/path/with?query=string', - $service->getLoginRedirect($request) + $service->getLoginRedirect($request), ); } @@ -887,7 +887,7 @@ public function testImpersonate() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - [] + [], ); $response = new Response(); @@ -920,7 +920,7 @@ public function testImpersonateAlreadyImpersonating() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - [] + [], ); $response = new Response(); @@ -950,7 +950,7 @@ public function testImpersonateWrongProvider() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $response = new Response(); $impersonator = new ArrayObject(['username' => 'mariano']); @@ -979,7 +979,7 @@ public function testStopImpersonating() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - [] + [], ); $response = new Response(); @@ -1014,7 +1014,7 @@ public function testStopImpersonatingWrongProvider() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $response = new Response(); @@ -1042,7 +1042,7 @@ public function testIsImpersonatingImpersonating() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - [] + [], ); $impersonator = new ArrayObject(['username' => 'mariano']); @@ -1070,7 +1070,7 @@ public function testIsImpersonatingNotImpersonating() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - [] + [], ); $user = new ArrayObject(['username' => 'mariano']); @@ -1097,7 +1097,7 @@ public function testIsImpersonatingWrongProvider() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $service = new AuthenticationService([ diff --git a/tests/TestCase/Authenticator/CookieAuthenticatorTest.php b/tests/TestCase/Authenticator/CookieAuthenticatorTest.php index e26ad062..b69f721d 100644 --- a/tests/TestCase/Authenticator/CookieAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/CookieAuthenticatorTest.php @@ -69,7 +69,7 @@ public function testAuthenticateInvalidTokenMissingUsername() null, [ 'CookieAuth' => '["$2y$10$O5VgLDfIqszzr0Q47Ygkc.LkoLIwlIjc/OzoGp6yJasQlxcHU4.ES"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers); @@ -97,7 +97,7 @@ public function testAuthenticateSuccess() [ // hash(username . password . hmac(username . password, salt)) 'CookieAuth' => '["mariano","$2y$10$RlCAFt3e/9l42f8SIaIbqejOg9/b/HklPo.fjXY.tFGuluafugssa"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers); @@ -124,7 +124,7 @@ public function testAuthenticateExpandedCookie() null, [ 'CookieAuth' => ['mariano', '$2y$10$RlCAFt3e/9l42f8SIaIbqejOg9/b/HklPo.fjXY.tFGuluafugssa'], - ] + ], ); $authenticator = new CookieAuthenticator($identifiers); @@ -154,7 +154,7 @@ public function testAuthenticateNoSalt() [ // hash(username . password) 'CookieAuth' => '["mariano","$2y$10$yq91zLgrlF0TUzPjFj49DOL44svGrOYxaBfB6QYWEvxVKzNkvcVom"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers, ['salt' => false]); @@ -181,7 +181,7 @@ public function testAuthenticateInvalidSalt() null, [ 'CookieAuth' => '["mariano","some_hash"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers, ['salt' => '']); @@ -207,7 +207,7 @@ public function testAuthenticateUnknownUser() null, [ 'CookieAuth' => '["robert","$2y$10$1bE1SgasKoz9WmEvUfuZLeYa6pQgxUIJ5LAoS/KGmC1hNuWkUG7ES"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers); @@ -229,7 +229,7 @@ public function testCredentialsNotPresent() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/testpath'] + ['REQUEST_URI' => '/testpath'], ); $authenticator = new CookieAuthenticator($identifiers); @@ -256,7 +256,7 @@ public function testAuthenticateInvalidToken() null, [ 'CookieAuth' => '["mariano","$2y$10$1bE1SgasKoz9WmEvUfuZLeYa6pQgxUIJ5LAoS/asdasdsadasd"]', - ] + ], ); $authenticator = new CookieAuthenticator($identifiers); @@ -278,7 +278,7 @@ public function testPersistIdentity() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/testpath'] + ['REQUEST_URI' => '/testpath'], ); $request = $request->withParsedBody([ 'remember_me' => 1, @@ -307,15 +307,15 @@ public function testPersistIdentity() } $this->assertStringContainsString( 'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24', // `CookieAuth=["mariano","$2y$10$` - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); $this->assertStringContainsString( 'expires=Tue, 01-Jan-2030 00:00:00 GMT;', - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); $this->assertStringContainsString( 'samesite=None', - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); Cookie::setDefaults(['samesite' => null]); @@ -325,7 +325,7 @@ public function testPersistIdentity() $result = $authenticator->persistIdentity($request, $response, $identity); $this->assertStringNotContainsString( 'CookieAuth', - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); // Testing a different field name @@ -338,7 +338,7 @@ public function testPersistIdentity() $result = $authenticator->persistIdentity($request, $response, $identity); $this->assertStringContainsString( 'CookieAuth=%5B%22mariano%22%2C%22%242y%24' . $hashCost . '%24', - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); } @@ -354,7 +354,7 @@ public function testPersistIdentityLoginUrlMismatch() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/testpath'] + ['REQUEST_URI' => '/testpath'], ); $request = $request->withParsedBody([ 'remember_me' => 1, @@ -378,7 +378,7 @@ public function testPersistIdentityLoginUrlMismatch() $this->assertInstanceOf(ResponseInterface::class, $result['response']); $this->assertStringNotContainsString( 'CookieAuth=%5B%22mariano%22%2C%22%242y%2410%24', - $result['response']->getHeaderLine('Set-Cookie') + $result['response']->getHeaderLine('Set-Cookie'), ); } @@ -394,7 +394,7 @@ public function testClearIdentity() ]); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/testpath'] + ['REQUEST_URI' => '/testpath'], ); $response = new Response(); diff --git a/tests/TestCase/Authenticator/EnvironmentAuthenticatorTest.php b/tests/TestCase/Authenticator/EnvironmentAuthenticatorTest.php index f4e56a38..67a6f0d1 100644 --- a/tests/TestCase/Authenticator/EnvironmentAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/EnvironmentAuthenticatorTest.php @@ -541,7 +541,7 @@ public function testAuthenticateInvalidChecker() $this->expectException(RuntimeException::class); $this->expectExceptionMessage( 'The provided URL checker class `Authentication\Test\TestCase\Authenticator\EnvironmentAuthenticatorTest` ' . - 'does not implement the `Authentication\UrlChecker\UrlCheckerInterface` interface.' + 'does not implement the `Authentication\UrlChecker\UrlCheckerInterface` interface.', ); $envAuth->authenticate($request); diff --git a/tests/TestCase/Authenticator/FormAuthenticatorTest.php b/tests/TestCase/Authenticator/FormAuthenticatorTest.php index 2d56a724..15db8cd0 100644 --- a/tests/TestCase/Authenticator/FormAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/FormAuthenticatorTest.php @@ -49,7 +49,7 @@ public function testAuthenticate() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers); @@ -73,7 +73,7 @@ public function testCredentialsNotPresent() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/does-not-match'], [], - [] + [], ); $form = new FormAuthenticator($identifiers); @@ -99,7 +99,7 @@ public function testCredentialsEmpty() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/does-not-match'], [], - ['username' => '', 'password' => ''] + ['username' => '', 'password' => ''], ); $form = new FormAuthenticator($identifiers); @@ -125,7 +125,7 @@ public function testSingleLoginUrlMismatch() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/does-not-match'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -153,7 +153,7 @@ public function testMultipleLoginUrlMismatch() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/does-not-match'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -184,7 +184,7 @@ public function testLoginUrlMismatchWithBase() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $request = $request->withAttribute('base', '/base'); @@ -213,7 +213,7 @@ public function testSingleLoginUrlSuccess() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/Users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -241,7 +241,7 @@ public function testMultipleLoginUrlSuccess() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/de/users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -272,7 +272,7 @@ public function testLoginUrlSuccessWithBase() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $request = $request->withAttribute('base', '/base'); @@ -301,7 +301,7 @@ public function testRegexLoginUrlSuccess() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/de/users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -334,7 +334,7 @@ public function testFullRegexLoginUrlFailure() 'REQUEST_URI' => '/de/users/login', ], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -369,7 +369,7 @@ public function testFullRegexLoginUrlSuccess() 'SERVER_NAME' => 'auth.localhost', ], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -401,7 +401,7 @@ public function testFullLoginUrlFailureWithoutCheckFullUrlOption() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -427,7 +427,7 @@ public function testAuthenticateCustomFields() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['email' => 'mariano@cakephp.org', 'secret' => 'password'] + ['email' => 'mariano@cakephp.org', 'secret' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -464,7 +464,7 @@ public function testAuthenticateValidData() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['id' => 1, 'username' => 'mariano', 'password' => 'password'] + ['id' => 1, 'username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -497,7 +497,7 @@ public function testAuthenticateMissingChecker() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['id' => 1, 'username' => 'mariano', 'password' => 'password'] + ['id' => 1, 'username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -523,7 +523,7 @@ public function testAuthenticateInvalidChecker() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/users/login'], [], - ['id' => 1, 'username' => 'mariano', 'password' => 'password'] + ['id' => 1, 'username' => 'mariano', 'password' => 'password'], ); $form = new FormAuthenticator($identifiers, [ @@ -534,7 +534,7 @@ public function testAuthenticateInvalidChecker() $this->expectException(RuntimeException::class); $this->expectExceptionMessage( 'The provided URL checker class `Authentication\Test\TestCase\Authenticator\FormAuthenticatorTest` ' . - 'does not implement the `Authentication\UrlChecker\UrlCheckerInterface` interface.' + 'does not implement the `Authentication\UrlChecker\UrlCheckerInterface` interface.', ); $form->authenticate($request); diff --git a/tests/TestCase/Authenticator/HttpBasicAuthenticatorTest.php b/tests/TestCase/Authenticator/HttpBasicAuthenticatorTest.php index b600a764..1859e38e 100644 --- a/tests/TestCase/Authenticator/HttpBasicAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/HttpBasicAuthenticatorTest.php @@ -90,7 +90,7 @@ public function testAuthenticateNoData() $request = ServerRequestFactory::fromGlobals( [ 'REQUEST_URI' => '/posts/index', - ] + ], ); $result = $this->auth->authenticate($request); @@ -109,7 +109,7 @@ public function testAuthenticateNoUsername() [ 'REQUEST_URI' => '/posts/index', 'PHP_AUTH_PW' => 'foobar', - ] + ], ); $result = $this->auth->authenticate($request); @@ -128,7 +128,7 @@ public function testAuthenticateNoPassword() [ 'REQUEST_URI' => '/posts/index', 'PHP_AUTH_USER' => 'mariano', - ] + ], ); $result = $this->auth->authenticate($request); @@ -148,7 +148,7 @@ public function testAuthenticateInjection() 'REQUEST_URI' => '/posts/index', 'PHP_AUTH_USER' => '> 1', 'PHP_AUTH_PW' => "' OR 1 = 1", - ] + ], ); $result = $this->auth->authenticate($request); @@ -179,7 +179,7 @@ public function testAuthenticateUsernameZero() [ 'user' => '0', 'password' => 'password', - ] + ], ); $expected = [ @@ -209,7 +209,7 @@ public function testAuthenticateChallenge() [ 'REQUEST_URI' => '/posts/index', 'SERVER_NAME' => 'localhost', - ] + ], ); try { @@ -234,7 +234,7 @@ public function testAuthenticateSuccess() 'REQUEST_URI' => '/posts/index', 'PHP_AUTH_USER' => 'mariano', 'PHP_AUTH_PW' => 'password', - ] + ], ); $result = $this->auth->authenticate($request); diff --git a/tests/TestCase/Authenticator/HttpDigestAuthenticatorTest.php b/tests/TestCase/Authenticator/HttpDigestAuthenticatorTest.php index 602d4c1b..b350ff96 100644 --- a/tests/TestCase/Authenticator/HttpDigestAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/HttpDigestAuthenticatorTest.php @@ -107,7 +107,7 @@ public function testConstructor() public function testAuthenticateNoData() { $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/posts/index'] + ['REQUEST_URI' => '/posts/index'], ); $result = $this->auth->authenticate($request); @@ -125,7 +125,7 @@ public function testAuthenticateWrongUsername() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/posts/index'], [], - [] + [], ); $digest = << '/dir/index.html', 'REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $this->digestHeader($data), - ] + ], ); $result = $this->auth->authenticate($request); @@ -211,7 +211,7 @@ public function testAuthenticateFailsOnBadNonce() 'REQUEST_URI' => '/dir/index.html', 'REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $this->digestHeader($data), - ] + ], ); $result = $this->auth->authenticate($request); @@ -242,7 +242,7 @@ public function testAuthenticateFailsNonceWithTooManyParts() 'REQUEST_URI' => '/dir/index.html', 'REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $this->digestHeader($data), - ] + ], ); $result = $this->auth->authenticate($request); @@ -285,7 +285,7 @@ public function testAuthenticateFailsOnStaleNonce() public function testUnauthorizedChallenge() { $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/posts/index', 'REQUEST_METHOD' => 'GET'] + ['REQUEST_URI' => '/posts/index', 'REQUEST_METHOD' => 'GET'], ); try { @@ -296,7 +296,7 @@ public function testUnauthorizedChallenge() $header = $e->getHeaders()['WWW-Authenticate']; $this->assertMatchesRegularExpression( '/^Digest realm="localhost",qop="auth",nonce="[A-Za-z0-9=]+",opaque="123abc"$/', - $header + $header, ); } } @@ -328,7 +328,7 @@ public function testUnauthorizedFailReChallenge() 'REQUEST_URI' => '/posts/index', 'REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $digest, - ] + ], ); try { @@ -339,7 +339,7 @@ public function testUnauthorizedFailReChallenge() $header = $e->getHeaders()['WWW-Authenticate']; $this->assertMatchesRegularExpression( '/^Digest realm="localhost",qop="auth",nonce="[A-Za-z0-9=]+",opaque="123abc"$/', - $header + $header, ); } } diff --git a/tests/TestCase/Authenticator/JwtAuthenticatorTest.php b/tests/TestCase/Authenticator/JwtAuthenticatorTest.php index c5ae8b0c..df8531a4 100644 --- a/tests/TestCase/Authenticator/JwtAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/JwtAuthenticatorTest.php @@ -95,7 +95,7 @@ public function setUp(): void public function testAuthenticateViaHeaderToken() { $this->request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/'] + ['REQUEST_URI' => '/'], ); $this->request = $this->request->withAddedHeader('Authorization', 'Bearer ' . $this->tokenHS256); @@ -119,7 +119,7 @@ public function testAuthenticateViaQueryParamToken() { $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenHS256] + ['token' => $this->tokenHS256], ); $authenticator = new JwtAuthenticator($this->identifiers, [ @@ -142,7 +142,7 @@ public function testAuthenticationViaIdentifierAndSubject() { $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenHS256] + ['token' => $this->tokenHS256], ); $this->identifiers = $this->createMock(IdentifierCollection::class); @@ -181,7 +181,7 @@ public function testAuthenticateInvalidPayloadNotAnObject() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenHS256] + ['token' => $this->tokenHS256], ); $authenticator = $this->getMockBuilder(JwtAuthenticator::class) @@ -212,7 +212,7 @@ public function testAuthenticateInvalidPayloadEmpty() { $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenHS256] + ['token' => $this->tokenHS256], ); $authenticator = $this->getMockBuilder(JwtAuthenticator::class) @@ -238,7 +238,7 @@ public function testInvalidToken() { $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => 'should cause an exception'] + ['token' => 'should cause an exception'], ); $authenticator = new JwtAuthenticator($this->identifiers, [ @@ -264,7 +264,7 @@ public function testGetPayloadHS256() { $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenHS256] + ['token' => $this->tokenHS256], ); $authenticator = new JwtAuthenticator($this->identifiers, [ @@ -296,7 +296,7 @@ public function testGetPayloadRS256() { $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $this->tokenRS256] + ['token' => $this->tokenRS256], ); $authenticator = new JwtAuthenticator($this->identifiers, [ diff --git a/tests/TestCase/Authenticator/SessionAuthenticatorTest.php b/tests/TestCase/Authenticator/SessionAuthenticatorTest.php index d534f498..2862a182 100644 --- a/tests/TestCase/Authenticator/SessionAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/SessionAuthenticatorTest.php @@ -191,7 +191,7 @@ public function testPersistIdentity() ->expects($this->exactly(2)) ->method('check') ->with( - ...self::withConsecutive(['Auth'], ['Auth']) + ...self::withConsecutive(['Auth'], ['Auth']), ) ->willReturnOnConsecutiveCalls(false, true); @@ -271,7 +271,7 @@ public function testImpersonate() ->expects($this->exactly(2)) ->method('write') ->with( - ...self::withConsecutive(['AuthImpersonate', $impersonator], ['Auth', $impersonated]) + ...self::withConsecutive(['AuthImpersonate', $impersonator], ['Auth', $impersonated]), ); $result = $authenticator->impersonate($request, $response, $impersonator, $impersonated); @@ -312,7 +312,7 @@ public function testImpersonateAlreadyImpersonating() $this->expectException(UnauthorizedException::class); $this->expectExceptionMessage( - 'You are impersonating a user already. Stop the current impersonation before impersonating another user.' + 'You are impersonating a user already. Stop the current impersonation before impersonating another user.', ); $authenticator->impersonate($request, $response, $impersonator, $impersonated); } diff --git a/tests/TestCase/Authenticator/TokenAuthenticatorTest.php b/tests/TestCase/Authenticator/TokenAuthenticatorTest.php index 9b67fa5f..e3f58a50 100644 --- a/tests/TestCase/Authenticator/TokenAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/TokenAuthenticatorTest.php @@ -60,7 +60,7 @@ public function setUp(): void $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); } diff --git a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php index b7cd2397..51cf7573 100644 --- a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php @@ -92,7 +92,7 @@ public function setUp(): void $this->request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); } @@ -257,7 +257,7 @@ public function testSetIdentityOverwrite() $this->assertSame( $this->identityData->username, $request->getSession()->read('Auth.username'), - 'Session should be updated.' + 'Session should be updated.', ); // Replace the identity @@ -269,7 +269,7 @@ public function testSetIdentityOverwrite() $this->assertSame( $newIdentity->username, $request->getSession()->read('Auth.username'), - 'Session should be updated.' + 'Session should be updated.', ); } @@ -432,7 +432,7 @@ public function testUnauthenticatedActions() $this->assertSame( ['add', 'delete', 'index', 'view'], $controller->Authentication->getUnauthenticatedActions(), - 'Should contain unique set.' + 'Should contain unique set.', ); } diff --git a/tests/TestCase/Middleware/AuthenticationMiddlewareTest.php b/tests/TestCase/Middleware/AuthenticationMiddlewareTest.php index 4d760f67..c6eb4369 100644 --- a/tests/TestCase/Middleware/AuthenticationMiddlewareTest.php +++ b/tests/TestCase/Middleware/AuthenticationMiddlewareTest.php @@ -76,7 +76,7 @@ public function testApplicationAuthentication() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -96,7 +96,7 @@ public function testProviderAuthentication() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -153,7 +153,7 @@ public function testSuccessfulAuthentication() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -213,7 +213,7 @@ public function testSuccessfulAuthenticationWithCustomIdentityAttribute() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -241,7 +241,7 @@ public function testSuccessfulAuthenticationApplicationHook() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -266,7 +266,7 @@ public function testSuccessfulAuthenticationPersistIdentity() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $this->service = new AuthenticationService([ 'identifiers' => [ @@ -303,7 +303,7 @@ public function testNonSuccessfulAuthentication() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'invalid', 'password' => 'invalid'] + ['username' => 'invalid', 'password' => 'invalid'], ); $handler = new TestRequestHandler(); @@ -328,7 +328,7 @@ public function testNonSuccessfulAuthenticationWithChallenge() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath', 'SERVER_NAME' => 'localhost'], [], - ['username' => 'invalid', 'password' => 'invalid'] + ['username' => 'invalid', 'password' => 'invalid'], ); $handler = new TestRequestHandler(); @@ -360,7 +360,7 @@ public function testUnauthenticatedNoRedirectMiddlewareConfiguration() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(function ($request) { throw new UnauthenticatedException(); @@ -385,7 +385,7 @@ public function testUnauthenticatedNoRedirect() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $this->expectException(UnauthenticatedException::class); @@ -408,7 +408,7 @@ public function testUnauthenticatedRedirect() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(function ($request) { throw new UnauthenticatedException(); @@ -434,7 +434,7 @@ public function testUnauthenticatedRedirectWithQueryBackwardsCompatible() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(function ($request) { throw new UnauthenticatedException(); @@ -462,7 +462,7 @@ public function testUnauthenticatedRedirectWithExistingQuery() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(function ($request) { throw new UnauthenticatedException(); @@ -490,7 +490,7 @@ public function testUnauthenticatedRedirectWithFragment() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $middleware = new AuthenticationMiddleware($this->service); @@ -507,7 +507,7 @@ public function testUnauthenticatedRedirectWithFragment() $this->assertSame(302, $response->getStatusCode()); $this->assertSame( '/users/login?hello=world&redirect=%2Ftestpath#frag', - $response->getHeaderLine('Location') + $response->getHeaderLine('Location'), ); $this->assertSame('', (string)$response->getBody()); } @@ -524,7 +524,7 @@ public function testUnauthenticatedRedirectWithBase() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $request = $request->withAttribute('base', '/base'); $handler = new TestRequestHandler(function ($request) { @@ -553,7 +553,7 @@ public function testUnauthenticatedRedirectWithQueryStringData() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath', 'QUERY_STRING' => 'a=b&c=d'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $this->service->setConfig([ @@ -603,7 +603,7 @@ public function testJwtTokenAuthorizationThroughTheMiddlewareStack() $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/'], - ['token' => $token] + ['token' => $token], ); $handler = new TestRequestHandler(); $middleware = new AuthenticationMiddleware($this->service); @@ -642,7 +642,7 @@ public function testCookieAuthorizationThroughTheMiddlewareStack() 'username' => 'mariano', 'password' => 'password', 'remember_me' => true, - ] + ], ); $handler = new TestRequestHandler(); @@ -658,7 +658,7 @@ public function testMiddlewareInjectsServiceIntoDIC(): void $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); @@ -674,7 +674,7 @@ public function testMiddlewareInjectsServiceIntoDICCustomContainerInstance(): vo $request = ServerRequestFactory::fromGlobals( ['REQUEST_URI' => '/testpath'], [], - ['username' => 'mariano', 'password' => 'password'] + ['username' => 'mariano', 'password' => 'password'], ); $handler = new TestRequestHandler(); diff --git a/tests/TestCase/UrlChecker/CakeRouterUrlCheckerTest.php b/tests/TestCase/UrlChecker/CakeRouterUrlCheckerTest.php index 402cc4d7..f8ec480e 100644 --- a/tests/TestCase/UrlChecker/CakeRouterUrlCheckerTest.php +++ b/tests/TestCase/UrlChecker/CakeRouterUrlCheckerTest.php @@ -39,7 +39,7 @@ public function setUp(): void $builder->connect( '/login', ['controller' => 'Users', 'action' => 'login'], - ['_name' => 'login'] + ['_name' => 'login'], ); $builder->connect('/{controller}/{action}'); $builder->connect( @@ -48,7 +48,7 @@ public function setUp(): void [ '_host' => 'auth.localhost', '_name' => 'secureLogin', - ] + ], ); } @@ -61,7 +61,7 @@ public function testCheckSimple() { $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/invalid'] + ['REQUEST_URI' => '/users/invalid'], ); $result = $checker->check($request, [ 'controller' => 'Users', @@ -84,7 +84,7 @@ public function testCheckFullUrls() $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, $url, [ 'checkFullUrl' => true, @@ -93,7 +93,7 @@ public function testCheckFullUrls() $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/invalid'] + ['REQUEST_URI' => '/users/invalid'], ); $result = $checker->check($request, $url, [ 'checkFullUrl' => true, @@ -102,7 +102,7 @@ public function testCheckFullUrls() $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/login'] + ['REQUEST_URI' => '/login'], ); $result = $checker->check($request, ['_name' => 'secureLogin'], [ 'checkFullUrl' => true, @@ -114,7 +114,7 @@ public function testCheckFullUrls() [ 'REQUEST_URI' => '/login', 'SERVER_NAME' => 'auth.localhost', - ] + ], ); $result = $checker->check($request, ['_name' => 'secureLogin'], [ 'checkFullUrl' => true, @@ -133,7 +133,7 @@ public function testEmptyUrl() $this->expectExceptionMessage('The $loginUrls parameter is empty or not of type array.'); $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, []); $this->assertFalse($result); @@ -150,7 +150,7 @@ public function testStringUrl() $this->expectExceptionMessage('The $loginUrls parameter is empty or not of type array.'); $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, '/users/login'); $this->assertFalse($result); @@ -165,7 +165,7 @@ public function testNamedRoute() { $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/login'] + ['REQUEST_URI' => '/login'], ); $result = $checker->check($request, ['_name' => 'login']); $this->assertTrue($result); @@ -179,7 +179,7 @@ public function testInvalidNamedRoute() $this->expectException('Cake\Routing\Exception\MissingRouteException'); $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/login'] + ['REQUEST_URI' => '/login'], ); $checker->check($request, ['_name' => 'login-does-not-exist']); } @@ -204,7 +204,7 @@ public function testMultipleUrls() $checker = new CakeRouterUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, $url, [ 'checkFullUrl' => true, @@ -212,7 +212,7 @@ public function testMultipleUrls() $this->assertTrue($result); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/admins/login'] + ['REQUEST_URI' => '/admins/login'], ); $result = $checker->check($request, $url, [ 'checkFullUrl' => true, @@ -220,7 +220,7 @@ public function testMultipleUrls() $this->assertTrue($result); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/invalid'] + ['REQUEST_URI' => '/users/invalid'], ); $result = $checker->check($request, $url, [ 'checkFullUrl' => true, diff --git a/tests/TestCase/UrlChecker/DefaultUrlCheckerTest.php b/tests/TestCase/UrlChecker/DefaultUrlCheckerTest.php index 1be9a8bd..e0a4e4cb 100644 --- a/tests/TestCase/UrlChecker/DefaultUrlCheckerTest.php +++ b/tests/TestCase/UrlChecker/DefaultUrlCheckerTest.php @@ -35,7 +35,7 @@ public function testCheckFailure() $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/does-not-match'] + ['REQUEST_URI' => '/users/does-not-match'], ); $result = $checker->check($request, '/users/login'); @@ -51,7 +51,7 @@ public function testCheckSimple() { $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, '/users/login'); $this->assertTrue($result); @@ -72,7 +72,7 @@ public function testCheckArray() { $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, [ @@ -91,7 +91,7 @@ public function testCheckRegexp() { $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/en/users/login'] + ['REQUEST_URI' => '/en/users/login'], ); $result = $checker->check($request, '%^/[a-z]{2}/users/login/?$%', [ @@ -109,7 +109,7 @@ public function testCheckFull() { $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $result = $checker->check($request, 'http://localhost/users/login', [ @@ -127,7 +127,7 @@ public function testCheckBase() { $checker = new DefaultUrlChecker(); $request = ServerRequestFactory::fromGlobals( - ['REQUEST_URI' => '/users/login'] + ['REQUEST_URI' => '/users/login'], ); $request = $request->withAttribute('base', '/base');