From a491348d442ab8e6cd2fa403d4365cdad78e52ce Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 21 Jun 2018 14:13:41 -0700 Subject: Vendoring deprecated composer libs --- libs/jsonrpc/tests/Validator/HostValidatorTest.php | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 libs/jsonrpc/tests/Validator/HostValidatorTest.php (limited to 'libs/jsonrpc/tests/Validator/HostValidatorTest.php') diff --git a/libs/jsonrpc/tests/Validator/HostValidatorTest.php b/libs/jsonrpc/tests/Validator/HostValidatorTest.php new file mode 100644 index 00000000..a5fed7e0 --- /dev/null +++ b/libs/jsonrpc/tests/Validator/HostValidatorTest.php @@ -0,0 +1,32 @@ +assertNull(HostValidator::validate(array(), '127.0.0.1', '127.0.0.1')); + } + + public function testWithValidHosts() + { + $this->assertNull(HostValidator::validate(array('127.0.0.1'), '127.0.0.1', '127.0.0.1')); + } + + public function testWithValidNetwork() + { + $this->assertNull(HostValidator::validate(array('192.168.10.1/24'), '192.168.10.1'),'test ip match'); + $this->assertNull(HostValidator::validate(array('192.168.10.1/24'), '192.168.10.250'),'test ip match'); + $this->setExpectedException('\JsonRPC\Exception\AccessDeniedException'); + HostValidator::validate(array('192.168.10.1/24'), '192.168.11.1'); + } + + public function testWithNotAuthorizedHosts() + { + $this->setExpectedException('\JsonRPC\Exception\AccessDeniedException'); + HostValidator::validate(array('192.168.1.1'), '127.0.0.1', '127.0.0.1'); + } +} -- cgit v1.2.3