blob: 5051c34394eacb4cd981b86c0437d42f704a00ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
namespace Psecio\Gatekeeper\Restrict;
class IpTest extends \Psecio\Gatekeeper\Base
{
/**
* Test that an exception is thrown when the remote address
* cannot be found
*
* @expectedException \Psecio\Gatekeeper\Exception\DataNotFoundException
*/
public function testEvaluateNoAddress()
{
$ip = new Ip(array());
$ip->evaluate();
}
/**
* Test that an "Allowed" valid match returns true
*/
public function testEvaluateAllowMatch()
{
$_SERVER['REMOTE_ADDR'] = '192.168.1.1';
$config = array(
'ALLOW' => array('192.168.*')
);
$ip = new Ip($config);
$this->assertTrue($ip->evaluate());
}
/**
* Test that a false is returned when a "deny" match is found
*/
public function testEvaluateDenyMatch()
{
$_SERVER['REMOTE_ADDR'] = '192.168.1.1';
$config = array(
'DENY' => array('192.168.*')
);
$ip = new Ip($config);
$this->assertFalse($ip->evaluate());
}
/**
* Test that a false is returned on an "allow" with
* no match
*/
public function testEvaluateAllowNoMatch()
{
$_SERVER['REMOTE_ADDR'] = '192.168.1.1';
$config = array(
'ALLOW' => array('10.0.*')
);
$ip = new Ip($config);
$this->assertFalse($ip->evaluate());
}
}
|