Vendoring deprecated composer libs
This commit is contained in:
32
libs/jsonrpc/tests/Validator/HostValidatorTest.php
Normal file
32
libs/jsonrpc/tests/Validator/HostValidatorTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use JsonRPC\Validator\HostValidator;
|
||||
|
||||
require_once __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
class HostValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testWithEmptyHosts()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
22
libs/jsonrpc/tests/Validator/JsonEncodingValidatorTest.php
Normal file
22
libs/jsonrpc/tests/Validator/JsonEncodingValidatorTest.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use JsonRPC\Validator\JsonEncodingValidator;
|
||||
|
||||
require_once __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
class JsonEncodingValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testWithValidJson()
|
||||
{
|
||||
json_encode('{"foo": "bar"}');
|
||||
$this->assertNull(JsonEncodingValidator::validate());
|
||||
}
|
||||
|
||||
public function testWithJsonError()
|
||||
{
|
||||
json_encode("\xB1\x31");
|
||||
|
||||
$this->setExpectedException('\JsonRPC\Exception\ResponseEncodingFailureException');
|
||||
JsonEncodingValidator::validate();
|
||||
}
|
||||
}
|
||||
19
libs/jsonrpc/tests/Validator/JsonFormatValidatorTest.php
Normal file
19
libs/jsonrpc/tests/Validator/JsonFormatValidatorTest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use JsonRPC\Validator\JsonFormatValidator;
|
||||
|
||||
require_once __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
class JsonFormatValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testJsonParsedCorrectly()
|
||||
{
|
||||
$this->assertNull(JsonFormatValidator::validate(array('foobar')));
|
||||
}
|
||||
|
||||
public function testJsonNotParsedCorrectly()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonFormatException');
|
||||
JsonFormatValidator::validate('');
|
||||
}
|
||||
}
|
||||
48
libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php
Normal file
48
libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use JsonRPC\Validator\RpcFormatValidator;
|
||||
|
||||
require_once __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
class RpcFormatValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testWithMinimumRequirement()
|
||||
{
|
||||
$this->assertNull(RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'foobar')));
|
||||
}
|
||||
|
||||
public function testWithNoVersion()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException');
|
||||
RpcFormatValidator::validate(array('method' => 'foobar'));
|
||||
}
|
||||
|
||||
public function testWithNoMethod()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException');
|
||||
RpcFormatValidator::validate(array('jsonrpc' => '2.0'));
|
||||
}
|
||||
|
||||
public function testWithMethodNotString()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException');
|
||||
RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => array()));
|
||||
}
|
||||
|
||||
public function testWithBadVersion()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException');
|
||||
RpcFormatValidator::validate(array('jsonrpc' => '1.0', 'method' => 'abc'));
|
||||
}
|
||||
|
||||
public function testWithBadParams()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException');
|
||||
RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'abc', 'params' => 'foobar'));
|
||||
}
|
||||
|
||||
public function testWithParams()
|
||||
{
|
||||
$this->assertNull(RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'abc', 'params' => array(1, 2))));
|
||||
}
|
||||
}
|
||||
24
libs/jsonrpc/tests/Validator/UserValidatorTest.php
Normal file
24
libs/jsonrpc/tests/Validator/UserValidatorTest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use JsonRPC\Validator\UserValidator;
|
||||
|
||||
require_once __DIR__.'/../../../../vendor/autoload.php';
|
||||
|
||||
class UserValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testWithEmptyHosts()
|
||||
{
|
||||
$this->assertNull(UserValidator::validate(array(), 'user', 'pass'));
|
||||
}
|
||||
|
||||
public function testWithValidHosts()
|
||||
{
|
||||
$this->assertNull(UserValidator::validate(array('user' => 'pass'), 'user', 'pass'));
|
||||
}
|
||||
|
||||
public function testWithNotAuthorizedHosts()
|
||||
{
|
||||
$this->setExpectedException('\JsonRPC\Exception\AuthenticationFailureException');
|
||||
UserValidator::validate(array('user' => 'pass'), 'user', 'wrong password');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user