/** * Tests UserLoginData->passwordUsedBefore() && UserLoginData->addToPreviousPasswords() */ public function testPasswordUsedBeforeAddToPreviousPasswords() { $this->assertNull($this->UserLoginData->getPreviousPasswords()); $this->dummyPartner->setNumPrevPassToKeep(3); $this->dummyPartner->save(); $pass2 = UserLoginDataPeer::generateNewPassword(); $pass3 = UserLoginDataPeer::generateNewPassword(); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass3)); $pass1 = $this->UserLoginData->resetPassword(); $this->UserLoginData->resetPassword($pass1, $pass1); $this->UserLoginData->resetPassword($pass2, $pass1); $this->UserLoginData->resetPassword($pass3, $pass2); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass3)); $pass4 = uniqid(); $this->UserLoginData->resetPassword($pass4, $pass3); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass3)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass4)); $pass5 = uniqid(); $this->UserLoginData->resetPassword($pass5, $pass4); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass3)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass4)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass5)); $this->dummyPartner->setNumPrevPassToKeep(2); $this->dummyPartner->save(); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass3)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass4)); $this->assertTrue($this->UserLoginData->passwordUsedBefore($pass5)); $this->dummyPartner->setNumPrevPassToKeep(0); $this->dummyPartner->save(); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass3)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass4)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass5)); $pass6 = uniqid(); $this->UserLoginData->resetPassword($pass6, $pass5); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass1)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass2)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass3)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass4)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass5)); $this->assertFalse($this->UserLoginData->passwordUsedBefore($pass6)); }
private function assertLoginData() { // check copied values $this->assertEquals($this->adminKuser->getEmail(), $this->loginData->getLoginEmail(), 'login_email for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPartnerId(), $this->loginData->getConfigPartnerId(), 'config_partner_id for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getSalt(), $this->loginData->getSalt(), 'salt for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getSha1Password(), $this->loginData->getSha1Password(), 'sha1_password for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getLoginAttempts(), $this->loginData->getLoginAttempts(), 'login_attempts for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getLoginBlockPeriod(), $this->loginData->getLoginBlockPeriod(), 'login_block_period for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getMaxLoginAttempts(), $this->loginData->getMaxLoginAttempts(), 'max_login_attempts for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getNumPrevPassToKeep(), $this->loginData->getNumPrevPassToKeep(), 'num_prev_pass_to_keep for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPassReplaceFreq(), $this->loginData->getPassReplaceFreq(), 'pass_replace_freq for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPasswordHashKey(), $this->loginData->getPasswordHashKey(), 'password_hash_key for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPasswordUpdatedAt(), $this->loginData->getPasswordUpdatedAt(), 'password_updated_at for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPreviousPasswords(), $this->loginData->getPreviousPasswords(), 'previous_passwords for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getLoginBlockedUntil(), $this->loginData->getLoginBlockedUntil(), 'login_blocked_until for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getFullName(), $this->loginData->getFullName(), 'full_name for ' . $this->getParams()); // check new values $this->assertEquals($this->adminKuser->getPartnerId(), $this->loginData->getLastLoginPartnerId(), 'last_login_partner_id for ' . $this->getParams()); }