Silently fail unblock

If the user unblocks and address that was not blocked, silently fail
This commit is contained in:
Chris Boden 2012-04-29 13:53:10 -04:00
parent 550b32e1e7
commit 852e5777e3
2 changed files with 7 additions and 1 deletions

View File

@ -34,7 +34,9 @@ class IpBlackListComponent implements MessageComponentInterface {
* @return IpBlackList
*/
public function unblockAddress($ip) {
if (isset($this->_blacklist[$this->filterAddress($ip)])) {
unset($this->_blacklist[$this->filterAddress($ip)]);
}
return $this;
}

View File

@ -84,4 +84,8 @@ class IpBlackListComponentTest extends \PHPUnit_Framework_TestCase {
public function testFilterAddress($expected, $input) {
$this->assertEquals($expected, $this->_comp->filterAddress($input));
}
public function testUnblockingSilentlyFails() {
$this->assertInstanceOf('\\Ratchet\\Component\\Server\\IpBlackListComponent', $this->_comp->unblockAddress('localhost'));
}
}