Exemplo n.º 1
0
 public function testIpLockingMechanism()
 {
     $memcache = Mockery::mock('Memcache');
     $bruteForce = new BruteForce($this->database);
     $this->database->shouldReceive('getTimeframe')->andReturn(100);
     $this->database->shouldReceive('getLockout')->andReturn(300);
     $timeout = Carbon::now()->addSeconds($this->database->getTimeframe());
     $this->database->shouldReceive('retrieveUserFailedLoginAttempts')->withArgs(array('jdoe'))->andReturn(array('timeout' => $timeout, 'attempts' => 1));
     $this->database->shouldReceive('retrieveIpFailedLoginAttempts')->withArgs(array('127.0.0.1'))->andReturn(array('timeout' => $timeout, 'attempts' => 100));
     $this->assertEquals(true, $bruteForce->checkLocked(array('username' => 'jdoe', 'ipAddress' => '127.0.0.1')));
 }