public function testInstantiateWithWhitelistRules()
 {
     $s = new ConfigSubscriber(array("^/" => array('ip_whitelist' => array('192.168.*.*'))));
     $s->addConfigHandler(new IpWhitelistHandler());
     $f = new Firewall();
     $f->addSubscriber($s);
     $this->assertTrue($f->verifyRequest($this->createRequestFromIp("192.168.30.40")));
     $s = new ConfigSubscriber(array("^/" => array('ip_whitelist' => array('192.168.*.*'))));
     $s->addConfigHandler(new IpWhitelistHandler());
     $f = new Firewall();
     $f->addSubscriber($s);
     $this->setExpectedException("AC\\Component\\Firewall\\Exception\\InvalidIpException");
     $this->assertTrue($f->verifyRequest($this->createRequestFromIp("80.0.0.0")));
 }
Example #2
0
 public function testDispatchFirewallEvents2()
 {
     $f = new Firewall();
     $s = new Mock\ExceptionSubscriber();
     $this->assertFalse($s->handledRequest());
     $this->assertFalse($s->handledException());
     $this->assertFalse($s->handledResponse());
     $f->addSubscriber($s);
     $response = $f->verifyRequest(Request::create("/", "GET"));
     $this->assertTrue($s->handledRequest());
     $this->assertTrue($s->handledException());
     $this->assertTrue($s->handledResponse());
     $this->assertTrue($response instanceof Response);
     $this->assertSame("foo", $response->getContent());
 }