Merge pull request #15 from anthonysterling/feature/fixtures
Moved JSON API Responses to test fixtures
This commit is contained in:
@@ -23,5 +23,10 @@
|
|||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Cloudflare\\API\\": "src/"
|
"Cloudflare\\API\\": "src/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"classmap": [
|
||||||
|
"tests/"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
|
|
||||||
class GuzzleTest extends PHPUnit_Framework_TestCase
|
class GuzzleTest extends TestCase
|
||||||
{
|
{
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 13/01/2017
|
* Date: 13/01/2017
|
||||||
* Time: 17:15
|
* Time: 17:15
|
||||||
*/
|
*/
|
||||||
class APIKeyTest extends PHPUnit_Framework_TestCase
|
class APIKeyTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
use Cloudflare\API\Auth\None;
|
use Cloudflare\API\Auth\None;
|
||||||
|
|
||||||
class NoneTest extends PHPUnit_Framework_TestCase
|
class NoneTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Date: 13/01/2017
|
* Date: 13/01/2017
|
||||||
* Time: 18:03
|
* Time: 18:03
|
||||||
*/
|
*/
|
||||||
class UserServiceKeyTest extends PHPUnit_Framework_TestCase
|
class UserServiceKeyTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Date: 19/09/2017
|
* Date: 19/09/2017
|
||||||
* Time: 15:24
|
* Time: 15:24
|
||||||
*/
|
*/
|
||||||
class ConfigurationsUARulesTest extends PHPUnit_Framework_TestCase
|
class ConfigurationsUARulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetArray()
|
public function testGetArray()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
use Cloudflare\API\Configurations\PageRulesTargets;
|
use Cloudflare\API\Configurations\PageRulesTargets;
|
||||||
|
|
||||||
class PageRulesTargetTest extends PHPUnit_Framework_TestCase
|
class PageRulesTargetTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetArray()
|
public function testGetArray()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Date: 05/09/2017
|
* Date: 05/09/2017
|
||||||
* Time: 13:50
|
* Time: 13:50
|
||||||
*/
|
*/
|
||||||
class ConfigurationZoneLockdownTest extends PHPUnit_Framework_TestCase
|
class ConfigurationZoneLockdownTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetArray()
|
public function testGetArray()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,32 +6,12 @@
|
|||||||
* Date: 09/06/2017
|
* Date: 09/06/2017
|
||||||
* Time: 15:31
|
* Time: 15:31
|
||||||
*/
|
*/
|
||||||
class DNSTest extends PHPUnit_Framework_TestCase
|
class DNSTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testAddRecord()
|
public function testAddRecord()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addRecord.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"type": "A",
|
|
||||||
"name": "example.com",
|
|
||||||
"content": "1.2.3.4",
|
|
||||||
"proxiable": true,
|
|
||||||
"proxied": false,
|
|
||||||
"ttl": 120,
|
|
||||||
"locked": false,
|
|
||||||
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"zone_name": "example.com",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"data": {}
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -55,36 +35,8 @@ class DNSTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testListRecords()
|
public function testListRecords()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRecords.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"type": "A",
|
|
||||||
"name": "example.com",
|
|
||||||
"content": "1.2.3.4",
|
|
||||||
"proxiable": true,
|
|
||||||
"proxied": false,
|
|
||||||
"ttl": 120,
|
|
||||||
"locked": false,
|
|
||||||
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"zone_name": "example.com",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"data": {}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -114,30 +66,10 @@ class DNSTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetRecordDetails()
|
public function testGetDNSRecordDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getDNSRecordDetails.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"type": "A",
|
|
||||||
"name": "example.com",
|
|
||||||
"content": "1.2.3.4",
|
|
||||||
"proxiable": true,
|
|
||||||
"proxied": false,
|
|
||||||
"ttl": 120,
|
|
||||||
"locked": false,
|
|
||||||
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"zone_name": "example.com",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"data": {}
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,12 @@
|
|||||||
|
|
||||||
use Cloudflare\API\Endpoints\IPs;
|
use Cloudflare\API\Endpoints\IPs;
|
||||||
|
|
||||||
class IPsTest extends PHPUnit_Framework_TestCase
|
class IPsTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListIPs()
|
public function testListIPs()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listIPs.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"ipv4_cidrs": [
|
|
||||||
"199.27.128.0/21"
|
|
||||||
],
|
|
||||||
"ipv6_cidrs": [
|
|
||||||
"2400:cb00::/32"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -8,46 +8,16 @@
|
|||||||
|
|
||||||
use Cloudflare\API\Adapter\PageRules;
|
use Cloudflare\API\Adapter\PageRules;
|
||||||
|
|
||||||
class PageRulesTest extends PHPUnit_Framework_TestCase
|
class PageRulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCreatePageRule()
|
public function testCreatePageRule()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "9a7806061c88ada191ed06f989cc3dac",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target": "url",
|
|
||||||
"constraint": {
|
|
||||||
"operator": "matches",
|
|
||||||
"value": "*example.com/images/*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"id": "always_online",
|
|
||||||
"value": "on"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"priority": 1,
|
|
||||||
"status": "active",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$target = new \Cloudflare\API\Configurations\PageRulesTargets('*example.com/images/*');
|
$target = new \Cloudflare\API\Configurations\PageRulesTargets('*example.com/images/*');
|
||||||
$action = new \Cloudflare\API\Configurations\PageRulesActions();
|
$action = new \Cloudflare\API\Configurations\PageRulesActions();
|
||||||
$action->setAlwaysOnline(true);
|
$action->setAlwaysOnline(true);
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.json');
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -72,47 +42,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testListPageRules()
|
public function testListPageRules()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listPageRules.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "9a7806061c88ada191ed06f989cc3dac",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target": "url",
|
|
||||||
"constraint": {
|
|
||||||
"operator": "matches",
|
|
||||||
"value": "*example.com/images/*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"id": "always_online",
|
|
||||||
"value": "on"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"priority": 1,
|
|
||||||
"status": "active",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -135,39 +66,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetPageRuleDetails()
|
public function testGetPageRuleDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getPageRuleDetails.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "9a7806061c88ada191ed06f989cc3dac",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target": "url",
|
|
||||||
"constraint": {
|
|
||||||
"operator": "matches",
|
|
||||||
"value": "*example.com/images/*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"id": "always_online",
|
|
||||||
"value": "on"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"priority": 1,
|
|
||||||
"status": "active",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -184,42 +84,12 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testUpdatePageRule()
|
public function testUpdatePageRule()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "9a7806061c88ada191ed06f989cc3dac",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target": "url",
|
|
||||||
"constraint": {
|
|
||||||
"operator": "matches",
|
|
||||||
"value": "*example.com/images/*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"id": "always_online",
|
|
||||||
"value": "on"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"priority": 1,
|
|
||||||
"status": "active",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$target = new \Cloudflare\API\Configurations\PageRulesTargets('*example.com/images/*');
|
$target = new \Cloudflare\API\Configurations\PageRulesTargets('*example.com/images/*');
|
||||||
$action = new \Cloudflare\API\Configurations\PageRulesActions();
|
$action = new \Cloudflare\API\Configurations\PageRulesActions();
|
||||||
$action->setAlwaysOnline(true);
|
$action->setAlwaysOnline(true);
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePageRule.json');
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('patch')->willReturn($response);
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
@@ -244,20 +114,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testDeletePageRule()
|
public function testDeletePageRule()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deletePageRule.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "9a7806061c88ada191ed06f989cc3dac"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('delete')->willReturn($response);
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -8,38 +8,12 @@
|
|||||||
|
|
||||||
use Cloudflare\API\Endpoints\UARules;
|
use Cloudflare\API\Endpoints\UARules;
|
||||||
|
|
||||||
class UARulesTest extends PHPUnit_Framework_TestCase
|
class UARulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListRules()
|
public function testListRules()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRules.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
|
||||||
"mode": "js_challenge",
|
|
||||||
"configuration": {
|
|
||||||
"target": "ua",
|
|
||||||
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -69,26 +43,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
|
|||||||
$config = new \Cloudflare\API\Configurations\UARules();
|
$config = new \Cloudflare\API\Configurations\UARules();
|
||||||
$config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
$config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
||||||
|
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRule.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
|
||||||
"mode": "js_challenge",
|
|
||||||
"configuration": {
|
|
||||||
"target": "ua",
|
|
||||||
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -117,26 +73,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function getRuleDetails()
|
public function getRuleDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getRuleDetails.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
|
||||||
"mode": "js_challenge",
|
|
||||||
"configuration": {
|
|
||||||
"target": "ua",
|
|
||||||
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -158,26 +96,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
|
|||||||
$config = new \Cloudflare\API\Configurations\UARules();
|
$config = new \Cloudflare\API\Configurations\UARules();
|
||||||
$config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
$config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
||||||
|
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateRule.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
|
||||||
"mode": "js_challenge",
|
|
||||||
"configuration": {
|
|
||||||
"target": "ua",
|
|
||||||
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('put')->willReturn($response);
|
$mock->method('put')->willReturn($response);
|
||||||
|
|
||||||
@@ -206,19 +126,8 @@ class UARulesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testDeleteRule()
|
public function testDeleteRule()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRule.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('delete')->willReturn($response);
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -5,30 +5,12 @@
|
|||||||
* Date: 01/02/2017
|
* Date: 01/02/2017
|
||||||
* Time: 12:50
|
* Time: 12:50
|
||||||
*/
|
*/
|
||||||
class UserTest extends PHPUnit_Framework_TestCase
|
class UserTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetUserDetails()
|
public function testGetUserDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getUserDetails.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Appleseed",
|
|
||||||
"username": "cfuser12345",
|
|
||||||
"telephone": "+1 123-123-1234",
|
|
||||||
"country": "US",
|
|
||||||
"zipcode": "12345",
|
|
||||||
"created_on": "2014-01-01T05:20:00Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00Z",
|
|
||||||
"two_factor_authentication_enabled": false
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -43,26 +25,8 @@ class UserTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetUserID()
|
public function testGetUserID()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getUserId.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Appleseed",
|
|
||||||
"username": "cfuser12345",
|
|
||||||
"telephone": "+1 123-123-1234",
|
|
||||||
"country": "US",
|
|
||||||
"zipcode": "12345",
|
|
||||||
"created_on": "2014-01-01T05:20:00Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00Z",
|
|
||||||
"two_factor_authentication_enabled": false
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -72,26 +36,8 @@ class UserTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetUserEmail()
|
public function testGetUserEmail()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getUserEmail.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Appleseed",
|
|
||||||
"username": "cfuser12345",
|
|
||||||
"telephone": "+1 123-123-1234",
|
|
||||||
"country": "US",
|
|
||||||
"zipcode": "12345",
|
|
||||||
"created_on": "2014-01-01T05:20:00Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00Z",
|
|
||||||
"two_factor_authentication_enabled": false
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -103,26 +49,8 @@ class UserTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testUpdateUserDetails()
|
public function testUpdateUserDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateUserDetails.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"first_name": "John",
|
|
||||||
"last_name": "Appleseed",
|
|
||||||
"username": "cfuser12345",
|
|
||||||
"telephone": "+1 123-123-1234",
|
|
||||||
"country": "US",
|
|
||||||
"zipcode": "12345",
|
|
||||||
"created_on": "2014-01-01T05:20:00Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00Z",
|
|
||||||
"two_factor_authentication_enabled": false
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('patch')->willReturn($response);
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -6,38 +6,12 @@
|
|||||||
* Date: 04/09/2017
|
* Date: 04/09/2017
|
||||||
* Time: 21:23
|
* Time: 21:23
|
||||||
*/
|
*/
|
||||||
class ZoneLockdownTest extends PHPUnit_Framework_TestCase
|
class ZoneLockdownTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListLockdowns()
|
public function testListLockdowns()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listLockdowns.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Restrict access to these endpoints to requests from a known IP address",
|
|
||||||
"urls": [
|
|
||||||
"api.mysite.com/some/endpoint*"
|
|
||||||
],
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"target": "ip",
|
|
||||||
"value": "1.2.3.4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -67,26 +41,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
|
|||||||
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
||||||
$config->addIP('1.2.3.4');
|
$config->addIP('1.2.3.4');
|
||||||
|
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addLockdown.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Restrict access to these endpoints to requests from a known IP address",
|
|
||||||
"urls": [
|
|
||||||
"api.mysite.com/some/endpoint*"
|
|
||||||
],
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"target": "ip",
|
|
||||||
"value": "1.2.3.4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -115,30 +71,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetRecordDetails()
|
public function testGetRecordDetails()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getRecordDetails.json');
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Restrict access to these endpoints to requests from a known IP address",
|
|
||||||
"urls": [
|
|
||||||
"api.mysite.com/some/endpoint*"
|
|
||||||
],
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"target": "ip",
|
|
||||||
"value": "1.2.3.4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -160,30 +94,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
|
|||||||
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
||||||
$config->addIP('1.2.3.4');
|
$config->addIP('1.2.3.4');
|
||||||
|
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateLockdown.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
|
||||||
"description": "Restrict access to these endpoints to requests from a known IP address",
|
|
||||||
"urls": [
|
|
||||||
"api.mysite.com/some/endpoint*"
|
|
||||||
],
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"target": "ip",
|
|
||||||
"value": "1.2.3.4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('put')->willReturn($response);
|
$mock->method('put')->willReturn($response);
|
||||||
|
|
||||||
@@ -215,20 +127,8 @@ class ZoneLockdownTest extends PHPUnit_Framework_TestCase
|
|||||||
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
$config = new \Cloudflare\API\Configurations\ZoneLockdown();
|
||||||
$config->addIP('1.2.3.4');
|
$config->addIP('1.2.3.4');
|
||||||
|
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteLockdown.json');
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"errors": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"messages": [
|
|
||||||
{}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"id": "372e67954025e0ba6aaa6d586b9e0b59"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('delete')->willReturn($response);
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
@@ -6,65 +6,12 @@
|
|||||||
* Date: 06/06/2017
|
* Date: 06/06/2017
|
||||||
* Time: 16:01
|
* Time: 16:01
|
||||||
*/
|
*/
|
||||||
class ZonesTest extends PHPUnit_Framework_TestCase
|
class ZonesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testAddZone()
|
public function testAddZone()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addZone.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"name": "example.com",
|
|
||||||
"development_mode": 7200,
|
|
||||||
"original_name_servers": [
|
|
||||||
"ns1.originaldnshost.com",
|
|
||||||
"ns2.originaldnshost.com"
|
|
||||||
],
|
|
||||||
"original_registrar": "GoDaddy",
|
|
||||||
"original_dnshost": "NameCheap",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"name_servers": [
|
|
||||||
"tony.ns.cloudflare.com",
|
|
||||||
"woz.ns.cloudflare.com"
|
|
||||||
],
|
|
||||||
"owner": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"owner_type": "user"
|
|
||||||
},
|
|
||||||
"permissions": [
|
|
||||||
"#zone:read",
|
|
||||||
"#zone:edit"
|
|
||||||
],
|
|
||||||
"plan": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"plan_pending": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"status": "active",
|
|
||||||
"paused": false,
|
|
||||||
"type": "full"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -82,7 +29,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertObjectHasAttribute("id", $result);
|
$this->assertObjectHasAttribute("id", $result);
|
||||||
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result->id);
|
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result->id);
|
||||||
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.json');
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -103,15 +51,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testActivationTest()
|
public function testActivationTest()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/activationTest.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('put')->willReturn($response);
|
$mock->method('put')->willReturn($response);
|
||||||
|
|
||||||
@@ -131,69 +72,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testListZones()
|
public function testListZones()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listZones.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"name": "example.com",
|
|
||||||
"development_mode": 7200,
|
|
||||||
"original_name_servers": [
|
|
||||||
"ns1.originaldnshost.com",
|
|
||||||
"ns2.originaldnshost.com"
|
|
||||||
],
|
|
||||||
"original_registrar": "GoDaddy",
|
|
||||||
"original_dnshost": "NameCheap",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"name_servers": [
|
|
||||||
"tony.ns.cloudflare.com",
|
|
||||||
"woz.ns.cloudflare.com"
|
|
||||||
],
|
|
||||||
"owner": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"owner_type": "user"
|
|
||||||
},
|
|
||||||
"permissions": [
|
|
||||||
"#zone:read",
|
|
||||||
"#zone:edit"
|
|
||||||
],
|
|
||||||
"plan": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"plan_pending": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"status": "active",
|
|
||||||
"paused": false,
|
|
||||||
"type": "full"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -225,69 +105,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetZoneID()
|
public function testGetZoneID()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getZoneId.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
|
||||||
"name": "example.com",
|
|
||||||
"development_mode": 7200,
|
|
||||||
"original_name_servers": [
|
|
||||||
"ns1.originaldnshost.com",
|
|
||||||
"ns2.originaldnshost.com"
|
|
||||||
],
|
|
||||||
"original_registrar": "GoDaddy",
|
|
||||||
"original_dnshost": "NameCheap",
|
|
||||||
"created_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"modified_on": "2014-01-01T05:20:00.12345Z",
|
|
||||||
"name_servers": [
|
|
||||||
"tony.ns.cloudflare.com",
|
|
||||||
"woz.ns.cloudflare.com"
|
|
||||||
],
|
|
||||||
"owner": {
|
|
||||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
|
||||||
"email": "user@example.com",
|
|
||||||
"owner_type": "user"
|
|
||||||
},
|
|
||||||
"permissions": [
|
|
||||||
"#zone:read",
|
|
||||||
"#zone:edit"
|
|
||||||
],
|
|
||||||
"plan": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"plan_pending": {
|
|
||||||
"id": "e592fd9519420ba7405e1307bff33214",
|
|
||||||
"name": "Pro Plan",
|
|
||||||
"price": 20,
|
|
||||||
"currency": "USD",
|
|
||||||
"frequency": "monthly",
|
|
||||||
"legacy_id": "pro",
|
|
||||||
"is_subscribed": true,
|
|
||||||
"can_subscribe": true
|
|
||||||
},
|
|
||||||
"status": "active",
|
|
||||||
"paused": false,
|
|
||||||
"type": "full"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result_info": {
|
|
||||||
"page": 1,
|
|
||||||
"per_page": 20,
|
|
||||||
"count": 1,
|
|
||||||
"total_count": 2000
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
@@ -312,15 +131,8 @@ class ZonesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testCachePurgeEverything()
|
public function testCachePurgeEverything()
|
||||||
{
|
{
|
||||||
$stream = GuzzleHttp\Psr7\stream_for('{
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json');
|
||||||
"success": true,
|
|
||||||
"errors": [],
|
|
||||||
"messages": [],
|
|
||||||
"result": {
|
|
||||||
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
|
||||||
}
|
|
||||||
}');
|
|
||||||
$response = new GuzzleHttp\Psr7\Response(200, ['Content-Type' => 'application/json'], $stream);
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('delete')->willReturn($response);
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
|||||||
8
tests/Fixtures/Endpoints/activationTest.json
Normal file
8
tests/Fixtures/Endpoints/activationTest.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/addLockdown.json
Normal file
18
tests/Fixtures/Endpoints/addLockdown.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Restrict access to these endpoints to requests from a known IP address",
|
||||||
|
"urls": [
|
||||||
|
"api.mysite.com/some/endpoint*"
|
||||||
|
],
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"target": "ip",
|
||||||
|
"value": "1.2.3.4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
20
tests/Fixtures/Endpoints/addRecord.json
Normal file
20
tests/Fixtures/Endpoints/addRecord.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"type": "A",
|
||||||
|
"name": "example.com",
|
||||||
|
"content": "1.2.3.4",
|
||||||
|
"proxiable": true,
|
||||||
|
"proxied": false,
|
||||||
|
"ttl": 120,
|
||||||
|
"locked": false,
|
||||||
|
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"zone_name": "example.com",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
tests/Fixtures/Endpoints/addZone.json
Normal file
54
tests/Fixtures/Endpoints/addZone.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"name": "example.com",
|
||||||
|
"development_mode": 7200,
|
||||||
|
"original_name_servers": [
|
||||||
|
"ns1.originaldnshost.com",
|
||||||
|
"ns2.originaldnshost.com"
|
||||||
|
],
|
||||||
|
"original_registrar": "GoDaddy",
|
||||||
|
"original_dnshost": "NameCheap",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"name_servers": [
|
||||||
|
"tony.ns.cloudflare.com",
|
||||||
|
"woz.ns.cloudflare.com"
|
||||||
|
],
|
||||||
|
"owner": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"owner_type": "user"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"#zone:read",
|
||||||
|
"#zone:edit"
|
||||||
|
],
|
||||||
|
"plan": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"plan_pending": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"status": "active",
|
||||||
|
"paused": false,
|
||||||
|
"type": "full"
|
||||||
|
}
|
||||||
|
}
|
||||||
8
tests/Fixtures/Endpoints/cachePurgeEverything.json
Normal file
8
tests/Fixtures/Endpoints/cachePurgeEverything.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Fixtures/Endpoints/createPageRule.json
Normal file
31
tests/Fixtures/Endpoints/createPageRule.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "9a7806061c88ada191ed06f989cc3dac",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"target": "url",
|
||||||
|
"constraint": {
|
||||||
|
"operator": "matches",
|
||||||
|
"value": "*example.com/images/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "always_online",
|
||||||
|
"value": "on"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"priority": 1,
|
||||||
|
"status": "active",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/createRule.json
Normal file
18
tests/Fixtures/Endpoints/createRule.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
||||||
|
"mode": "js_challenge",
|
||||||
|
"configuration": {
|
||||||
|
"target": "ua",
|
||||||
|
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
tests/Fixtures/Endpoints/deleteLockdown.json
Normal file
12
tests/Fixtures/Endpoints/deleteLockdown.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
tests/Fixtures/Endpoints/deletePageRule.json
Normal file
12
tests/Fixtures/Endpoints/deletePageRule.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "9a7806061c88ada191ed06f989cc3dac"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
tests/Fixtures/Endpoints/deleteRule.json
Normal file
12
tests/Fixtures/Endpoints/deleteRule.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
tests/Fixtures/Endpoints/getDNSRecordDetails.json
Normal file
20
tests/Fixtures/Endpoints/getDNSRecordDetails.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"type": "A",
|
||||||
|
"name": "example.com",
|
||||||
|
"content": "1.2.3.4",
|
||||||
|
"proxiable": true,
|
||||||
|
"proxied": false,
|
||||||
|
"ttl": 120,
|
||||||
|
"locked": false,
|
||||||
|
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"zone_name": "example.com",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Fixtures/Endpoints/getPageRuleDetails.json
Normal file
31
tests/Fixtures/Endpoints/getPageRuleDetails.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "9a7806061c88ada191ed06f989cc3dac",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"target": "url",
|
||||||
|
"constraint": {
|
||||||
|
"operator": "matches",
|
||||||
|
"value": "*example.com/images/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "always_online",
|
||||||
|
"value": "on"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"priority": 1,
|
||||||
|
"status": "active",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
22
tests/Fixtures/Endpoints/getRecordDetails.json
Normal file
22
tests/Fixtures/Endpoints/getRecordDetails.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Restrict access to these endpoints to requests from a known IP address",
|
||||||
|
"urls": [
|
||||||
|
"api.mysite.com/some/endpoint*"
|
||||||
|
],
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"target": "ip",
|
||||||
|
"value": "1.2.3.4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/getRuleDetails.json
Normal file
18
tests/Fixtures/Endpoints/getRuleDetails.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
||||||
|
"mode": "js_challenge",
|
||||||
|
"configuration": {
|
||||||
|
"target": "ua",
|
||||||
|
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/getUserDetails.json
Normal file
18
tests/Fixtures/Endpoints/getUserDetails.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Appleseed",
|
||||||
|
"username": "cfuser12345",
|
||||||
|
"telephone": "+1 123-123-1234",
|
||||||
|
"country": "US",
|
||||||
|
"zipcode": "12345",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z",
|
||||||
|
"two_factor_authentication_enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/getUserEmail.json
Normal file
18
tests/Fixtures/Endpoints/getUserEmail.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Appleseed",
|
||||||
|
"username": "cfuser12345",
|
||||||
|
"telephone": "+1 123-123-1234",
|
||||||
|
"country": "US",
|
||||||
|
"zipcode": "12345",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z",
|
||||||
|
"two_factor_authentication_enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/getUserId.json
Normal file
18
tests/Fixtures/Endpoints/getUserId.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Appleseed",
|
||||||
|
"username": "cfuser12345",
|
||||||
|
"telephone": "+1 123-123-1234",
|
||||||
|
"country": "US",
|
||||||
|
"zipcode": "12345",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z",
|
||||||
|
"two_factor_authentication_enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
62
tests/Fixtures/Endpoints/getZoneId.json
Normal file
62
tests/Fixtures/Endpoints/getZoneId.json
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"name": "example.com",
|
||||||
|
"development_mode": 7200,
|
||||||
|
"original_name_servers": [
|
||||||
|
"ns1.originaldnshost.com",
|
||||||
|
"ns2.originaldnshost.com"
|
||||||
|
],
|
||||||
|
"original_registrar": "GoDaddy",
|
||||||
|
"original_dnshost": "NameCheap",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"name_servers": [
|
||||||
|
"tony.ns.cloudflare.com",
|
||||||
|
"woz.ns.cloudflare.com"
|
||||||
|
],
|
||||||
|
"owner": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"owner_type": "user"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"#zone:read",
|
||||||
|
"#zone:edit"
|
||||||
|
],
|
||||||
|
"plan": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"plan_pending": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"status": "active",
|
||||||
|
"paused": false,
|
||||||
|
"type": "full"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
13
tests/Fixtures/Endpoints/listIPs.json
Normal file
13
tests/Fixtures/Endpoints/listIPs.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"ipv4_cidrs": [
|
||||||
|
"199.27.128.0/21"
|
||||||
|
],
|
||||||
|
"ipv6_cidrs": [
|
||||||
|
"2400:cb00::/32"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Fixtures/Endpoints/listLockdowns.json
Normal file
26
tests/Fixtures/Endpoints/listLockdowns.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Restrict access to these endpoints to requests from a known IP address",
|
||||||
|
"urls": [
|
||||||
|
"api.mysite.com/some/endpoint*"
|
||||||
|
],
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"target": "ip",
|
||||||
|
"value": "1.2.3.4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
39
tests/Fixtures/Endpoints/listPageRules.json
Normal file
39
tests/Fixtures/Endpoints/listPageRules.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "9a7806061c88ada191ed06f989cc3dac",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"target": "url",
|
||||||
|
"constraint": {
|
||||||
|
"operator": "matches",
|
||||||
|
"value": "*example.com/images/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "always_online",
|
||||||
|
"value": "on"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"priority": 1,
|
||||||
|
"status": "active",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
28
tests/Fixtures/Endpoints/listRecords.json
Normal file
28
tests/Fixtures/Endpoints/listRecords.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"type": "A",
|
||||||
|
"name": "example.com",
|
||||||
|
"content": "1.2.3.4",
|
||||||
|
"proxiable": true,
|
||||||
|
"proxied": false,
|
||||||
|
"ttl": 120,
|
||||||
|
"locked": false,
|
||||||
|
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"zone_name": "example.com",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Fixtures/Endpoints/listRules.json
Normal file
26
tests/Fixtures/Endpoints/listRules.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
||||||
|
"mode": "js_challenge",
|
||||||
|
"configuration": {
|
||||||
|
"target": "ua",
|
||||||
|
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
62
tests/Fixtures/Endpoints/listZones.json
Normal file
62
tests/Fixtures/Endpoints/listZones.json
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"name": "example.com",
|
||||||
|
"development_mode": 7200,
|
||||||
|
"original_name_servers": [
|
||||||
|
"ns1.originaldnshost.com",
|
||||||
|
"ns2.originaldnshost.com"
|
||||||
|
],
|
||||||
|
"original_registrar": "GoDaddy",
|
||||||
|
"original_dnshost": "NameCheap",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"name_servers": [
|
||||||
|
"tony.ns.cloudflare.com",
|
||||||
|
"woz.ns.cloudflare.com"
|
||||||
|
],
|
||||||
|
"owner": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"owner_type": "user"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"#zone:read",
|
||||||
|
"#zone:edit"
|
||||||
|
],
|
||||||
|
"plan": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"plan_pending": {
|
||||||
|
"id": "e592fd9519420ba7405e1307bff33214",
|
||||||
|
"name": "Pro Plan",
|
||||||
|
"price": 20,
|
||||||
|
"currency": "USD",
|
||||||
|
"frequency": "monthly",
|
||||||
|
"legacy_id": "pro",
|
||||||
|
"is_subscribed": true,
|
||||||
|
"can_subscribe": true
|
||||||
|
},
|
||||||
|
"status": "active",
|
||||||
|
"paused": false,
|
||||||
|
"type": "full"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
22
tests/Fixtures/Endpoints/updateLockdown.json
Normal file
22
tests/Fixtures/Endpoints/updateLockdown.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Restrict access to these endpoints to requests from a known IP address",
|
||||||
|
"urls": [
|
||||||
|
"api.mysite.com/some/endpoint*"
|
||||||
|
],
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"target": "ip",
|
||||||
|
"value": "1.2.3.4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Fixtures/Endpoints/updatePageRule.json
Normal file
31
tests/Fixtures/Endpoints/updatePageRule.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "9a7806061c88ada191ed06f989cc3dac",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"target": "url",
|
||||||
|
"constraint": {
|
||||||
|
"operator": "matches",
|
||||||
|
"value": "*example.com/images/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "always_online",
|
||||||
|
"value": "on"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"priority": 1,
|
||||||
|
"status": "active",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/updateRule.json
Normal file
18
tests/Fixtures/Endpoints/updateRule.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "372e67954025e0ba6aaa6d586b9e0b59",
|
||||||
|
"description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack",
|
||||||
|
"mode": "js_challenge",
|
||||||
|
"configuration": {
|
||||||
|
"target": "ua",
|
||||||
|
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/Fixtures/Endpoints/updateUserDetails.json
Normal file
18
tests/Fixtures/Endpoints/updateUserDetails.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Appleseed",
|
||||||
|
"username": "cfuser12345",
|
||||||
|
"telephone": "+1 123-123-1234",
|
||||||
|
"country": "US",
|
||||||
|
"zipcode": "12345",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z",
|
||||||
|
"two_factor_authentication_enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
41
tests/TestCase.php
Normal file
41
tests/TestCase.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
use GuzzleHttp\Psr7;
|
||||||
|
|
||||||
|
abstract class TestCase extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns a PSR7 Stream for a given fixture.
|
||||||
|
*
|
||||||
|
* @param string $fixture The fixture to create the stream for.
|
||||||
|
* @return Psr7Stream
|
||||||
|
*/
|
||||||
|
protected function getPsr7StreamForFixture($fixture): Psr7\Stream
|
||||||
|
{
|
||||||
|
$path = sprintf('%s/Fixtures/%s', __DIR__, $fixture);
|
||||||
|
|
||||||
|
$this->assertFileExists($path);
|
||||||
|
|
||||||
|
$stream = Psr7\stream_for(file_get_contents($path));
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Psr7\Stream::class, $stream);
|
||||||
|
|
||||||
|
return $stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a PSR7 Response (JSON) for a given fixture.
|
||||||
|
*
|
||||||
|
* @param string $fixture The fixture to create the response for.
|
||||||
|
* @param integer $statusCode A HTTP Status Code for the response.
|
||||||
|
* @return Psr7Response
|
||||||
|
*/
|
||||||
|
protected function getPsr7JsonResponseForFixture($fixture, $statusCode = 200): Psr7\Response
|
||||||
|
{
|
||||||
|
$stream = $this->getPsr7StreamForFixture($fixture);
|
||||||
|
|
||||||
|
$this->assertNotNull(json_decode($stream));
|
||||||
|
$this->assertEquals(JSON_ERROR_NONE, json_last_error());
|
||||||
|
|
||||||
|
return new Psr7\Response($statusCode, ['Content-Type' => 'application/json'], $stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user