diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php index 06e5473..7efe444 100644 --- a/tests/Fixture/UsersFixture.php +++ b/tests/Fixture/UsersFixture.php @@ -12,6 +12,8 @@ namespace CakeDC\Api\Test\Fixture; +use Authentication\PasswordHasher\DefaultPasswordHasher; +use Authentication\PasswordHasher\PasswordHasherFactory; use Cake\TestSuite\Fixture\TestFixture; use CakeDC\Users\Webauthn\Base64Utility; @@ -20,12 +22,20 @@ */ class UsersFixture extends TestFixture { + + /** + * records property + * + * @var array + */ + public array $records = []; + /** * Init method * * @return void */ - public function init(): void + public function __construct() { $this->records = [ [ @@ -42,20 +52,18 @@ public function init(): void 'secret' => 'yyy', 'secret_verified' => false, 'tos_date' => '2015-06-24 17:33:54', - 'active' => false, + 'active' => true, 'is_superuser' => true, 'role' => 'admin', 'created' => '2015-06-24 17:33:54', 'modified' => '2015-06-24 17:33:54', - 'additional_data' => null, 'last_login' => '2015-06-24 17:33:54', ], [ 'id' => '00000000-0000-0000-0000-000000000002', 'username' => 'user-2', 'email' => 'user-2@test.com', - //The password real value is 12345 - 'password' => '$2y$10$Nvu7ipP.z8tiIl75OdUvt.86vuG6iKMoHIOc7O7mboFI85hSyTEde', + 'password' => '12345', 'first_name' => 'user', 'last_name' => 'second', 'token' => '6614f65816754310a5f0553436dd89e9', @@ -212,28 +220,12 @@ public function init(): void 'created' => '2015-06-24 17:33:54', 'modified' => '2015-06-24 17:33:54', ], - [ - 'id' => '00000000-0000-0000-0000-000000000010', - 'username' => 'Lorem ipsum dolor sit amet', - 'email' => 'Lorem ipsum dolor sit amet', - 'password' => 'Lorem ipsum dolor sit amet', - 'first_name' => 'Lorem ipsum dolor sit amet', - 'last_name' => 'Lorem ipsum dolor sit amet', - 'token' => 'Lorem ipsum dolor sit amet', - 'token_expires' => '2015-06-24 17:33:54', - 'api_token' => 'Lorem ipsum dolor sit amet', - 'activation_date' => '2015-06-24 17:33:54', - 'secret' => 'Lorem ipsum dolor sit amet', - 'secret_verified' => false, - 'tos_date' => '2015-06-24 17:33:54', - 'active' => true, - 'is_superuser' => false, - 'role' => 'Lorem ipsum dolor sit amet', - 'created' => '2015-06-24 17:33:54', - 'modified' => '2015-06-24 17:33:54', - ], ]; - parent::init(); + parent::__construct(); + $hasher = PasswordHasherFactory::build(DefaultPasswordHasher::class); + foreach ($this->records as $id => $record) { + $this->records[$id]['password'] = $hasher->hash($record['password']); + } } } diff --git a/tests/TestCase/Integration/Service/Action/Auth/LoginActionTest.php b/tests/TestCase/Integration/Service/Action/Auth/LoginActionTest.php index bc10ed1..e0a76a5 100644 --- a/tests/TestCase/Integration/Service/Action/Auth/LoginActionTest.php +++ b/tests/TestCase/Integration/Service/Action/Auth/LoginActionTest.php @@ -64,6 +64,8 @@ public function testSuccessLogin() 'active' => true, 'api_token' => 'yyy', 'role' => 'admin', + 'secret_verified' => false, + 'last_login' => '2015-06-24T17:33:54+00:00', ]; $data = Hash::get($result, 'data'); unset($data['activation_date']);