Реализовано автоматическое обновление алгоритма хэширования пароля во время авторизации пользователя

This commit is contained in:
ErickSkrauch
2016-05-23 22:42:50 +03:00
parent 3d6d9d484c
commit fe2c422621
3 changed files with 38 additions and 18 deletions

View File

@ -4,12 +4,25 @@ namespace tests\codeception\api\models\authentication;
use api\models\authentication\LoginForm;
use Codeception\Specify;
use common\models\Account;
use tests\codeception\api\unit\TestCase;
use tests\codeception\api\unit\DbTestCase;
use tests\codeception\common\fixtures\AccountFixture;
use Yii;
class LoginFormTest extends TestCase {
/**
* @property AccountFixture $accounts
*/
class LoginFormTest extends DbTestCase {
use Specify;
public function fixtures() {
return [
'accounts' => [
'class' => AccountFixture::class,
'dataFile' => '@tests/codeception/common/fixtures/data/accounts.php',
],
];
}
public function testValidateLogin() {
$this->specify('error.login_not_exist if login not exists', function () {
$model = $this->createModel([
@ -84,6 +97,18 @@ class LoginFormTest extends TestCase {
});
}
public function testLoginWithRehashing() {
$this->specify('user, that login using account with old pass hash strategy should update it automatically', function () {
$model = new LoginForm([
'login' => $this->accounts['user-with-old-password-type']['username'],
'password' => '12345678',
]);
expect($model->login())->notEquals(false);
expect($model->errors)->isEmpty();
expect($model->getAccount()->password_hash_strategy)->equals(Account::PASS_HASH_STRATEGY_YII2);
});
}
/**
* @param array $params
* @return LoginForm