public function testLegacyPasswordIsValidUpgradedRehashedWhenClientCodeUsesSameParametersAsUpgradeDecorator() { $validator = new UpgradeDecorator(new PasswordValidator(), $this->callback); $password = '******'; $hash = hash('sha512', $password); $validator->setOptions(array('cost' => UpgradeDecorator::DEFAULT_REHASH_COST)); $result = $validator->isValid($password, $hash); $this->assertTrue($result->isValid(), "Failed asserting that result is valid"); $this->assertEquals(ValidationResult::SUCCESS_PASSWORD_REHASHED, $result->getCode(), "Failed asserting that password was rehashed"); }
public function testLegacyPasswordIsValidUpgradedRehashedStored() { $validator = new UpgradeDecorator(new StorageDecorator(new PasswordValidator(), $this->storage), $this->callback); $password = '******'; $hash = hash('sha512', $password); $identity = 'username'; $this->storage->expects($this->once())->method('updatePassword')->with($identity, $this->stringContains('$2y$10$')); $result = $validator->isValid($password, $hash, null, $identity); $this->assertTrue($result->isValid()); $this->assertEquals(ValidationResult::SUCCESS_PASSWORD_REHASHED, $result->getCode()); $this->assertNotNull($result->getPassword()); $this->assertStringStartsWith('$2y$10$', $result->getPassword()); }