Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cfaed1019 | ||
|
|
84ee7302ca | ||
|
|
f088c67314 | ||
|
|
30fc22aa5b | ||
|
|
0d89f13f9b | ||
|
|
ca9e5bbc28 | ||
|
|
f0213ecf92 | ||
|
|
b4a6237509 | ||
|
|
a909f3780e | ||
|
|
6a76e1cc3c |
2
Makefile
2
Makefile
@@ -10,6 +10,8 @@ fix:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs --dry-run
|
php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs --dry-run
|
||||||
|
php $(HERE)/vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode
|
||||||
|
php $(HERE)/vendor/bin/phpmd tests/ text cleancode,codesize,controversial,design,naming,unusedcode
|
||||||
|
|
||||||
test:
|
test:
|
||||||
php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml
|
php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ Each API call is provided via a similarly named function within various classes
|
|||||||
- [x] User Administration (partial)
|
- [x] User Administration (partial)
|
||||||
- [x] [Cloudflare IPs](https://www.cloudflare.com/ips/)
|
- [x] [Cloudflare IPs](https://www.cloudflare.com/ips/)
|
||||||
- [x] [Page Rules](https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-)
|
- [x] [Page Rules](https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-)
|
||||||
- [ ] [Web Application Firewall (WAF)](https://www.cloudflare.com/waf/)
|
- [x] [Web Application Firewall (WAF)](https://www.cloudflare.com/waf/)
|
||||||
- [ ] Virtual DNS Management
|
- [ ] Virtual DNS Management
|
||||||
- [ ] Custom hostnames
|
- [ ] Custom hostnames
|
||||||
- [x] Zone Lockdown and User-Agent Block rules
|
- [x] Zone Lockdown and User-Agent Block rules
|
||||||
- [ ] Organization Administration
|
- [ ] Organization Administration
|
||||||
- [ ] [Railgun](https://www.cloudflare.com/railgun/) administration
|
- [x] [Railgun](https://www.cloudflare.com/railgun/) administration
|
||||||
- [ ] [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/)
|
- [ ] [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/)
|
||||||
- [ ] [Origin CA](https://blog.cloudflare.com/universal-ssl-encryption-all-the-way-to-the-origin-for-free/)
|
- [ ] [Origin CA](https://blog.cloudflare.com/universal-ssl-encryption-all-the-way-to-the-origin-for-free/)
|
||||||
|
|
||||||
|
|||||||
@@ -159,12 +159,12 @@ class PageRulesActions implements Configurations
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMinification(bool $html, bool $css, bool $js)
|
public function setMinification(bool $html, bool $css, bool $javascript)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("minification", [
|
$this->addConfigurationOption("minification", [
|
||||||
'html' => $this->getBoolAsOnOrOff($html),
|
'html' => $this->getBoolAsOnOrOff($html),
|
||||||
'css' => $this->getBoolAsOnOrOff($css),
|
'css' => $this->getBoolAsOnOrOff($css),
|
||||||
'js' => $this->getBoolAsOnOrOff($js),
|
'js' => $this->getBoolAsOnOrOff($javascript),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,9 +297,9 @@ class PageRulesActions implements Configurations
|
|||||||
return $this->configs;
|
return $this->configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addConfigurationOption($id, array $configuration)
|
private function addConfigurationOption(string $setting, array $configuration)
|
||||||
{
|
{
|
||||||
$configuration['id'] = $id;
|
$configuration['id'] = $setting;
|
||||||
|
|
||||||
array_push($this->configs, (object) $configuration);
|
array_push($this->configs, (object) $configuration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,17 @@ class DNS implements API
|
|||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||||
|
*
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $type
|
||||||
|
* @param string $name
|
||||||
|
* @param string $content
|
||||||
|
* @param int $ttl
|
||||||
|
* @param bool $proxied
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function addRecord(
|
public function addRecord(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $type,
|
string $type,
|
||||||
|
|||||||
@@ -21,6 +21,16 @@ class PageRules implements API
|
|||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||||
|
*
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param PageRulesTargets $target
|
||||||
|
* @param PageRulesActions $actions
|
||||||
|
* @param bool $active
|
||||||
|
* @param int|null $priority
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function createPageRule(
|
public function createPageRule(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
PageRulesTargets $target,
|
PageRulesTargets $target,
|
||||||
|
|||||||
107
src/Endpoints/Railgun.php
Normal file
107
src/Endpoints/Railgun.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 23/10/2017
|
||||||
|
* Time: 11:15
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
|
||||||
|
class Railgun implements API
|
||||||
|
{
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(
|
||||||
|
string $name
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'name' => $name,
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = $this->adapter->post('railguns', [], $query);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list(
|
||||||
|
int $page = 1,
|
||||||
|
int $perPage = 20,
|
||||||
|
string $direction = ""
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
$query['direction'] = $direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->adapter->get('railguns', $query, []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
$result = new \stdClass();
|
||||||
|
$result->result = $body->result;
|
||||||
|
$result->result_info = $body->result_info;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(
|
||||||
|
string $railgunID
|
||||||
|
): \stdClass {
|
||||||
|
$user = $this->adapter->get('railguns/' . $railgunID, [], []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getZones(
|
||||||
|
string $railgunID
|
||||||
|
): \stdClass {
|
||||||
|
$user = $this->adapter->get('railguns/' . $railgunID . '/zones', [], []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
$result = new \stdClass();
|
||||||
|
$result->result = $body->result;
|
||||||
|
$result->result_info = $body->result_info;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(
|
||||||
|
string $railgunID,
|
||||||
|
bool $status
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'enabled' => $status
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = $this->adapter->patch('railguns/' . $railgunID, [], $query);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(
|
||||||
|
string $railgunID
|
||||||
|
): bool {
|
||||||
|
$user = $this->adapter->delete('railguns/' . $railgunID, [], []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
if (isset($body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ class UARules implements API
|
|||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $mode,
|
string $mode,
|
||||||
\Cloudflare\API\Configurations\Configurations $configuration,
|
\Cloudflare\API\Configurations\Configurations $configuration,
|
||||||
string $id = null,
|
string $ruleID = null,
|
||||||
string $description = null
|
string $description = null
|
||||||
): bool {
|
): bool {
|
||||||
$options = [
|
$options = [
|
||||||
@@ -51,8 +51,8 @@ class UARules implements API
|
|||||||
'configurations' => $configuration->getArray()
|
'configurations' => $configuration->getArray()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($id !== null) {
|
if ($ruleID !== null) {
|
||||||
$options['id'] = $id;
|
$options['id'] = $ruleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($description !== null) {
|
if ($description !== null) {
|
||||||
|
|||||||
203
src/Endpoints/WAF.php
Normal file
203
src/Endpoints/WAF.php
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 23/10/2017
|
||||||
|
* Time: 11:17
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
|
||||||
|
class WAF implements \Cloudflare\API\Endpoints\API
|
||||||
|
{
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPackages(
|
||||||
|
string $zoneID,
|
||||||
|
int $page = 1,
|
||||||
|
int $perPage = 20,
|
||||||
|
string $order = "",
|
||||||
|
string $direction = "",
|
||||||
|
string $match = "all"
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
'match' => $match
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($order)) {
|
||||||
|
$query['order'] = $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
$query['direction'] = $direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages', $query, []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
$result = new \stdClass();
|
||||||
|
$result->result = $body->result;
|
||||||
|
$result->result_info = $body->result_info;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getPackageInfo(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID
|
||||||
|
): \stdClass {
|
||||||
|
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID, [], []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRules(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
int $page = 1,
|
||||||
|
int $perPage = 20,
|
||||||
|
string $order = "",
|
||||||
|
string $direction = "",
|
||||||
|
string $match = "all"
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
'match' => $match
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($order)) {
|
||||||
|
$query['order'] = $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
$query['direction'] = $direction;
|
||||||
|
}
|
||||||
|
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules', $query, []);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
$result = new \stdClass();
|
||||||
|
$result->result = $body->result;
|
||||||
|
$result->result_info = $body->result_info;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRuleInfo(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
string $ruleID
|
||||||
|
): \stdClass {
|
||||||
|
$user = $this->adapter->get(
|
||||||
|
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID,
|
||||||
|
[],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateRule(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
string $ruleID,
|
||||||
|
string $status
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'mode' => $status,
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = $this->adapter->patch(
|
||||||
|
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID,
|
||||||
|
[],
|
||||||
|
$query
|
||||||
|
);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGroups(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
int $page = 1,
|
||||||
|
int $perPage = 20,
|
||||||
|
string $order = "",
|
||||||
|
string $direction = "",
|
||||||
|
string $match = "all"
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
'match' => $match
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($order)) {
|
||||||
|
$query['order'] = $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
$query['direction'] = $direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->adapter->get(
|
||||||
|
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups',
|
||||||
|
$query,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
$result = new \stdClass();
|
||||||
|
$result->result = $body->result;
|
||||||
|
$result->result_info = $body->result_info;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGroupInfo(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
string $groupID
|
||||||
|
): \stdClass {
|
||||||
|
$user = $this->adapter->get(
|
||||||
|
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID,
|
||||||
|
[],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateGroup(
|
||||||
|
string $zoneID,
|
||||||
|
string $packageID,
|
||||||
|
string $groupID,
|
||||||
|
string $status
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'mode' => $status
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = $this->adapter->patch(
|
||||||
|
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID,
|
||||||
|
[],
|
||||||
|
$query
|
||||||
|
);
|
||||||
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
|
return $body->result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ class ZoneLockdown implements API
|
|||||||
string $zoneID,
|
string $zoneID,
|
||||||
array $urls,
|
array $urls,
|
||||||
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
|
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
|
||||||
string $id = null,
|
string $lockdownID = null,
|
||||||
string $description = null
|
string $description = null
|
||||||
): bool {
|
): bool {
|
||||||
$options = [
|
$options = [
|
||||||
@@ -51,8 +51,8 @@ class ZoneLockdown implements API
|
|||||||
'configurations' => $configuration->getArray()
|
'configurations' => $configuration->getArray()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($id !== null) {
|
if ($lockdownID !== null) {
|
||||||
$options['id'] = $id;
|
$options['id'] = $lockdownID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($description !== null) {
|
if ($description !== null) {
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ class Zones implements API
|
|||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param bool $jumpstart
|
||||||
|
* @param string $organizationID
|
||||||
|
* @return \stdClass
|
||||||
|
*/
|
||||||
public function addZone(string $name, bool $jumpstart = false, string $organizationID = ''): \stdClass
|
public function addZone(string $name, bool $jumpstart = false, string $organizationID = ''): \stdClass
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
@@ -119,9 +127,9 @@ class Zones implements API
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cachePurge(string $zoneID, array $files = [], array $tags = []): bool
|
public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool
|
||||||
{
|
{
|
||||||
if (empty($files) && empty($tags)) {
|
if (is_null($files) && is_null($tags)) {
|
||||||
throw new EndpointException("No files or tags to purge.");
|
throw new EndpointException("No files or tags to purge.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,6 @@ class GuzzleTest extends TestCase
|
|||||||
public function testNotFound()
|
public function testNotFound()
|
||||||
{
|
{
|
||||||
$this->expectException(\GuzzleHttp\Exception\RequestException::class);
|
$this->expectException(\GuzzleHttp\Exception\RequestException::class);
|
||||||
$response = $this->client->get('https://httpbin.org/status/404');
|
$this->client->get('https://httpbin.org/status/404');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class PageRulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
$result = $pageRules->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -60,8 +60,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$pr->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all');
|
$pageRules->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPageRuleDetails()
|
public function testGetPageRuleDetails()
|
||||||
@@ -78,8 +78,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$pr->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
$pageRules->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdatePageRule()
|
public function testUpdatePageRule()
|
||||||
@@ -106,8 +106,8 @@ class PageRulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
$result = $pageRules->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -127,8 +127,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
$result = $pageRules->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|||||||
153
tests/Endpoints/RailgunTest.php
Normal file
153
tests/Endpoints/RailgunTest.php
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 23/10/2017
|
||||||
|
* Time: 11:20
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Cloudflare\API\Endpoints\Railgun;
|
||||||
|
|
||||||
|
class RailgunTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testcreate()
|
||||||
|
{
|
||||||
|
$details = [
|
||||||
|
'name' => "My Railgun",
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRailgun.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('post')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo(['name' => $details['name']])
|
||||||
|
);
|
||||||
|
|
||||||
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$result = $railgun->create($details['name']);
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
|
||||||
|
foreach ($details as $property => $value) {
|
||||||
|
$this->assertEquals($result->result->{ $property }, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testlist()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRailguns.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 20,
|
||||||
|
'direction' => 'desc'
|
||||||
|
]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$result = $railgun->list(1, 20, "desc");
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testget()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getRailgun.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$result = $railgun->get("e928d310693a83094309acf9ead50448");
|
||||||
|
|
||||||
|
$this->assertEquals("e928d310693a83094309acf9ead50448", $result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testgetZones()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRailgunZones.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns/e928d310693a83094309acf9ead50448/zones'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$result = $railgun->getZones("e928d310693a83094309acf9ead50448");
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testupdate()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateRailgun.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
$details = [
|
||||||
|
'enabled' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('patch')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo($details)
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$result = $waf->update("e928d310693a83094309acf9ead50448", true);
|
||||||
|
|
||||||
|
$this->assertEquals("e928d310693a83094309acf9ead50448", $result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testdelete()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRailgun.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('delete')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
|
$waf->delete("e928d310693a83094309acf9ead50448");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 15:19
|
* Time: 15:19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Endpoints\UARules;
|
|
||||||
|
|
||||||
class UARulesTest extends TestCase
|
class UARulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListRules()
|
public function testListRules()
|
||||||
@@ -61,8 +59,8 @@ class UARulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->createRule(
|
$rules->createRule(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'js_challenge',
|
'js_challenge',
|
||||||
$config,
|
$config,
|
||||||
@@ -114,8 +112,8 @@ class UARulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->updateRule(
|
$rules->updateRule(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
'js_challenge',
|
'js_challenge',
|
||||||
@@ -139,7 +137,7 @@ class UARulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
$rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
223
tests/Endpoints/WAFTest.php
Normal file
223
tests/Endpoints/WAFTest.php
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: junade
|
||||||
|
* Date: 23/10/2017
|
||||||
|
* Time: 13:34
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Cloudflare\API\Endpoints\WAF;
|
||||||
|
|
||||||
|
class WAFTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testgetPackages()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listPackages.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 20,
|
||||||
|
'match' => 'all',
|
||||||
|
'order' => 'status',
|
||||||
|
'direction' => 'desc'
|
||||||
|
]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getPackages("023e105f4ecef8ad9ca31a8372d0c353", 1, 20, "status", "desc", "all");
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
|
$this->assertEquals("a25a9a7e9c00afc1fb2e0245519d725b", $result->result[0]->id);
|
||||||
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testgetPackageInfo()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageInfo.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b'),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getPackageInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b");
|
||||||
|
|
||||||
|
$this->assertEquals("a25a9a7e9c00afc1fb2e0245519d725b", $result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testgetRules()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listPackageRules.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 20,
|
||||||
|
'match' => 'all',
|
||||||
|
'order' => 'status',
|
||||||
|
'direction' => 'desc'
|
||||||
|
]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getRules("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", 1, 20, "status", "desc", "all");
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
|
$this->assertEquals("92f17202ed8bd63d69a66b86a49a8f6b", $result->result[0]->id);
|
||||||
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testgetRuleInfo()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageRuleInfo.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023'),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getRuleInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "f939de3be84e66e757adcdcb87908023");
|
||||||
|
|
||||||
|
$this->assertEquals("f939de3be84e66e757adcdcb87908023", $result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testupdateRule()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePackageRule.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
$details = [
|
||||||
|
'mode' => "on",
|
||||||
|
];
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('patch')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo($details)
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->updateRule("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "f939de3be84e66e757adcdcb87908023", "on");
|
||||||
|
|
||||||
|
$this->assertEquals("f939de3be84e66e757adcdcb87908023", $result->id);
|
||||||
|
|
||||||
|
foreach ($details as $property => $value) {
|
||||||
|
$this->assertEquals($result->{ $property }, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGroups()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listPackageGroups.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 20,
|
||||||
|
'match' => 'all',
|
||||||
|
'order' => 'status',
|
||||||
|
'direction' => 'desc'
|
||||||
|
]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getGroups("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", 1, 20, "status", "desc", "all");
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
|
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->result[0]->id);
|
||||||
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testgetGroupInfo()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageGroupInfo.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5'),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->getGroupInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "de677e5818985db1285d0e80225f06e5");
|
||||||
|
|
||||||
|
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testupdateGroup()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePackageGroup.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
$details = [
|
||||||
|
'mode' => "off",
|
||||||
|
];
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('patch')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo($details)
|
||||||
|
);
|
||||||
|
|
||||||
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
|
$result = $waf->updateGroup("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "de677e5818985db1285d0e80225f06e5", "off");
|
||||||
|
|
||||||
|
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->id);
|
||||||
|
|
||||||
|
foreach ($details as $property => $value) {
|
||||||
|
$this->assertEquals($result->{ $property }, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,8 +59,8 @@ class ZoneLockdownTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->createLockdown(
|
$zoneLockdown->createLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
["api.mysite.com/some/endpoint*"],
|
["api.mysite.com/some/endpoint*"],
|
||||||
$config,
|
$config,
|
||||||
@@ -112,8 +112,8 @@ class ZoneLockdownTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->updateLockdown(
|
$zoneLockdown->updateLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
["api.mysite.com/some/endpoint*"],
|
["api.mysite.com/some/endpoint*"],
|
||||||
@@ -140,7 +140,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
$zoneLockdown->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
tests/Fixtures/Endpoints/createRailgun.json
Normal file
23
tests/Fixtures/Endpoints/createRailgun.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "e928d310693a83094309acf9ead50448",
|
||||||
|
"name": "My Railgun",
|
||||||
|
"status": "active",
|
||||||
|
"enabled": true,
|
||||||
|
"zones_connected": 2,
|
||||||
|
"build": "b1234",
|
||||||
|
"version": "2.1",
|
||||||
|
"revision": "123",
|
||||||
|
"activation_key": "e4edc00281cb56ebac22c81be9bac8f3",
|
||||||
|
"activated_on": "2014-01-02T02:20:00Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
tests/Fixtures/Endpoints/deleteRailgun.json
Normal file
12
tests/Fixtures/Endpoints/deleteRailgun.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "e928d310693a83094309acf9ead50448"
|
||||||
|
}
|
||||||
|
}
|
||||||
22
tests/Fixtures/Endpoints/getPackageGroupInfo.json
Normal file
22
tests/Fixtures/Endpoints/getPackageGroupInfo.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "de677e5818985db1285d0e80225f06e5",
|
||||||
|
"name": "Project Honey Pot",
|
||||||
|
"description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks",
|
||||||
|
"rules_count": 10,
|
||||||
|
"modified_rules_count": 2,
|
||||||
|
"package_id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"mode": "on",
|
||||||
|
"allowed_modes": [
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
17
tests/Fixtures/Endpoints/getPackageInfo.json
Normal file
17
tests/Fixtures/Endpoints/getPackageInfo.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"name": "WordPress rules",
|
||||||
|
"description": "Common WordPress exploit protections",
|
||||||
|
"detection_mode": "traditional",
|
||||||
|
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
tests/Fixtures/Endpoints/getPackageRuleInfo.json
Normal file
24
tests/Fixtures/Endpoints/getPackageRuleInfo.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "f939de3be84e66e757adcdcb87908023",
|
||||||
|
"description": "SQL injection prevention for SELECT statements",
|
||||||
|
"priority": 5,
|
||||||
|
"group": {
|
||||||
|
"id": "de677e5818985db1285d0e80225f06e5",
|
||||||
|
"name": "Project Honey Pot"
|
||||||
|
},
|
||||||
|
"package_id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"allowed_modes": [
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
|
],
|
||||||
|
"mode": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
tests/Fixtures/Endpoints/getRailgun.json
Normal file
23
tests/Fixtures/Endpoints/getRailgun.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "e928d310693a83094309acf9ead50448",
|
||||||
|
"name": "My Railgun",
|
||||||
|
"status": "active",
|
||||||
|
"enabled": true,
|
||||||
|
"zones_connected": 2,
|
||||||
|
"build": "b1234",
|
||||||
|
"version": "2.1",
|
||||||
|
"revision": "123",
|
||||||
|
"activation_key": "e4edc00281cb56ebac22c81be9bac8f3",
|
||||||
|
"activated_on": "2014-01-02T02:20:00Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Fixtures/Endpoints/listPackageGroups.json
Normal file
30
tests/Fixtures/Endpoints/listPackageGroups.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "de677e5818985db1285d0e80225f06e5",
|
||||||
|
"name": "Project Honey Pot",
|
||||||
|
"description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks",
|
||||||
|
"rules_count": 10,
|
||||||
|
"modified_rules_count": 2,
|
||||||
|
"package_id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"mode": "on",
|
||||||
|
"allowed_modes": [
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
38
tests/Fixtures/Endpoints/listPackageRules.json
Normal file
38
tests/Fixtures/Endpoints/listPackageRules.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "92f17202ed8bd63d69a66b86a49a8f6b",
|
||||||
|
"notes": "This rule is on because of an event that occured on date X",
|
||||||
|
"allowed_modes": [
|
||||||
|
"whitelist",
|
||||||
|
"block",
|
||||||
|
"challenge"
|
||||||
|
],
|
||||||
|
"mode": "challenge",
|
||||||
|
"configuration": {
|
||||||
|
"target": "ip",
|
||||||
|
"value": "1.2.3.4"
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"type": "user"
|
||||||
|
},
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
25
tests/Fixtures/Endpoints/listPackages.json
Normal file
25
tests/Fixtures/Endpoints/listPackages.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"name": "WordPress rules",
|
||||||
|
"description": "Common WordPress exploit protections",
|
||||||
|
"detection_mode": "traditional",
|
||||||
|
"zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Fixtures/Endpoints/listRailgunZones.json
Normal file
30
tests/Fixtures/Endpoints/listRailgunZones.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Fixtures/Endpoints/listRailguns.json
Normal file
31
tests/Fixtures/Endpoints/listRailguns.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "e928d310693a83094309acf9ead50448",
|
||||||
|
"name": "My Railgun",
|
||||||
|
"status": "active",
|
||||||
|
"enabled": true,
|
||||||
|
"zones_connected": 2,
|
||||||
|
"build": "b1234",
|
||||||
|
"version": "2.1",
|
||||||
|
"revision": "123",
|
||||||
|
"activation_key": "e4edc00281cb56ebac22c81be9bac8f3",
|
||||||
|
"activated_on": "2014-01-02T02:20:00Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
22
tests/Fixtures/Endpoints/updatePackageGroup.json
Normal file
22
tests/Fixtures/Endpoints/updatePackageGroup.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "de677e5818985db1285d0e80225f06e5",
|
||||||
|
"name": "Project Honey Pot",
|
||||||
|
"description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks",
|
||||||
|
"rules_count": 10,
|
||||||
|
"modified_rules_count": 2,
|
||||||
|
"package_id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"mode": "off",
|
||||||
|
"allowed_modes": [
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
24
tests/Fixtures/Endpoints/updatePackageRule.json
Normal file
24
tests/Fixtures/Endpoints/updatePackageRule.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "f939de3be84e66e757adcdcb87908023",
|
||||||
|
"description": "SQL injection prevention for SELECT statements",
|
||||||
|
"priority": 5,
|
||||||
|
"group": {
|
||||||
|
"id": "de677e5818985db1285d0e80225f06e5",
|
||||||
|
"name": "Project Honey Pot"
|
||||||
|
},
|
||||||
|
"package_id": "a25a9a7e9c00afc1fb2e0245519d725b",
|
||||||
|
"allowed_modes": [
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
|
],
|
||||||
|
"mode": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
tests/Fixtures/Endpoints/updateRailgun.json
Normal file
23
tests/Fixtures/Endpoints/updateRailgun.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "e928d310693a83094309acf9ead50448",
|
||||||
|
"name": "My Railgun",
|
||||||
|
"status": "active",
|
||||||
|
"enabled": true,
|
||||||
|
"zones_connected": 2,
|
||||||
|
"build": "b1234",
|
||||||
|
"version": "2.1",
|
||||||
|
"revision": "123",
|
||||||
|
"activation_key": "e4edc00281cb56ebac22c81be9bac8f3",
|
||||||
|
"activated_on": "2014-01-02T02:20:00Z",
|
||||||
|
"created_on": "2014-01-01T05:20:00Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
use GuzzleHttp\Psr7;
|
use GuzzleHttp\Psr7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TestCase
|
||||||
|
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
||||||
|
*/
|
||||||
abstract class TestCase extends PHPUnit_Framework_TestCase
|
abstract class TestCase extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user