From e93a09ec88c0213288fc60aa17fc1ada80faa89c Mon Sep 17 00:00:00 2001 From: Yevgeny Tomenko Date: Tue, 12 Mar 2024 02:56:30 +0300 Subject: [PATCH] authentication and behavior tests --- .../Model/Behavior/RegisterBehaviorTest.php | 1 - .../Provider/AuthenticationServiceProviderTest.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php index 7609e376..d3e43e0d 100644 --- a/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/RegisterBehaviorTest.php @@ -53,7 +53,6 @@ public function setUp(): void { parent::setUp(); $table = TableRegistry::getTableLocator()->get('CakeDC/Users.Users'); - $table->addBehavior('CakeDC/Users/Register.Register'); $this->Table = $table; $this->Behavior = $table->behaviors()->Register; TransportFactory::setConfig('test', ['className' => 'Debug']); diff --git a/tests/TestCase/Provider/AuthenticationServiceProviderTest.php b/tests/TestCase/Provider/AuthenticationServiceProviderTest.php index c13338b6..5c8898ec 100644 --- a/tests/TestCase/Provider/AuthenticationServiceProviderTest.php +++ b/tests/TestCase/Provider/AuthenticationServiceProviderTest.php @@ -98,22 +98,26 @@ public function testGetAuthenticationService() 'identityAttribute' => 'identity', 'skipTwoFactorVerify' => true, 'impersonateSessionKey' => 'AuthImpersonate', + 'className' => 'Authentication.Session', ], FormAuthenticator::class => [ 'loginUrl' => '/login', 'keyCheckEnabledRecaptcha' => 'Users.reCaptcha.login', 'fields' => ['username' => 'email', 'password' => 'alt_password'], + 'className' => 'CakeDC/Auth.Form', ], TokenAuthenticator::class => [ 'header' => null, 'queryParam' => 'api_key', 'tokenPrefix' => null, 'skipTwoFactorVerify' => true, + 'className' => 'Authentication.Token', ], TwoFactorAuthenticator::class => [ 'loginUrl' => null, 'urlChecker' => 'Authentication.Default', 'skipTwoFactorVerify' => true, + 'className' => 'CakeDC/Auth.TwoFactor', ], ]; $actual = []; @@ -135,17 +139,20 @@ public function testGetAuthenticationService() ], 'resolver' => 'Authentication.Orm', 'passwordHasher' => null, + 'className' => 'Authentication.Password', ], TokenIdentifier::class => [ 'tokenField' => 'api_token', 'dataField' => 'token', 'resolver' => 'Authentication.Orm', 'hashAlgorithm' => null, + 'className' => 'Authentication.Token', ], JwtSubjectIdentifier::class => [ 'tokenField' => 'id', 'dataField' => 'sub', 'resolver' => 'Authentication.Orm', + 'className' => 'Authentication.JwtSubject', ], ]; $actual = []; @@ -196,11 +203,13 @@ public function testGetAuthenticationServiceWithoutOneTimePasswordAuthenticator( 'fields' => ['username' => 'email'], 'identify' => true, 'impersonateSessionKey' => 'AuthImpersonate', + 'className' => 'Authentication.Session', ], 'Form' => [ 'className' => 'CakeDC/Auth.Form', 'loginUrl' => '/login', 'fields' => ['username' => 'email', 'password' => 'alt_password'], + 'className' => 'CakeDC/Auth.Form', ], 'Token' => [ 'className' => 'Authentication.Token', @@ -208,6 +217,7 @@ public function testGetAuthenticationServiceWithoutOneTimePasswordAuthenticator( 'header' => null, 'queryParam' => 'api_key', 'tokenPrefix' => null, + 'className' => 'Authentication.Token', ], ]); Configure::write('Auth.Identifiers', [ @@ -237,17 +247,20 @@ public function testGetAuthenticationServiceWithoutOneTimePasswordAuthenticator( 'identityAttribute' => 'identity', 'skipTwoFactorVerify' => true, 'impersonateSessionKey' => 'AuthImpersonate', + 'className' => 'Authentication.Session' ], FormAuthenticator::class => [ 'loginUrl' => '/login', 'fields' => ['username' => 'email', 'password' => 'alt_password'], 'keyCheckEnabledRecaptcha' => 'Users.reCaptcha.login', + 'className' => 'CakeDC/Auth.Form', ], TokenAuthenticator::class => [ 'header' => null, 'queryParam' => 'api_key', 'tokenPrefix' => null, 'skipTwoFactorVerify' => true, + 'className' => 'Authentication.Token', ], ]; $actual = [];