Compare commits
1 Commits
1.1.1
...
revert-49-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67c34b789e |
@@ -18,7 +18,7 @@ Each API call is provided via a similarly named function within various classes
|
||||
- [x] [Page Rules](https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-)
|
||||
- [x] [Web Application Firewall (WAF)](https://www.cloudflare.com/waf/)
|
||||
- [ ] Virtual DNS Management
|
||||
- [x] Custom hostnames
|
||||
- [ ] Custom hostnames
|
||||
- [x] Zone Lockdown and User-Agent Block rules
|
||||
- [ ] Organization Administration
|
||||
- [x] [Railgun](https://www.cloudflare.com/railgun/) administration
|
||||
|
||||
@@ -31,46 +31,46 @@ interface Adapter
|
||||
* RFCs, it is never useful).
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $data
|
||||
* @param array $query
|
||||
* @param array $headers
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $uri, array $data = [], array $headers = []): ResponseInterface;
|
||||
public function get(string $uri, array $query, array $headers): ResponseInterface;
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param array $data
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function post(string $uri, array $data = [], array $headers = []): ResponseInterface;
|
||||
public function post(string $uri, array $headers, array $body): ResponseInterface;
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param array $data
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function put(string $uri, array $data = [], array $headers = []): ResponseInterface;
|
||||
public function put(string $uri, array $headers, array $body): ResponseInterface;
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param array $data
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function patch(string $uri, array $data = [], array $headers = []): ResponseInterface;
|
||||
public function patch(string $uri, array $headers, array $body): ResponseInterface;
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param array $data
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(string $uri, array $data = [], array $headers = []): ResponseInterface;
|
||||
public function delete(string $uri, array $headers, array $body): ResponseInterface;
|
||||
}
|
||||
|
||||
@@ -37,56 +37,79 @@ class Guzzle implements Adapter
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get(string $uri, array $data = [], array $headers = []): ResponseInterface
|
||||
public function get(string $uri, array $query = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request('get', $uri, $data, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function post(string $uri, array $data = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request('post', $uri, $data, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function put(string $uri, array $data = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request('put', $uri, $data, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function patch(string $uri, array $data = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request('patch', $uri, $data, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(string $uri, array $data = [], array $headers = []): ResponseInterface
|
||||
{
|
||||
return $this->request('delete', $uri, $data, $headers);
|
||||
}
|
||||
|
||||
public function request(string $method, string $uri, array $data = [], array $headers = [])
|
||||
{
|
||||
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) {
|
||||
throw new \InvalidArgumentException('Request method must be get, post, put, patch, or delete');
|
||||
}
|
||||
|
||||
$response = $this->client->$method($uri, [
|
||||
'headers' => $headers,
|
||||
($method === 'get' ? 'query' : 'json') => $data,
|
||||
]);
|
||||
$response = $this->client->get($uri, ['query' => $query, 'headers' => $headers]);
|
||||
|
||||
$this->checkError($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function post(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||
{
|
||||
$response = $this->client->post(
|
||||
$uri,
|
||||
[
|
||||
'headers' => $headers,
|
||||
'json' => $body
|
||||
]
|
||||
);
|
||||
|
||||
$this->checkError($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function put(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||
{
|
||||
$response = $this->client->put(
|
||||
$uri,
|
||||
[
|
||||
'headers' => $headers,
|
||||
'json' => $body
|
||||
]
|
||||
);
|
||||
|
||||
$this->checkError($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function patch(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||
{
|
||||
$response = $this->client->patch(
|
||||
$uri,
|
||||
[
|
||||
'headers' => $headers,
|
||||
'json' => $body
|
||||
]
|
||||
);
|
||||
|
||||
$this->checkError($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||
{
|
||||
$response = $this->client->delete(
|
||||
$uri,
|
||||
[
|
||||
'headers' => $headers,
|
||||
'json' => $body
|
||||
]
|
||||
);
|
||||
|
||||
$this->checkError($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,11 +132,9 @@ class PageRulesActions implements Configurations
|
||||
throw new ConfigurationsException('Status Codes can only be 301 or 302.');
|
||||
}
|
||||
|
||||
$this->addConfigurationOption("forwarding_url", [
|
||||
'value' => [
|
||||
'status_code' => $statusCode,
|
||||
'url' => $forwardingUrl,
|
||||
],
|
||||
$this->addConfigurationOption('forwarding_url', [
|
||||
'status_code' => $statusCode,
|
||||
'url' => $forwardingUrl,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -303,7 +301,7 @@ class PageRulesActions implements Configurations
|
||||
{
|
||||
$configuration['id'] = $setting;
|
||||
|
||||
array_push($this->configs, $configuration);
|
||||
$this->configs[] = (object) $configuration;
|
||||
}
|
||||
|
||||
private function getBoolAsOnOrOff(bool $value): string
|
||||
|
||||
@@ -15,9 +15,9 @@ class PageRulesTargets implements Configurations
|
||||
public function __construct(string $queryUrl)
|
||||
{
|
||||
$this->targets = [
|
||||
[
|
||||
(object)[
|
||||
'target' => 'url',
|
||||
'constraint' => [
|
||||
'constraint' => (object)[
|
||||
'operator' => 'matches',
|
||||
'value' => $queryUrl
|
||||
]
|
||||
|
||||
@@ -14,7 +14,7 @@ class UARules implements Configurations
|
||||
|
||||
public function addUA(string $value)
|
||||
{
|
||||
$this->configs[] = ['target' => 'ua', 'value' => $value];
|
||||
$this->configs[] = (object)['target' => 'ua', 'value' => $value];
|
||||
}
|
||||
|
||||
public function getArray(): array
|
||||
|
||||
@@ -14,12 +14,12 @@ class ZoneLockdown implements Configurations
|
||||
|
||||
public function addIP(string $value)
|
||||
{
|
||||
$this->configs[] = ['target' => 'ip', 'value' => $value];
|
||||
$this->configs[] = (object)['target' => 'ip', 'value' => $value];
|
||||
}
|
||||
|
||||
public function addIPRange(string $value)
|
||||
{
|
||||
$this->configs[] = ['target' => 'ip_range', 'value' => $value];
|
||||
$this->configs[] = (object)['target' => 'ip_range', 'value' => $value];
|
||||
}
|
||||
|
||||
public function getArray(): array
|
||||
|
||||
@@ -77,7 +77,7 @@ class AccessRules implements API
|
||||
$query['notes'] = $notes;
|
||||
}
|
||||
|
||||
$data = $this->adapter->get('zones/' . $zoneID . '/firewall/access_rules/rules', $query);
|
||||
$data = $this->adapter->get('zones/' . $zoneID . '/firewall/access_rules/rules', $query, []);
|
||||
$body = json_decode($data->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -91,14 +91,14 @@ class AccessRules implements API
|
||||
): bool {
|
||||
$options = [
|
||||
'mode' => $mode,
|
||||
'configuration' => $configuration->getArray()
|
||||
'configuration' => (object) $configuration->getArray()
|
||||
];
|
||||
|
||||
if ($notes !== null) {
|
||||
$options['notes'] = $notes;
|
||||
}
|
||||
|
||||
$query = $this->adapter->post('zones/' . $zoneID . '/firewall/access_rules/rules', $options);
|
||||
$query = $this->adapter->post('zones/' . $zoneID . '/firewall/access_rules/rules', [], $options);
|
||||
|
||||
$body = json_decode($query->getBody());
|
||||
|
||||
@@ -123,7 +123,7 @@ class AccessRules implements API
|
||||
$options['notes'] = $notes;
|
||||
}
|
||||
|
||||
$query = $this->adapter->patch('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, $options);
|
||||
$query = $this->adapter->patch('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, [], $options);
|
||||
|
||||
$body = json_decode($query->getBody());
|
||||
|
||||
@@ -140,7 +140,7 @@ class AccessRules implements API
|
||||
'cascade' => $cascade
|
||||
];
|
||||
|
||||
$data = $this->adapter->delete('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, $options);
|
||||
$data = $this->adapter->delete('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, [], $options);
|
||||
|
||||
$body = json_decode($data->getBody());
|
||||
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: junade
|
||||
* Date: 18/03/2018
|
||||
* Time: 21:46
|
||||
*/
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
|
||||
class CustomHostnames implements API
|
||||
{
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*
|
||||
* @param string $zoneID
|
||||
* @param string $hostname
|
||||
* @param string $sslMethod
|
||||
* @param string $sslType
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv'): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'hostname' => $hostname,
|
||||
'ssl' => [
|
||||
'method' => $sslMethod,
|
||||
'type' => $sslType
|
||||
]
|
||||
];
|
||||
|
||||
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);
|
||||
$body = json_decode($zone->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zoneID
|
||||
* @param string $hostname
|
||||
* @param string $id
|
||||
* @param int $page
|
||||
* @param int $perPage
|
||||
* @param string $order
|
||||
* @param string $direction
|
||||
* @param int $ssl
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function listHostnames(
|
||||
string $zoneID,
|
||||
string $hostname = '',
|
||||
string $hostnameID = '',
|
||||
int $page = 1,
|
||||
int $perPage = 20,
|
||||
string $order = '',
|
||||
string $direction = '',
|
||||
int $ssl = 0
|
||||
): \stdClass {
|
||||
$query = [
|
||||
'page' => $page,
|
||||
'per_page' => $perPage,
|
||||
'ssl' => $ssl
|
||||
];
|
||||
|
||||
if (!empty($hostname)) {
|
||||
$query['hostname'] = $hostname;
|
||||
}
|
||||
|
||||
if (!empty($hostnameID)) {
|
||||
$query['id'] = $hostnameID;
|
||||
}
|
||||
|
||||
if (!empty($order)) {
|
||||
$query['order'] = $order;
|
||||
}
|
||||
|
||||
if (!empty($direction)) {
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
|
||||
$zone = $this->adapter->get('zones/'.$zoneID.'/custom_hostnames', $query);
|
||||
$body = json_decode($zone->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zoneID
|
||||
* @param string $hostnameID
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHostname(string $zoneID, string $hostnameID)
|
||||
{
|
||||
$zone = $this->adapter->get('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID);
|
||||
$body = json_decode($zone->getBody());
|
||||
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*
|
||||
* @param string $zoneID
|
||||
* @param string $hostnameID
|
||||
* @param string $sslMethod
|
||||
* @param string $sslType
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = ''): \stdClass
|
||||
{
|
||||
$query = [];
|
||||
|
||||
if (!empty($sslMethod)) {
|
||||
$query['method'] = $sslMethod;
|
||||
}
|
||||
|
||||
if (!empty($sslType)) {
|
||||
$query['type'] = $sslType;
|
||||
}
|
||||
|
||||
$options = [
|
||||
'ssl' => $query
|
||||
];
|
||||
|
||||
$zone = $this->adapter->patch('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID, $options);
|
||||
$body = json_decode($zone->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $zoneID
|
||||
* @param string $hostnameID
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function deleteHostname(string $zoneID, string $hostnameID): \stdClass
|
||||
{
|
||||
$zone = $this->adapter->delete('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID);
|
||||
$body = json_decode($zone->getBody());
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ class DNS implements API
|
||||
* @param string $content
|
||||
* @param int $ttl
|
||||
* @param bool $proxied
|
||||
* @param string $priority
|
||||
* @return bool
|
||||
*/
|
||||
public function addRecord(
|
||||
@@ -37,8 +36,7 @@ class DNS implements API
|
||||
string $name,
|
||||
string $content,
|
||||
int $ttl = 0,
|
||||
bool $proxied = true,
|
||||
string $priority = ''
|
||||
bool $proxied = true
|
||||
): bool {
|
||||
$options = [
|
||||
'type' => $type,
|
||||
@@ -51,11 +49,7 @@ class DNS implements API
|
||||
$options['ttl'] = $ttl;
|
||||
}
|
||||
|
||||
if (!empty($priority)) {
|
||||
$options['priority'] = (int)$priority;
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options);
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/dns_records', [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -103,7 +97,7 @@ class DNS implements API
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -111,20 +105,20 @@ class DNS implements API
|
||||
|
||||
public function getRecordDetails(string $zoneID, string $recordID): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records/' . $recordID);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records/' . $recordID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
public function updateRecordDetails(string $zoneID, string $recordID, array $details): \stdClass
|
||||
{
|
||||
$response = $this->adapter->put('zones/' . $zoneID . '/dns_records/' . $recordID, $details);
|
||||
$response = $this->adapter->put('zones/' . $zoneID . '/dns_records/' . $recordID, [], $details);
|
||||
return json_decode($response->getBody());
|
||||
}
|
||||
|
||||
public function deleteRecord(string $zoneID, string $recordID): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/dns_records/' . $recordID);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/dns_records/' . $recordID, [], []);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class IPs implements API
|
||||
|
||||
public function listIPs(): \stdClass
|
||||
{
|
||||
$ips = $this->adapter->get('ips');
|
||||
$ips = $this->adapter->get('ips', [], []);
|
||||
$body = json_decode($ips->getBody());
|
||||
|
||||
return $body->result;
|
||||
|
||||
@@ -52,7 +52,7 @@ class PageRules implements API
|
||||
}
|
||||
|
||||
|
||||
$query = $this->adapter->post('zones/' . $zoneID . '/pagerules', $options);
|
||||
$query = $this->adapter->post('zones/' . $zoneID . '/pagerules', [], $options);
|
||||
|
||||
$body = json_decode($query->getBody());
|
||||
|
||||
@@ -93,7 +93,7 @@ class PageRules implements API
|
||||
'match' => $match
|
||||
];
|
||||
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/pagerules', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/pagerules', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -101,7 +101,7 @@ class PageRules implements API
|
||||
|
||||
public function getPageRuleDetails(string $zoneID, string $ruleID): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/pagerules/' . $ruleID);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/pagerules/' . $ruleID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class PageRules implements API
|
||||
}
|
||||
|
||||
|
||||
$query = $this->adapter->patch('zones/' . $zoneID . '/pagerules', $options);
|
||||
$query = $this->adapter->patch('zones/' . $zoneID . '/pagerules', [], $options);
|
||||
|
||||
$body = json_decode($query->getBody());
|
||||
|
||||
@@ -145,7 +145,7 @@ class PageRules implements API
|
||||
|
||||
public function deletePageRule(string $zoneID, string $ruleID): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/pagerules/' . $ruleID);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/pagerules/' . $ruleID, [], []);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Railgun implements API
|
||||
'name' => $name,
|
||||
];
|
||||
|
||||
$user = $this->adapter->post('railguns', $query);
|
||||
$user = $this->adapter->post('railguns', [], $query);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body;
|
||||
@@ -46,7 +46,7 @@ class Railgun implements API
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
|
||||
$user = $this->adapter->get('railguns', $query);
|
||||
$user = $this->adapter->get('railguns', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -55,7 +55,7 @@ class Railgun implements API
|
||||
public function get(
|
||||
string $railgunID
|
||||
): \stdClass {
|
||||
$user = $this->adapter->get('railguns/' . $railgunID);
|
||||
$user = $this->adapter->get('railguns/' . $railgunID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -64,7 +64,7 @@ class Railgun implements API
|
||||
public function getZones(
|
||||
string $railgunID
|
||||
): \stdClass {
|
||||
$user = $this->adapter->get('railguns/' . $railgunID . '/zones');
|
||||
$user = $this->adapter->get('railguns/' . $railgunID . '/zones', [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -78,7 +78,7 @@ class Railgun implements API
|
||||
'enabled' => $status
|
||||
];
|
||||
|
||||
$user = $this->adapter->patch('railguns/' . $railgunID, $query);
|
||||
$user = $this->adapter->patch('railguns/' . $railgunID, [], $query);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -87,7 +87,7 @@ class Railgun implements API
|
||||
public function delete(
|
||||
string $railgunID
|
||||
): bool {
|
||||
$user = $this->adapter->delete('railguns/' . $railgunID);
|
||||
$user = $this->adapter->delete('railguns/' . $railgunID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
if (isset($body->result->id)) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class UARules implements API
|
||||
'per_page' => $perPage
|
||||
];
|
||||
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -56,7 +56,7 @@ class UARules implements API
|
||||
$options['description'] = $description;
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/firewall/ua_rules', $options);
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/firewall/ua_rules', [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -69,7 +69,7 @@ class UARules implements API
|
||||
|
||||
public function getRuleDetails(string $zoneID, string $blockID): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules/' . $blockID);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules/' . $blockID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class UARules implements API
|
||||
$options['description'] = $description;
|
||||
}
|
||||
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID, $options);
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID, [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -104,7 +104,7 @@ class UARules implements API
|
||||
|
||||
public function deleteRule(string $zoneID, string $ruleID): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID, [], []);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class User implements API
|
||||
|
||||
public function getUserDetails(): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('user');
|
||||
$user = $this->adapter->get('user', [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class User implements API
|
||||
|
||||
public function updateUserDetails(array $details): \stdClass
|
||||
{
|
||||
$response = $this->adapter->patch('user', $details);
|
||||
$response = $this->adapter->patch('user', [], $details);
|
||||
return json_decode($response->getBody());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class WAF implements API
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -52,7 +52,7 @@ class WAF implements API
|
||||
string $zoneID,
|
||||
string $packageID
|
||||
): \stdClass {
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -80,7 +80,7 @@ class WAF implements API
|
||||
if (!empty($direction)) {
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -91,7 +91,11 @@ class WAF implements API
|
||||
string $packageID,
|
||||
string $ruleID
|
||||
): \stdClass {
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID);
|
||||
$user = $this->adapter->get(
|
||||
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -109,6 +113,7 @@ class WAF implements API
|
||||
|
||||
$user = $this->adapter->patch(
|
||||
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID,
|
||||
[],
|
||||
$query
|
||||
);
|
||||
$body = json_decode($user->getBody());
|
||||
@@ -141,7 +146,8 @@ class WAF implements API
|
||||
|
||||
$user = $this->adapter->get(
|
||||
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups',
|
||||
$query
|
||||
$query,
|
||||
[]
|
||||
);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -153,7 +159,11 @@ class WAF implements API
|
||||
string $packageID,
|
||||
string $groupID
|
||||
): \stdClass {
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID);
|
||||
$user = $this->adapter->get(
|
||||
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return $body->result;
|
||||
@@ -171,6 +181,7 @@ class WAF implements API
|
||||
|
||||
$user = $this->adapter->patch(
|
||||
'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID,
|
||||
[],
|
||||
$query
|
||||
);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -29,7 +29,7 @@ class ZoneLockdown implements API
|
||||
'per_page' => $perPage
|
||||
];
|
||||
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns', $query);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -55,7 +55,7 @@ class ZoneLockdown implements API
|
||||
$options['description'] = $description;
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/firewall/lockdowns', $options);
|
||||
$user = $this->adapter->post('zones/' . $zoneID . '/firewall/lockdowns', [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -68,7 +68,7 @@ class ZoneLockdown implements API
|
||||
|
||||
public function getLockdownDetails(string $zoneID, string $lockdownID): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID);
|
||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID, [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class ZoneLockdown implements API
|
||||
$options['description'] = $description;
|
||||
}
|
||||
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID, $options);
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID, [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -103,7 +103,7 @@ class ZoneLockdown implements API
|
||||
|
||||
public function deleteLockdown(string $zoneID, string $lockdownID): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID, [], []);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
|
||||
@@ -35,17 +35,17 @@ class Zones implements API
|
||||
];
|
||||
|
||||
if (!empty($organizationID)) {
|
||||
$options['organization'] = ['id' => $organizationID];
|
||||
$options['organization'] = (object)['id' => $organizationID];
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones', $options);
|
||||
$user = $this->adapter->post('zones', [], $options);
|
||||
$body = json_decode($user->getBody());
|
||||
return $body->result;
|
||||
}
|
||||
|
||||
public function activationCheck(string $zoneID): bool
|
||||
{
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/activation_check');
|
||||
$user = $this->adapter->put('zones/' . $zoneID . '/activation_check', [], []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
if (isset($body->result->id)) {
|
||||
@@ -86,7 +86,7 @@ class Zones implements API
|
||||
$query['direction'] = $direction;
|
||||
}
|
||||
|
||||
$user = $this->adapter->get('zones', $query);
|
||||
$user = $this->adapter->get('zones', $query, []);
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||
@@ -114,7 +114,7 @@ class Zones implements API
|
||||
*/
|
||||
public function getAnalyticsDashboard(string $zoneID, string $since = '-10080', string $until = '0', bool $continuous = true): \stdClass
|
||||
{
|
||||
$response = $this->adapter->get('zones/' . $zoneID . '/analytics/dashboard', ['since' => $since, 'until' => $until, 'continuous' => var_export($continuous, true)]);
|
||||
$response = $this->adapter->get('zones/' . $zoneID . '/analytics/dashboard', ['since' => $since, 'until' => $until, 'continuous' => var_export($continuous, true)], []);
|
||||
|
||||
return json_decode($response->getBody())->result;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class Zones implements API
|
||||
*/
|
||||
public function changeDevelopmentMode(string $zoneID, bool $enable = false): bool
|
||||
{
|
||||
$response = $this->adapter->patch('zones/' . $zoneID . '/settings/development_mode', ['value' => $enable ? 'on' : 'off']);
|
||||
$response = $this->adapter->patch('zones/' . $zoneID . '/settings/development_mode', [], ['value' => $enable ? 'on' : 'off']);
|
||||
|
||||
$body = json_decode($response->getBody());
|
||||
|
||||
@@ -147,7 +147,7 @@ class Zones implements API
|
||||
*/
|
||||
public function cachePurgeEverything(string $zoneID): bool
|
||||
{
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', ['purge_everything' => true]);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', [], ['purge_everything' => true]);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
@@ -158,26 +158,18 @@ class Zones implements API
|
||||
return false;
|
||||
}
|
||||
|
||||
public function cachePurge(string $zoneID, array $files = null, array $tags = null, array $hosts = null): bool
|
||||
public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool
|
||||
{
|
||||
if ($files === null && $tags === null && $hosts === null) {
|
||||
throw new EndpointException('No files, tags or hosts to purge.');
|
||||
if ($files === null && $tags === null) {
|
||||
throw new EndpointException('No files or tags to purge.');
|
||||
}
|
||||
|
||||
$options = [];
|
||||
if (!is_null($files)) {
|
||||
$options['files'] = $files;
|
||||
}
|
||||
$options = [
|
||||
'files' => $files,
|
||||
'tags' => $tags
|
||||
];
|
||||
|
||||
if (!is_null($tags)) {
|
||||
$options['tags'] = $tags;
|
||||
}
|
||||
|
||||
if (!is_null($hosts)) {
|
||||
$options['hosts'] = $hosts;
|
||||
}
|
||||
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', $options);
|
||||
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', [], $options);
|
||||
|
||||
$body = json_decode($user->getBody());
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class GuzzleTest extends TestCase
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$response = $this->client->post('https://httpbin.org/post', ['X-Post-Test' => 'Testing a POST request.']);
|
||||
$response = $this->client->post('https://httpbin.org/post', [], ['X-Post-Test' => 'Testing a POST request.']);
|
||||
|
||||
$headers = $response->getHeaders();
|
||||
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||
@@ -52,7 +52,7 @@ class GuzzleTest extends TestCase
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$response = $this->client->put('https://httpbin.org/put', ['X-Put-Test' => 'Testing a PUT request.']);
|
||||
$response = $this->client->put('https://httpbin.org/put', [], ['X-Put-Test' => 'Testing a PUT request.']);
|
||||
|
||||
$headers = $response->getHeaders();
|
||||
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||
@@ -65,6 +65,7 @@ class GuzzleTest extends TestCase
|
||||
{
|
||||
$response = $this->client->patch(
|
||||
'https://httpbin.org/patch',
|
||||
[],
|
||||
['X-Patch-Test' => 'Testing a PATCH request.']
|
||||
);
|
||||
|
||||
@@ -79,6 +80,7 @@ class GuzzleTest extends TestCase
|
||||
{
|
||||
$response = $this->client->delete(
|
||||
'https://httpbin.org/delete',
|
||||
[],
|
||||
['X-Delete-Test' => 'Testing a DELETE request.']
|
||||
);
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ class ConfigurationsUARulesTest extends TestCase
|
||||
$array = $configuration->getArray();
|
||||
$this->assertCount(1, $array);
|
||||
|
||||
$this->assertArrayHasKey('target', $array[0]);
|
||||
$this->assertEquals('ua', $array[0]['target']);
|
||||
$this->assertArrayHasKey('value', $array[0]);
|
||||
$this->assertObjectHasAttribute('target', $array[0]);
|
||||
$this->assertEquals('ua', $array[0]->target);
|
||||
$this->assertObjectHasAttribute('value', $array[0]);
|
||||
$this->assertEquals(
|
||||
'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',
|
||||
$array[0]['value']
|
||||
$array[0]->value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ class ConfigurationsZoneLockdownTest extends TestCase
|
||||
$array = $configuration->getArray();
|
||||
$this->assertCount(1, $array);
|
||||
|
||||
$this->assertArrayHasKey('target', $array[0]);
|
||||
$this->assertEquals('ip', $array[0]['target']);
|
||||
$this->assertArrayHasKey('value', $array[0]);
|
||||
$this->assertEquals('1.2.3.4', $array[0]['value']);
|
||||
$this->assertObjectHasAttribute('target', $array[0]);
|
||||
$this->assertEquals('ip', $array[0]->target);
|
||||
$this->assertObjectHasAttribute('value', $array[0]);
|
||||
$this->assertEquals('1.2.3.4', $array[0]->value);
|
||||
|
||||
$configuration->addIPRange('1.2.3.4/24');
|
||||
|
||||
$array = $configuration->getArray();
|
||||
$this->assertCount(2, $array);
|
||||
|
||||
$this->assertArrayHasKey('target', $array[1]);
|
||||
$this->assertEquals('ip_range', $array[1]['target']);
|
||||
$this->assertArrayHasKey('value', $array[1]);
|
||||
$this->assertEquals('1.2.3.4/24', $array[1]['value']);
|
||||
$this->assertObjectHasAttribute('target', $array[1]);
|
||||
$this->assertEquals('ip_range', $array[1]->target);
|
||||
$this->assertObjectHasAttribute('value', $array[1]);
|
||||
$this->assertEquals('1.2.3.4/24', $array[1]->value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
use Cloudflare\API\Configurations\PageRulesActions;
|
||||
|
||||
class PageRulesActionTest extends TestCase
|
||||
{
|
||||
public function testForwardingURLConfigurationIsApplied()
|
||||
{
|
||||
$identifier = 'forwarding_url';
|
||||
$statusCode = 301;
|
||||
$forwardingURL = 'https://www.example.org/';
|
||||
|
||||
$actions = new PageRulesActions();
|
||||
$actions->setForwardingURL($statusCode, $forwardingURL);
|
||||
$configuration = $actions->getArray();
|
||||
|
||||
$this->assertCount(1, $configuration);
|
||||
$this->assertEquals($identifier, $configuration[0]['id']);
|
||||
$this->assertEquals($statusCode, $configuration[0]['value']['status_code']);
|
||||
$this->assertEquals($forwardingURL, $configuration[0]['value']['url']);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class PageRulesTargetTest extends TestCase
|
||||
$array = $targets->getArray();
|
||||
|
||||
$this->assertCount(1, $array);
|
||||
$this->assertEquals('junade.com/*', $array[0]['constraint']['value']);
|
||||
$this->assertEquals('matches', $array[0]['constraint']['operator']);
|
||||
$this->assertEquals('junade.com/*', $array[0]->constraint->value);
|
||||
$this->assertEquals('matches', $array[0]->constraint->operator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ class AccessRulesTest extends TestCase
|
||||
'page' => 1,
|
||||
'per_page' => 50,
|
||||
'match' => 'all'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\AccessRules($mock);
|
||||
@@ -44,9 +45,10 @@ class AccessRulesTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'mode' => 'challenge',
|
||||
'configuration' => $config->getArray(),
|
||||
'configuration' => (object) $config->getArray(),
|
||||
'notes' => 'This rule is on because of an event that occured on date X',
|
||||
])
|
||||
);
|
||||
@@ -71,6 +73,7 @@ class AccessRulesTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules/92f17202ed8bd63d69a66b86a49a8f6b'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'mode' => 'challenge',
|
||||
'notes' => 'This rule is on because of an event that occured on date X',
|
||||
@@ -97,6 +100,7 @@ class AccessRulesTest extends TestCase
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules/92f17202ed8bd63d69a66b86a49a8f6b'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'cascade' => 'none'
|
||||
])
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: junade
|
||||
* Date: 18/03/2018
|
||||
* Time: 22:23
|
||||
*/
|
||||
|
||||
use Cloudflare\API\Endpoints\CustomHostnames;
|
||||
|
||||
class CustomHostnamesTest extends TestCase
|
||||
{
|
||||
public function testAddHostname()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createCustomHostname.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames'),
|
||||
$this->equalTo([
|
||||
'hostname' => 'app.example.com',
|
||||
'ssl' => [
|
||||
'method' => 'http',
|
||||
'type' => 'dv'
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$hostname = new CustomHostnames($mock);
|
||||
$hostname->addHostname('023e105f4ecef8ad9ca31a8372d0c353', 'app.example.com', 'http', 'dv');
|
||||
}
|
||||
|
||||
public function testListHostnames()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listHostnames.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/custom_hostnames'),
|
||||
$this->equalTo([
|
||||
'hostname' => 'app.example.com',
|
||||
'id' => '0d89c70d-ad9f-4843-b99f-6cc0252067e9',
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'order' => 'ssl',
|
||||
'direction' => 'desc',
|
||||
'ssl' => 0
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock);
|
||||
$result = $zones->listHostnames('023e105f4ecef8ad9ca31a8372d0c353', 'app.example.com', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 1, 20, 'ssl', 'desc', 0);
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
$this->assertObjectHasAttribute('result_info', $result);
|
||||
|
||||
$this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $result->result[0]->id);
|
||||
$this->assertEquals(1, $result->result_info->page);
|
||||
}
|
||||
|
||||
public function testGetHostname()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getHostname.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/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9')
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock);
|
||||
$result = $zones->getHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', '0d89c70d-ad9f-4843-b99f-6cc0252067e9');
|
||||
|
||||
$this->assertObjectHasAttribute('id', $result);
|
||||
$this->assertObjectHasAttribute('hostname', $result);
|
||||
}
|
||||
|
||||
public function testUpdateHostname()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('patch')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9'),
|
||||
$this->equalTo([
|
||||
'ssl' => [
|
||||
'method' => 'http',
|
||||
'type' => 'dv'
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock);
|
||||
$result = $zones->updateHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 'http', 'dv');
|
||||
|
||||
$this->assertObjectHasAttribute('id', $result);
|
||||
$this->assertObjectHasAttribute('hostname', $result);
|
||||
}
|
||||
|
||||
public function testDeleteHostname()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteHostname.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('delete')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9')
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock);
|
||||
$result = $zones->deleteHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9');
|
||||
|
||||
$this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $result->id);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class DNSTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'type' => 'A',
|
||||
'name' => 'example.com',
|
||||
@@ -43,16 +44,16 @@ class DNSTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'type' => 'A',
|
||||
'name' => 'example.com',
|
||||
'content' => '127.0.0.1',
|
||||
'order' => 'type',
|
||||
'direction' => 'desc',
|
||||
])
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'type' => 'A',
|
||||
'name' => 'example.com',
|
||||
'content' => '127.0.0.1',
|
||||
'order' => 'type',
|
||||
'direction' => 'desc']),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||
@@ -75,7 +76,8 @@ class DNSTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||
@@ -103,6 +105,7 @@ class DNSTest extends TestCase
|
||||
->method('put')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo($details)
|
||||
);
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ class IPsTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('ips')
|
||||
$this->equalTo('ips'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$ips = new \Cloudflare\API\Endpoints\IPs($mock);
|
||||
|
||||
@@ -23,6 +23,7 @@ class PageRulesTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'targets' => $target->getArray(),
|
||||
'actions' => $action->getArray(),
|
||||
@@ -53,7 +54,8 @@ class PageRulesTest extends TestCase
|
||||
'order' => 'status',
|
||||
'direction' => 'desc',
|
||||
'match' => 'all'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||
@@ -70,7 +72,8 @@ class PageRulesTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||
@@ -92,6 +95,7 @@ class PageRulesTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'targets' => $target->getArray(),
|
||||
'actions' => $action->getArray(),
|
||||
@@ -116,7 +120,9 @@ class PageRulesTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/pagerules/9a7806061c88ada191ed06f989cc3dac'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||
|
||||
@@ -23,6 +23,7 @@ class RailgunTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('railguns'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo(['name' => $details['name']])
|
||||
);
|
||||
|
||||
@@ -51,7 +52,8 @@ class RailgunTest extends TestCase
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'direction' => 'desc'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||
@@ -71,7 +73,8 @@ class RailgunTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448')
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||
@@ -90,7 +93,9 @@ class RailgunTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448/zones')
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448/zones'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||
@@ -115,6 +120,7 @@ class RailgunTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo($details)
|
||||
);
|
||||
|
||||
@@ -134,7 +140,9 @@ class RailgunTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448')
|
||||
$this->equalTo('railguns/e928d310693a83094309acf9ead50448'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||
|
||||
@@ -22,7 +22,8 @@ class UARulesTest extends TestCase
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||
@@ -49,6 +50,7 @@ class UARulesTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'mode' => 'js_challenge',
|
||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||
@@ -77,7 +79,8 @@ class UARulesTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$lockdown = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||
@@ -100,6 +103,7 @@ class UARulesTest extends TestCase
|
||||
->method('put')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'mode' => 'js_challenge',
|
||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||
@@ -128,7 +132,9 @@ class UARulesTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||
|
||||
@@ -56,7 +56,7 @@ class UserTest extends TestCase
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('patch')
|
||||
->with($this->equalTo('user'), $this->equalTo(['email' => 'user2@example.com']));
|
||||
->with($this->equalTo('user'), $this->equalTo([]), $this->equalTo(['email' => 'user2@example.com']));
|
||||
|
||||
$user = new \Cloudflare\API\Endpoints\User($mock);
|
||||
$user->updateUserDetails(['email' => 'user2@example.com']);
|
||||
|
||||
@@ -25,7 +25,8 @@ class WAFTest extends TestCase
|
||||
'match' => 'all',
|
||||
'order' => 'status',
|
||||
'direction' => 'desc'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -48,7 +49,8 @@ class WAFTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -74,7 +76,8 @@ class WAFTest extends TestCase
|
||||
'match' => 'all',
|
||||
'order' => 'status',
|
||||
'direction' => 'desc'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -97,7 +100,8 @@ class WAFTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -121,6 +125,7 @@ class WAFTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo($details)
|
||||
);
|
||||
|
||||
@@ -151,7 +156,8 @@ class WAFTest extends TestCase
|
||||
'match' => 'all',
|
||||
'order' => 'status',
|
||||
'direction' => 'desc'
|
||||
])
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -174,7 +180,8 @@ class WAFTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||
@@ -198,6 +205,7 @@ class WAFTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo($details)
|
||||
);
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@ class ZoneLockdownTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
])
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||
@@ -49,6 +50,7 @@ class ZoneLockdownTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'urls' => ['api.mysite.com/some/endpoint*'],
|
||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||
@@ -77,7 +79,8 @@ class ZoneLockdownTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$lockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||
@@ -100,6 +103,7 @@ class ZoneLockdownTest extends TestCase
|
||||
->method('put')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'urls' => ['api.mysite.com/some/endpoint*'],
|
||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||
@@ -131,7 +135,9 @@ class ZoneLockdownTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59')
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||
|
||||
@@ -19,6 +19,7 @@ class ZonesTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo(['name' => 'example.com', 'jump_start' => false])
|
||||
);
|
||||
|
||||
@@ -37,10 +38,11 @@ class ZonesTest extends TestCase
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([
|
||||
'name' => 'example.com',
|
||||
'jump_start' => true,
|
||||
'organization' => ['id' => '01a7362d577a6c3019a474fd6f485823']
|
||||
'organization' => (object)['id' => '01a7362d577a6c3019a474fd6f485823']
|
||||
])
|
||||
);
|
||||
|
||||
@@ -58,7 +60,9 @@ class ZonesTest extends TestCase
|
||||
$mock->expects($this->once())
|
||||
->method('put')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/activation_check')
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/activation_check'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
@@ -78,15 +82,16 @@ class ZonesTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'name' => 'example.com',
|
||||
'status' => 'active',
|
||||
'order' => 'status',
|
||||
'direction' => 'desc',
|
||||
])
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'name' => 'example.com',
|
||||
'status' => 'active',
|
||||
'order' => 'status',
|
||||
'direction' => 'desc'
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
@@ -110,12 +115,13 @@ class ZonesTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'name' => 'example.com',
|
||||
])
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
'match' => 'all',
|
||||
'name' => 'example.com',
|
||||
]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
@@ -135,7 +141,8 @@ class ZonesTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/analytics/dashboard'),
|
||||
$this->equalTo(['since' => '-10080', 'until' => '0', 'continuous' => var_export(true, true)])
|
||||
$this->equalTo(['since' => '-10080', 'until' => '0', 'continuous' => var_export(true, true)]),
|
||||
$this->equalTo([])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
@@ -144,7 +151,7 @@ class ZonesTest extends TestCase
|
||||
$this->assertObjectHasAttribute('since', $analytics->totals);
|
||||
$this->assertObjectHasAttribute('since', $analytics->timeseries[0]);
|
||||
}
|
||||
|
||||
|
||||
public function testChangeDevelopmentMode()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/changeDevelopmentMode.json');
|
||||
@@ -156,6 +163,7 @@ class ZonesTest extends TestCase
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/development_mode'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo(['value' => 'on'])
|
||||
);
|
||||
|
||||
@@ -176,6 +184,7 @@ class ZonesTest extends TestCase
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo([]),
|
||||
$this->equalTo(['purge_everything' => true])
|
||||
);
|
||||
|
||||
@@ -184,30 +193,4 @@ class ZonesTest extends TestCase
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testCachePurgeHost()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('delete')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(
|
||||
[
|
||||
'files' => [],
|
||||
'tags' => [],
|
||||
'hosts' => ['dash.cloudflare.com']
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "023e105f4ecef8ad9ca31a8372d0c353"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{}
|
||||
],
|
||||
"messages": [
|
||||
{}
|
||||
],
|
||||
"result": {
|
||||
"id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9",
|
||||
"hostname": "app.example.com",
|
||||
"ssl": {
|
||||
"status": "pending_validation",
|
||||
"method": "http",
|
||||
"type": "dv",
|
||||
"cname_target": "dcv.digicert.com",
|
||||
"cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9"
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{}
|
||||
],
|
||||
"messages": [
|
||||
{}
|
||||
],
|
||||
"result": {
|
||||
"id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9",
|
||||
"hostname": "app.example.com",
|
||||
"ssl": {
|
||||
"status": "pending_validation",
|
||||
"method": "http",
|
||||
"type": "dv",
|
||||
"cname_target": "dcv.digicert.com",
|
||||
"cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{}
|
||||
],
|
||||
"messages": [
|
||||
{}
|
||||
],
|
||||
"result": [
|
||||
{
|
||||
"id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9",
|
||||
"hostname": "app.example.com",
|
||||
"ssl": {
|
||||
"status": "pending_validation",
|
||||
"method": "http",
|
||||
"type": "dv",
|
||||
"cname_target": "dcv.digicert.com",
|
||||
"cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com"
|
||||
}
|
||||
}
|
||||
],
|
||||
"result_info": {
|
||||
"page": 1,
|
||||
"per_page": 20,
|
||||
"count": 1,
|
||||
"total_count": 2000
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{}
|
||||
],
|
||||
"messages": [
|
||||
{}
|
||||
],
|
||||
"result": {
|
||||
"id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9",
|
||||
"hostname": "app.example.com",
|
||||
"ssl": {
|
||||
"status": "pending_validation",
|
||||
"method": "http",
|
||||
"type": "dv",
|
||||
"cname_target": "dcv.digicert.com",
|
||||
"cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user