/** * @covers OpCacheGUI\Auth\Ip::__construct * @covers OpCacheGUI\Auth\Ip::buildWhitelist * @covers OpCacheGUI\Auth\Ip::addWhitelist * @covers OpCacheGUI\Auth\Ip::isAllowed */ public function testIsAllowedFalse() { $converter = $this->getMock('\\OpCacheGUI\\Network\\Ip\\Converter'); $converter->method('isValid')->will($this->returnValue(true)); $converter->method('convert')->will($this->returnValue([167772161, 167772161])); $whitelist = new Ip([$converter]); $whitelist->buildWhitelist(['10.0.0.1-10.0.0.5']); $this->assertFalse($whitelist->isAllowed('10.0.0.2')); }
* Start the session */ session_start(); /** * Setup formatters */ $byteFormatter = new ByteFormatter(); /** * Setup CSRF token */ $sessionStorage = new Session(); $csrfToken = new CsrfToken($sessionStorage, new Factory()); /** * Setup the IP whitelist */ $whitelist = new Ip([new \OpCacheGUI\Network\Ip\Any(), new \OpCacheGUI\Network\Ip\Localhost(), new \OpCacheGUI\Network\Ip\Single(), new \OpCacheGUI\Network\Ip\Wildcard(), new \OpCacheGUI\Network\Ip\Range(), new \OpCacheGUI\Network\Ip\Cidr()]); $whitelist->buildWhitelist($login['whitelist']); /** * Setup the authentication object */ $user = new User($sessionStorage, $login['username'], $login['password'], $whitelist); /** * Setup URL renderer */ $urlRenderer = new Url($uriScheme); /** * Setup the HTML template renderer */ $htmlTemplate = new Html(__DIR__ . '/template', 'page.phtml', $translator, $urlRenderer); /** * Setup the JSON template renderer