示例#1
0
 public function testCanAdjustEncriptionWorkfactor()
 {
     $this->auth->setUserOption(AuthManager::ATTR_WORKFACTOR, 4);
     $start = microtime(true);
     $this->auth->newUser('user1', 'P@ssW0rd', '*****@*****.**');
     $token = $this->auth->getTokenElement(true);
     $_POST[$this->auth->tokenkey] = $this->auth->tokenval;
     $this->auth->login('user1', 'P@ssW0rd');
     $time1 = microtime(true) - $start;
     $this->auth->setUserOption(AuthManager::ATTR_WORKFACTOR, 6);
     $start = microtime(true);
     $this->auth->newUser('user2', 'P@ssW0rd', '*****@*****.**');
     $token = $this->auth->getTokenElement(true);
     $_POST[$this->auth->tokenkey] = $this->auth->tokenval;
     $this->auth->login('user2', 'P@ssW0rd');
     $time2 = microtime(true) - $start;
     $this->assertGreaterThan($time1 * 2, $time2, 'A work factor of 6 should be more than 2x as slow as a workfactor of 4');
 }