Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d00a1d3f44 | ||
|
|
c8e85d2582 | ||
|
|
ff42f334a5 | ||
|
|
dfa299c895 | ||
|
|
e1864a6824 | ||
|
|
c9d21466aa | ||
|
|
b15b4ecc51 | ||
|
|
0aa9f6c05a | ||
|
|
a09478eb2f | ||
|
|
f6cb9a8e30 | ||
|
|
bc9e15a557 | ||
|
|
5caae74370 | ||
|
|
ee4a42ea06 | ||
|
|
90eaea7be2 | ||
|
|
dac1e15e2d | ||
|
|
a4224265d8 | ||
|
|
4f3f82b1ba | ||
|
|
7c9ea4874d | ||
|
|
0920fc48b2 |
@@ -21,55 +21,56 @@ interface Adapter
|
|||||||
* Adapter constructor.
|
* Adapter constructor.
|
||||||
*
|
*
|
||||||
* @param Auth $auth
|
* @param Auth $auth
|
||||||
* @param String $baseURI
|
* @param string $baseURI
|
||||||
*/
|
*/
|
||||||
public function __construct(Auth $auth, String $baseURI);
|
public function __construct(Auth $auth, string $baseURI);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a GET request.
|
* Sends a GET request.
|
||||||
* Per Robustness Principle - not including the ability to send a body with a GET request (though possible in the
|
* Per Robustness Principle - not including the ability to send a body with a GET request (though possible in the
|
||||||
* RFCs, it is never useful).
|
* RFCs, it is never useful).
|
||||||
*
|
*
|
||||||
* @param String $uri
|
* @param string $uri
|
||||||
|
* @param array $query
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get(String $uri, array $query, array $headers): ResponseInterface;
|
public function get(string $uri, array $query, array $headers): ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $uri
|
* @param string $uri
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @param array $body
|
* @param array $body
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function post(String $uri, array $headers, array $body): ResponseInterface;
|
public function post(string $uri, array $headers, array $body): ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $uri
|
* @param string $uri
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @param array $body
|
* @param array $body
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function put(String $uri, array $headers, array $body): ResponseInterface;
|
public function put(string $uri, array $headers, array $body): ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $uri
|
* @param string $uri
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @param array $body
|
* @param array $body
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function patch(String $uri, array $headers, array $body): ResponseInterface;
|
public function patch(string $uri, array $headers, array $body): ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $uri
|
* @param string $uri
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @param array $body
|
* @param array $body
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function delete(String $uri, array $headers, array $body): ResponseInterface;
|
public function delete(string $uri, array $headers, array $body): ResponseInterface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function __construct(Auth $auth, String $baseURI = null)
|
public function __construct(Auth $auth, string $baseURI = null)
|
||||||
{
|
{
|
||||||
if ($baseURI === null) {
|
if ($baseURI === null) {
|
||||||
$baseURI = "https://api.cloudflare.com/client/v4/";
|
$baseURI = 'https://api.cloudflare.com/client/v4/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = $auth->getHeaders();
|
$headers = $auth->getHeaders();
|
||||||
@@ -37,7 +37,7 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function get(String $uri, array $query = [], array $headers = []): ResponseInterface
|
public function get(string $uri, array $query = [], array $headers = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$response = $this->client->get($uri, ['query' => $query, 'headers' => $headers]);
|
$response = $this->client->get($uri, ['query' => $query, 'headers' => $headers]);
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function post(String $uri, array $headers = [], array $body = []): ResponseInterface
|
public function post(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$response = $this->client->post(
|
$response = $this->client->post(
|
||||||
$uri,
|
$uri,
|
||||||
@@ -65,7 +65,7 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function put(String $uri, array $headers = [], array $body = []): ResponseInterface
|
public function put(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$response = $this->client->put(
|
$response = $this->client->put(
|
||||||
$uri,
|
$uri,
|
||||||
@@ -82,7 +82,7 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface
|
public function patch(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$response = $this->client->patch(
|
$response = $this->client->patch(
|
||||||
$uri,
|
$uri,
|
||||||
@@ -99,7 +99,7 @@ class Guzzle implements Adapter
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function delete(String $uri, array $headers = [], array $body = []): ResponseInterface
|
public function delete(string $uri, array $headers = [], array $body = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$response = $this->client->delete(
|
$response = $this->client->delete(
|
||||||
$uri,
|
$uri,
|
||||||
@@ -122,13 +122,11 @@ class Guzzle implements Adapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($json->errors)) {
|
if (isset($json->errors)) {
|
||||||
foreach ($json->errors as $error) {
|
throw new ResponseException($json->errors[0]->message, $json->errors[0]->code);
|
||||||
throw new ResponseException($error->message, $error->code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($json->success) && ($json->success === false)) {
|
if (isset($json->success) && ($json->success === false)) {
|
||||||
throw new ResponseException("Request was unsuccessful.");
|
throw new ResponseException('Request was unsuccessful.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class APIKey implements Auth
|
|||||||
private $email;
|
private $email;
|
||||||
private $apiKey;
|
private $apiKey;
|
||||||
|
|
||||||
public function __construct(String $email, String $apiKey)
|
public function __construct(string $email, string $apiKey)
|
||||||
{
|
{
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
$this->apiKey = $apiKey;
|
$this->apiKey = $apiKey;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class UserServiceKey implements Auth
|
|||||||
{
|
{
|
||||||
private $userServiceKey;
|
private $userServiceKey;
|
||||||
|
|
||||||
public function __construct(String $userServiceKey)
|
public function __construct(string $userServiceKey)
|
||||||
{
|
{
|
||||||
$this->userServiceKey = $userServiceKey;
|
$this->userServiceKey = $userServiceKey;
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/Configurations/AccessRules.php
Normal file
28
src/Configurations/AccessRules.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Configurations;
|
||||||
|
|
||||||
|
class AccessRules implements Configurations
|
||||||
|
{
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
public function setIP(string $value)
|
||||||
|
{
|
||||||
|
$this->config = ['target' => 'ip', 'value' => $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIPRange(string $value)
|
||||||
|
{
|
||||||
|
$this->config = ['target' => 'ip_range', 'value' => $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCountry(string $value)
|
||||||
|
{
|
||||||
|
$this->config = ['target' => 'country', 'value' => $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArray(): array
|
||||||
|
{
|
||||||
|
return $this->config;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,28 +14,28 @@ class PageRulesActions implements Configurations
|
|||||||
|
|
||||||
public function setAlwaysOnline(bool $active)
|
public function setAlwaysOnline(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("always_online", [
|
$this->addConfigurationOption('always_online', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAlwaysUseHTTPS(bool $active)
|
public function setAlwaysUseHTTPS(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("always_use_https", [
|
$this->addConfigurationOption('always_use_https', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBrowserCacheTTL(int $ttl)
|
public function setBrowserCacheTTL(int $ttl)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("browser_cache_ttl", [
|
$this->addConfigurationOption('browser_cache_ttl', [
|
||||||
'value' => $ttl
|
'value' => $ttl
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBrowserIntegrityCheck(bool $active)
|
public function setBrowserIntegrityCheck(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("browser_check", [
|
$this->addConfigurationOption('browser_check', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -43,35 +43,35 @@ class PageRulesActions implements Configurations
|
|||||||
public function setBypassCacheOnCookie(string $value)
|
public function setBypassCacheOnCookie(string $value)
|
||||||
{
|
{
|
||||||
if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) {
|
if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) {
|
||||||
throw new ConfigurationsException("Invalid cookie string.");
|
throw new ConfigurationsException('Invalid cookie string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("bypass_cache_on_cookie", [
|
$this->addConfigurationOption('bypass_cache_on_cookie', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCacheByDeviceType(bool $active)
|
public function setCacheByDeviceType(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("cache_by_device_type", [
|
$this->addConfigurationOption('cache_by_device_type', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCacheKey(string $value)
|
public function setCacheKey(string $value)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("cache_key", [
|
$this->addConfigurationOption('cache_key', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCacheLevel(string $value)
|
public function setCacheLevel(string $value)
|
||||||
{
|
{
|
||||||
if (!in_array($value, ["bypass", "basic", "simplified", "aggressive", "cache_everything"])) {
|
if (!in_array($value, ['bypass', 'basic', 'simplified', 'aggressive', 'cache_everything'])) {
|
||||||
throw new ConfigurationsException("Invalid cache level");
|
throw new ConfigurationsException('Invalid cache level');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("cache_level", [
|
$this->addConfigurationOption('cache_level', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -79,31 +79,31 @@ class PageRulesActions implements Configurations
|
|||||||
public function setCacheOnCookie(string $value)
|
public function setCacheOnCookie(string $value)
|
||||||
{
|
{
|
||||||
if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) {
|
if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) {
|
||||||
throw new ConfigurationsException("Invalid cookie string.");
|
throw new ConfigurationsException('Invalid cookie string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("cache_on_cookie", [
|
$this->addConfigurationOption('cache_on_cookie', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDisableApps(bool $active)
|
public function setDisableApps(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("disable_apps", [
|
$this->addConfigurationOption('disable_apps', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDisablePerformance(bool $active)
|
public function setDisablePerformance(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("disable_performance", [
|
$this->addConfigurationOption('disable_performance', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDisableSecurity(bool $active)
|
public function setDisableSecurity(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("disable_security", [
|
$this->addConfigurationOption('disable_security', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -111,17 +111,17 @@ class PageRulesActions implements Configurations
|
|||||||
public function setEdgeCacheTTL(int $value)
|
public function setEdgeCacheTTL(int $value)
|
||||||
{
|
{
|
||||||
if ($value > 2419200) {
|
if ($value > 2419200) {
|
||||||
throw new ConfigurationsException("Edge Cache TTL too high.");
|
throw new ConfigurationsException('Edge Cache TTL too high.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("edge_cache_ttl", [
|
$this->addConfigurationOption('edge_cache_ttl', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmailObfuscation(bool $active)
|
public function setEmailObfuscation(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("disable_security", [
|
$this->addConfigurationOption('disable_security', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ class PageRulesActions implements Configurations
|
|||||||
throw new ConfigurationsException('Status Codes can only be 301 or 302.');
|
throw new ConfigurationsException('Status Codes can only be 301 or 302.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("forwarding_url", [
|
$this->addConfigurationOption('forwarding_url', [
|
||||||
'status_code' => $statusCode,
|
'status_code' => $statusCode,
|
||||||
'url' => $forwardingUrl,
|
'url' => $forwardingUrl,
|
||||||
]);
|
]);
|
||||||
@@ -140,28 +140,28 @@ class PageRulesActions implements Configurations
|
|||||||
|
|
||||||
public function setHostHeaderOverride(bool $active)
|
public function setHostHeaderOverride(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("host_header_override", [
|
$this->addConfigurationOption('host_header_override', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHotlinkProtection(bool $active)
|
public function setHotlinkProtection(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("hotlink_protection", [
|
$this->addConfigurationOption('hotlink_protection', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIPGeoLocationHeader(bool $active)
|
public function setIPGeoLocationHeader(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("ip_geolocation", [
|
$this->addConfigurationOption('ip_geolocation', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMinification(bool $html, bool $css, bool $javascript)
|
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($javascript),
|
'js' => $this->getBoolAsOnOrOff($javascript),
|
||||||
@@ -170,124 +170,124 @@ class PageRulesActions implements Configurations
|
|||||||
|
|
||||||
public function setMirage(bool $active)
|
public function setMirage(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("mirage", [
|
$this->addConfigurationOption('mirage', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOriginErrorPagePassthru(bool $active)
|
public function setOriginErrorPagePassthru(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("origin_error_page_pass_thru", [
|
$this->addConfigurationOption('origin_error_page_pass_thru', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setQueryStringSort(bool $active)
|
public function setQueryStringSort(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("sort_query_string_for_cache", [
|
$this->addConfigurationOption('sort_query_string_for_cache', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDisableRailgun(bool $active)
|
public function setDisableRailgun(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("disable_railgun", [
|
$this->addConfigurationOption('disable_railgun', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResolveOverride(bool $value)
|
public function setResolveOverride(bool $value)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("resolve_override", [
|
$this->addConfigurationOption('resolve_override', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRespectStrongEtag(bool $active)
|
public function setRespectStrongEtag(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("respect_strong_etag", [
|
$this->addConfigurationOption('respect_strong_etag', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResponseBuffering(bool $active)
|
public function setResponseBuffering(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("response_buffering", [
|
$this->addConfigurationOption('response_buffering', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRocketLoader(string $value)
|
public function setRocketLoader(string $value)
|
||||||
{
|
{
|
||||||
if (!in_array($value, ["off", "manual", "automatic"])) {
|
if (!in_array($value, ['off', 'manual', 'automatic'])) {
|
||||||
throw new ConfigurationsException('Rocket Loader can only be off, automatic, or manual.');
|
throw new ConfigurationsException('Rocket Loader can only be off, automatic, or manual.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("rocket_loader", [
|
$this->addConfigurationOption('rocket_loader', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSecurityLevel(string $value)
|
public function setSecurityLevel(string $value)
|
||||||
{
|
{
|
||||||
if (!in_array($value, ["off", "essentially_off", "low", "medium", "high", "under_attack"])) {
|
if (!in_array($value, ['off', 'essentially_off', 'low', 'medium', 'high', 'under_attack'])) {
|
||||||
throw new ConfigurationsException('Can only be set to off, essentially_off, low, medium, high or under_attack.');
|
throw new ConfigurationsException('Can only be set to off, essentially_off, low, medium, high or under_attack.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("security_level", [
|
$this->addConfigurationOption('security_level', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setServerSideExcludes(bool $active)
|
public function setServerSideExcludes(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("server_side_exclude", [
|
$this->addConfigurationOption('server_side_exclude', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSmartErrors(bool $active)
|
public function setSmartErrors(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("smart_errors", [
|
$this->addConfigurationOption('smart_errors', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSSL(string $value)
|
public function setSSL(string $value)
|
||||||
{
|
{
|
||||||
if (!in_array($value, ["off", "flexible", "full", "strict", "origin_pull"])) {
|
if (!in_array($value, ['off', 'flexible', 'full', 'strict', 'origin_pull'])) {
|
||||||
throw new ConfigurationsException('Can only be set to off, flexible, full, strict, origin_pull.');
|
throw new ConfigurationsException('Can only be set to off, flexible, full, strict, origin_pull.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addConfigurationOption("smart_errors", [
|
$this->addConfigurationOption('smart_errors', [
|
||||||
'value' => $value
|
'value' => $value
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTrueClientIpHeader(bool $active)
|
public function setTrueClientIpHeader(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("true_client_ip_header", [
|
$this->addConfigurationOption('true_client_ip_header', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWAF(bool $active)
|
public function setWAF(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("waf", [
|
$this->addConfigurationOption('waf', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAutomatedHTTPSRewrites(bool $active)
|
public function setAutomatedHTTPSRewrites(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("automatic_https_rewrites", [
|
$this->addConfigurationOption('automatic_https_rewrites', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOpportunisticEncryption(bool $active)
|
public function setOpportunisticEncryption(bool $active)
|
||||||
{
|
{
|
||||||
$this->addConfigurationOption("opportunistic_encryption", [
|
$this->addConfigurationOption('opportunistic_encryption', [
|
||||||
'value' => $this->getBoolAsOnOrOff($active)
|
'value' => $this->getBoolAsOnOrOff($active)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ class PageRulesActions implements Configurations
|
|||||||
{
|
{
|
||||||
$configuration['id'] = $setting;
|
$configuration['id'] = $setting;
|
||||||
|
|
||||||
array_push($this->configs, (object) $configuration);
|
$this->configs[] = (object) $configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBoolAsOnOrOff(bool $value): string
|
private function getBoolAsOnOrOff(bool $value): string
|
||||||
|
|||||||
@@ -14,13 +14,15 @@ class PageRulesTargets implements Configurations
|
|||||||
|
|
||||||
public function __construct(string $queryUrl)
|
public function __construct(string $queryUrl)
|
||||||
{
|
{
|
||||||
$target = new \stdClass();
|
$this->targets = [
|
||||||
$target->target = 'url';
|
(object)[
|
||||||
$target->constraint = new \stdClass();
|
'target' => 'url',
|
||||||
$target->constraint->operator = "matches";
|
'constraint' => (object)[
|
||||||
$target->constraint->value = $queryUrl;
|
'operator' => 'matches',
|
||||||
|
'value' => $queryUrl
|
||||||
$this->targets = [$target];
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArray(): array
|
public function getArray(): array
|
||||||
|
|||||||
@@ -14,11 +14,7 @@ class UARules implements Configurations
|
|||||||
|
|
||||||
public function addUA(string $value)
|
public function addUA(string $value)
|
||||||
{
|
{
|
||||||
$object = new \stdClass();
|
$this->configs[] = (object)['target' => 'ua', 'value' => $value];
|
||||||
$object->target = "ua";
|
|
||||||
$object->value = $value;
|
|
||||||
|
|
||||||
array_push($this->configs, $object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArray(): array
|
public function getArray(): array
|
||||||
|
|||||||
@@ -14,20 +14,12 @@ class ZoneLockdown implements Configurations
|
|||||||
|
|
||||||
public function addIP(string $value)
|
public function addIP(string $value)
|
||||||
{
|
{
|
||||||
$object = new \stdClass();
|
$this->configs[] = (object)['target' => 'ip', 'value' => $value];
|
||||||
$object->target = "ip";
|
|
||||||
$object->value = $value;
|
|
||||||
|
|
||||||
array_push($this->configs, $object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addIPRange(string $value)
|
public function addIPRange(string $value)
|
||||||
{
|
{
|
||||||
$object = new \stdClass();
|
$this->configs[] = (object)['target' => 'ip_range', 'value' => $value];
|
||||||
$object->target = "ip_range";
|
|
||||||
$object->value = $value;
|
|
||||||
|
|
||||||
array_push($this->configs, $object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArray(): array
|
public function getArray(): array
|
||||||
|
|||||||
153
src/Endpoints/AccessRules.php
Normal file
153
src/Endpoints/AccessRules.php
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
use Cloudflare\API\Configurations\Configurations;
|
||||||
|
|
||||||
|
class AccessRules implements API
|
||||||
|
{
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
||||||
|
*
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $scopeType
|
||||||
|
* @param string $mode
|
||||||
|
* @param string $configurationTarget
|
||||||
|
* @param string $configurationValue
|
||||||
|
* @param int $page
|
||||||
|
* @param int $perPage
|
||||||
|
* @param string $order
|
||||||
|
* @param string $direction
|
||||||
|
* @param string $match
|
||||||
|
* @param string $notes
|
||||||
|
* @return \stdClass
|
||||||
|
*/
|
||||||
|
public function listRules(
|
||||||
|
string $zoneID,
|
||||||
|
string $scopeType = '',
|
||||||
|
string $mode = '',
|
||||||
|
string $configurationTarget = '',
|
||||||
|
string $configurationValue = '',
|
||||||
|
int $page = 1,
|
||||||
|
int $perPage = 50,
|
||||||
|
string $order = '',
|
||||||
|
string $direction = '',
|
||||||
|
string $match = 'all',
|
||||||
|
string $notes = ''
|
||||||
|
): \stdClass {
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
'match' => $match
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($scopeType)) {
|
||||||
|
$query['scope_type'] = $scopeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($mode)) {
|
||||||
|
$query['mode'] = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($configurationTarget)) {
|
||||||
|
$query['configuration_target'] = $configurationTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($configurationValue)) {
|
||||||
|
$query['configuration_value'] = $configurationValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($order)) {
|
||||||
|
$query['order'] = $order;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($direction)) {
|
||||||
|
$query['direction'] = $direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($notes)) {
|
||||||
|
$query['notes'] = $notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$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];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createRule(
|
||||||
|
string $zoneID,
|
||||||
|
string $mode,
|
||||||
|
Configurations $configuration,
|
||||||
|
string $notes = null
|
||||||
|
): bool {
|
||||||
|
$options = [
|
||||||
|
'mode' => $mode,
|
||||||
|
'configuration' => (object) $configuration->getArray()
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($notes !== null) {
|
||||||
|
$options['notes'] = $notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->adapter->post('zones/' . $zoneID . '/firewall/access_rules/rules', [], $options);
|
||||||
|
|
||||||
|
$body = json_decode($query->getBody());
|
||||||
|
|
||||||
|
if (isset($body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateRule(
|
||||||
|
string $zoneID,
|
||||||
|
string $ruleID,
|
||||||
|
string $mode,
|
||||||
|
string $notes = null
|
||||||
|
): bool {
|
||||||
|
$options = [
|
||||||
|
'mode' => $mode
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($notes !== null) {
|
||||||
|
$options['notes'] = $notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->adapter->patch('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, [], $options);
|
||||||
|
|
||||||
|
$body = json_decode($query->getBody());
|
||||||
|
|
||||||
|
if (isset($body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteRule(string $zoneID, string $ruleID, string $cascade = 'none'): bool
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
'cascade' => $cascade
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->adapter->delete('zones/' . $zoneID . '/firewall/access_rules/rules/' . $ruleID, [], $options);
|
||||||
|
|
||||||
|
$body = json_decode($data->getBody());
|
||||||
|
|
||||||
|
if (isset($body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -62,14 +62,14 @@ class DNS implements API
|
|||||||
|
|
||||||
public function listRecords(
|
public function listRecords(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $type = "",
|
string $type = '',
|
||||||
string $name = "",
|
string $name = '',
|
||||||
string $content = "",
|
string $content = '',
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $order = "",
|
string $order = '',
|
||||||
string $direction = "",
|
string $direction = '',
|
||||||
string $match = "all"
|
string $match = 'all'
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -100,11 +100,7 @@ class DNS implements API
|
|||||||
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records', $query, []);
|
$user = $this->adapter->get('zones/' . $zoneID . '/dns_records', $query, []);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRecordDetails(string $zoneID, string $recordID): \stdClass
|
public function getRecordDetails(string $zoneID, string $recordID): \stdClass
|
||||||
|
|||||||
@@ -70,19 +70,19 @@ class PageRules implements API
|
|||||||
string $direction = null,
|
string $direction = null,
|
||||||
string $match = null
|
string $match = null
|
||||||
): array {
|
): array {
|
||||||
if (is_null($status) && !in_array($status, ['active', 'disabled'])) {
|
if ($status === null && !in_array($status, ['active', 'disabled'])) {
|
||||||
throw new EndpointException('Page Rules can only be listed by status of active or disabled.');
|
throw new EndpointException('Page Rules can only be listed by status of active or disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($order) && !in_array($order, ['status', 'priority'])) {
|
if ($order === null && !in_array($order, ['status', 'priority'])) {
|
||||||
throw new EndpointException('Page Rules can only be ordered by status or priority.');
|
throw new EndpointException('Page Rules can only be ordered by status or priority.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($direction) && !in_array($direction, ['asc', 'desc'])) {
|
if ($direction === null && !in_array($direction, ['asc', 'desc'])) {
|
||||||
throw new EndpointException('Direction of Page Rule ordering can only be asc or desc.');
|
throw new EndpointException('Direction of Page Rule ordering can only be asc or desc.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($match) && !in_array($match, ['all', 'any'])) {
|
if ($match === null && !in_array($match, ['all', 'any'])) {
|
||||||
throw new EndpointException('Match can only be any or all.');
|
throw new EndpointException('Match can only be any or all.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ class PageRules implements API
|
|||||||
): bool {
|
): bool {
|
||||||
$options = [];
|
$options = [];
|
||||||
|
|
||||||
if ($active !== null) {
|
if ($target !== null) {
|
||||||
$options['targets'] = $target->getArray();
|
$options['targets'] = $target->getArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Railgun implements API
|
|||||||
public function list(
|
public function list(
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $direction = ""
|
string $direction = ''
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -49,11 +49,7 @@ class Railgun implements API
|
|||||||
$user = $this->adapter->get('railguns', $query, []);
|
$user = $this->adapter->get('railguns', $query, []);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get(
|
public function get(
|
||||||
@@ -71,11 +67,7 @@ class Railgun implements API
|
|||||||
$user = $this->adapter->get('railguns/' . $railgunID . '/zones', [], []);
|
$user = $this->adapter->get('railguns/' . $railgunID . '/zones', [], []);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(
|
public function update(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
namespace Cloudflare\API\Endpoints;
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Configurations\Configurations;
|
||||||
use Cloudflare\API\Adapter\Adapter;
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
|
||||||
class UARules implements API
|
class UARules implements API
|
||||||
@@ -32,17 +33,13 @@ class UARules implements API
|
|||||||
$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());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createRule(
|
public function createRule(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $mode,
|
string $mode,
|
||||||
\Cloudflare\API\Configurations\Configurations $configuration,
|
Configurations $configuration,
|
||||||
string $ruleID = null,
|
string $ruleID = null,
|
||||||
string $description = null
|
string $description = null
|
||||||
): bool {
|
): bool {
|
||||||
@@ -72,7 +69,7 @@ class UARules implements API
|
|||||||
|
|
||||||
public function getRuleDetails(string $zoneID, string $blockID): \stdClass
|
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());
|
$body = json_decode($user->getBody());
|
||||||
return $body->result;
|
return $body->result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,17 +27,17 @@ class User implements API
|
|||||||
|
|
||||||
public function getUserID(): string
|
public function getUserID(): string
|
||||||
{
|
{
|
||||||
return ($this->getUserDetails())->id;
|
return $this->getUserDetails()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserEmail(): string
|
public function getUserEmail(): string
|
||||||
{
|
{
|
||||||
return ($this->getUserDetails())->email;
|
return $this->getUserDetails()->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateUserDetails(array $details): \stdClass
|
public function updateUserDetails(array $details): \stdClass
|
||||||
{
|
{
|
||||||
$response = $this->adapter->patch("user", [], $details);
|
$response = $this->adapter->patch('user', [], $details);
|
||||||
return json_decode($response->getBody());
|
return json_decode($response->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Cloudflare\API\Endpoints;
|
|||||||
|
|
||||||
use Cloudflare\API\Adapter\Adapter;
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
|
||||||
class WAF implements \Cloudflare\API\Endpoints\API
|
class WAF implements API
|
||||||
{
|
{
|
||||||
private $adapter;
|
private $adapter;
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
string $zoneID,
|
string $zoneID,
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $order = "",
|
string $order = '',
|
||||||
string $direction = "",
|
string $direction = '',
|
||||||
string $match = "all"
|
string $match = 'all'
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -44,11 +44,7 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
$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());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,9 +63,9 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
string $packageID,
|
string $packageID,
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $order = "",
|
string $order = '',
|
||||||
string $direction = "",
|
string $direction = '',
|
||||||
string $match = "all"
|
string $match = 'all'
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -87,11 +83,7 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
$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());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRuleInfo(
|
public function getRuleInfo(
|
||||||
@@ -134,9 +126,9 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
string $packageID,
|
string $packageID,
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $order = "",
|
string $order = '',
|
||||||
string $direction = "",
|
string $direction = '',
|
||||||
string $match = "all"
|
string $match = 'all'
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -159,11 +151,7 @@ class WAF implements \Cloudflare\API\Endpoints\API
|
|||||||
);
|
);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroupInfo(
|
public function getGroupInfo(
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ class ZoneLockdown implements API
|
|||||||
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns', $query, []);
|
$user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns', $query, []);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createLockdown(
|
public function createLockdown(
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ class Zones implements API
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($organizationID)) {
|
if (!empty($organizationID)) {
|
||||||
$organization = new \stdClass();
|
$options['organization'] = (object)['id' => $organizationID];
|
||||||
$organization->id = $organizationID;
|
|
||||||
$options["organization"] = $organization;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->adapter->post('zones', [], $options);
|
$user = $this->adapter->post('zones', [], $options);
|
||||||
@@ -58,13 +56,13 @@ class Zones implements API
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function listZones(
|
public function listZones(
|
||||||
string $name = "",
|
string $name = '',
|
||||||
string $status = "",
|
string $status = '',
|
||||||
int $page = 1,
|
int $page = 1,
|
||||||
int $perPage = 20,
|
int $perPage = 20,
|
||||||
string $order = "",
|
string $order = '',
|
||||||
string $direction = "",
|
string $direction = '',
|
||||||
string $match = "all"
|
string $match = 'all'
|
||||||
): \stdClass {
|
): \stdClass {
|
||||||
$query = [
|
$query = [
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -91,19 +89,15 @@ class Zones implements API
|
|||||||
$user = $this->adapter->get('zones', $query, []);
|
$user = $this->adapter->get('zones', $query, []);
|
||||||
$body = json_decode($user->getBody());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
$result = new \stdClass();
|
return (object)['result' => $body->result, 'result_info' => $body->result_info];
|
||||||
$result->result = $body->result;
|
|
||||||
$result->result_info = $body->result_info;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getZoneID(string $name = ""): string
|
public function getZoneID(string $name = ''): string
|
||||||
{
|
{
|
||||||
$zones = $this->listZones($name);
|
$zones = $this->listZones($name);
|
||||||
|
|
||||||
if (sizeof($zones->result) < 1) {
|
if (count($zones->result) < 1) {
|
||||||
throw new EndpointException("Could not find zones with specified name.");
|
throw new EndpointException('Could not find zones with specified name.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $zones->result[0]->id;
|
return $zones->result[0]->id;
|
||||||
@@ -118,9 +112,9 @@ class Zones implements API
|
|||||||
* @param bool $continuous
|
* @param bool $continuous
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public function getAnalyticsDashboard(string $zoneID, string $since = "-10080", string $until = "0", bool $continuous = true): \stdClass
|
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" => $continuous]);
|
$response = $this->adapter->get('zones/' . $zoneID . '/analytics/dashboard', [], ['since' => $since, 'until' => $until, 'continuous' => $continuous]);
|
||||||
|
|
||||||
return json_decode($response->getBody())->result;
|
return json_decode($response->getBody())->result;
|
||||||
}
|
}
|
||||||
@@ -134,7 +128,7 @@ class Zones implements API
|
|||||||
*/
|
*/
|
||||||
public function changeDevelopmentMode(string $zoneID, bool $enable = false): bool
|
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());
|
$body = json_decode($response->getBody());
|
||||||
|
|
||||||
@@ -153,7 +147,7 @@ class Zones implements API
|
|||||||
*/
|
*/
|
||||||
public function cachePurgeEverything(string $zoneID): bool
|
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());
|
$body = json_decode($user->getBody());
|
||||||
|
|
||||||
@@ -166,8 +160,8 @@ class Zones implements API
|
|||||||
|
|
||||||
public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool
|
public function cachePurge(string $zoneID, array $files = null, array $tags = null): bool
|
||||||
{
|
{
|
||||||
if (is_null($files) && is_null($tags)) {
|
if ($files === null && $tags === null) {
|
||||||
throw new EndpointException("No files or tags to purge.");
|
throw new EndpointException('No files or tags to purge.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ class GuzzleTest extends TestCase
|
|||||||
$response = $this->client->get('https://httpbin.org/get');
|
$response = $this->client->get('https://httpbin.org/get');
|
||||||
|
|
||||||
$headers = $response->getHeaders();
|
$headers = $response->getHeaders();
|
||||||
$this->assertEquals("application/json", $headers["Content-Type"][0]);
|
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||||
|
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Test", $body->headers->{"X-Testing"});
|
$this->assertEquals('Test', $body->headers->{'X-Testing'});
|
||||||
|
|
||||||
$response = $this->client->get('https://httpbin.org/get', [], ['X-Another-Test' => 'Test2']);
|
$response = $this->client->get('https://httpbin.org/get', [], ['X-Another-Test' => 'Test2']);
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Test2", $body->headers->{"X-Another-Test"});
|
$this->assertEquals('Test2', $body->headers->{'X-Another-Test'});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPost()
|
public function testPost()
|
||||||
@@ -44,10 +44,10 @@ class GuzzleTest extends TestCase
|
|||||||
$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();
|
$headers = $response->getHeaders();
|
||||||
$this->assertEquals("application/json", $headers["Content-Type"][0]);
|
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||||
|
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Testing a POST request.", $body->json->{"X-Post-Test"});
|
$this->assertEquals('Testing a POST request.', $body->json->{'X-Post-Test'});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPut()
|
public function testPut()
|
||||||
@@ -55,10 +55,10 @@ class GuzzleTest extends TestCase
|
|||||||
$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();
|
$headers = $response->getHeaders();
|
||||||
$this->assertEquals("application/json", $headers["Content-Type"][0]);
|
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||||
|
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"});
|
$this->assertEquals('Testing a PUT request.', $body->json->{'X-Put-Test'});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPatch()
|
public function testPatch()
|
||||||
@@ -70,10 +70,10 @@ class GuzzleTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$headers = $response->getHeaders();
|
$headers = $response->getHeaders();
|
||||||
$this->assertEquals("application/json", $headers["Content-Type"][0]);
|
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||||
|
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"});
|
$this->assertEquals('Testing a PATCH request.', $body->json->{'X-Patch-Test'});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDelete()
|
public function testDelete()
|
||||||
@@ -85,10 +85,10 @@ class GuzzleTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$headers = $response->getHeaders();
|
$headers = $response->getHeaders();
|
||||||
$this->assertEquals("application/json", $headers["Content-Type"][0]);
|
$this->assertEquals('application/json', $headers['Content-Type'][0]);
|
||||||
|
|
||||||
$body = json_decode($response->getBody());
|
$body = json_decode($response->getBody());
|
||||||
$this->assertEquals("Testing a DELETE request.", $body->json->{"X-Delete-Test"});
|
$this->assertEquals('Testing a DELETE request.', $body->json->{'X-Delete-Test'});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testErrors()
|
public function testErrors()
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ class APIKeyTest extends TestCase
|
|||||||
$this->assertEquals('example@example.com', $headers['X-Auth-Email']);
|
$this->assertEquals('example@example.com', $headers['X-Auth-Email']);
|
||||||
$this->assertEquals('1234567893feefc5f0q5000bfo0c38d90bbeb', $headers['X-Auth-Key']);
|
$this->assertEquals('1234567893feefc5f0q5000bfo0c38d90bbeb', $headers['X-Auth-Key']);
|
||||||
|
|
||||||
$this->assertEquals(2, sizeof($headers));
|
$this->assertCount(2, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 20:08
|
* Time: 20:08
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Auth\None;
|
|
||||||
|
|
||||||
class NoneTest extends TestCase
|
class NoneTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class UserServiceKeyTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testGetHeaders()
|
public function testGetHeaders()
|
||||||
{
|
{
|
||||||
$auth = new \Cloudflare\API\Auth\UserServiceKey("v1.0-e24fd090c02efcfecb4de8f4ff246fd5c75b48946fdf0ce26c59f91d0d90797b-cfa33fe60e8e34073c149323454383fc9005d25c9b4c502c2f063457ef65322eade065975001a0b4b4c591c5e1bd36a6e8f7e2d4fa8a9ec01c64c041e99530c2-07b9efe0acd78c82c8d9c690aacb8656d81c369246d7f996a205fe3c18e9254a");
|
$auth = new \Cloudflare\API\Auth\UserServiceKey('v1.0-e24fd090c02efcfecb4de8f4ff246fd5c75b48946fdf0ce26c59f91d0d90797b-cfa33fe60e8e34073c149323454383fc9005d25c9b4c502c2f063457ef65322eade065975001a0b4b4c591c5e1bd36a6e8f7e2d4fa8a9ec01c64c041e99530c2-07b9efe0acd78c82c8d9c690aacb8656d81c369246d7f996a205fe3c18e9254a');
|
||||||
$headers = $auth->getHeaders();
|
$headers = $auth->getHeaders();
|
||||||
|
|
||||||
$this->assertArrayHasKey('X-Auth-User-Service-Key', $headers);
|
$this->assertArrayHasKey('X-Auth-User-Service-Key', $headers);
|
||||||
@@ -19,6 +19,6 @@ class UserServiceKeyTest extends TestCase
|
|||||||
$headers['X-Auth-User-Service-Key']
|
$headers['X-Auth-User-Service-Key']
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(1, sizeof($headers));
|
$this->assertCount(1, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ConfigurationsUARulesTest extends TestCase
|
|||||||
$configuration->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
$configuration->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4');
|
||||||
|
|
||||||
$array = $configuration->getArray();
|
$array = $configuration->getArray();
|
||||||
$this->assertEquals(1, sizeof($array));
|
$this->assertCount(1, $array);
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('target', $array[0]);
|
$this->assertObjectHasAttribute('target', $array[0]);
|
||||||
$this->assertEquals('ua', $array[0]->target);
|
$this->assertEquals('ua', $array[0]->target);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Date: 05/09/2017
|
* Date: 05/09/2017
|
||||||
* Time: 13:50
|
* Time: 13:50
|
||||||
*/
|
*/
|
||||||
class ConfigurationZoneLockdownTest extends TestCase
|
class ConfigurationsZoneLockdownTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testGetArray()
|
public function testGetArray()
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ class ConfigurationZoneLockdownTest extends TestCase
|
|||||||
$configuration->addIP('1.2.3.4');
|
$configuration->addIP('1.2.3.4');
|
||||||
|
|
||||||
$array = $configuration->getArray();
|
$array = $configuration->getArray();
|
||||||
$this->assertEquals(1, sizeof($array));
|
$this->assertCount(1, $array);
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('target', $array[0]);
|
$this->assertObjectHasAttribute('target', $array[0]);
|
||||||
$this->assertEquals('ip', $array[0]->target);
|
$this->assertEquals('ip', $array[0]->target);
|
||||||
@@ -24,7 +24,7 @@ class ConfigurationZoneLockdownTest extends TestCase
|
|||||||
$configuration->addIPRange('1.2.3.4/24');
|
$configuration->addIPRange('1.2.3.4/24');
|
||||||
|
|
||||||
$array = $configuration->getArray();
|
$array = $configuration->getArray();
|
||||||
$this->assertEquals(2, sizeof($array));
|
$this->assertCount(2, $array);
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('target', $array[1]);
|
$this->assertObjectHasAttribute('target', $array[1]);
|
||||||
$this->assertEquals('ip_range', $array[1]->target);
|
$this->assertEquals('ip_range', $array[1]->target);
|
||||||
@@ -15,8 +15,8 @@ class PageRulesTargetTest extends TestCase
|
|||||||
$targets = new PageRulesTargets('junade.com/*');
|
$targets = new PageRulesTargets('junade.com/*');
|
||||||
$array = $targets->getArray();
|
$array = $targets->getArray();
|
||||||
|
|
||||||
$this->assertEquals(1, sizeof($array));
|
$this->assertCount(1, $array);
|
||||||
$this->assertEquals("junade.com/*", $array[0]->constraint->value);
|
$this->assertEquals('junade.com/*', $array[0]->constraint->value);
|
||||||
$this->assertEquals("matches", $array[0]->constraint->operator);
|
$this->assertEquals('matches', $array[0]->constraint->operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
112
tests/Endpoints/AccessRulesTest.php
Normal file
112
tests/Endpoints/AccessRulesTest.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class AccessRulesTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testListRules()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listAccessRules.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/access_rules/rules'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 50,
|
||||||
|
'match' => 'all'
|
||||||
|
]),
|
||||||
|
$this->equalTo([])
|
||||||
|
);
|
||||||
|
|
||||||
|
$zones = new \Cloudflare\API\Endpoints\AccessRules($mock);
|
||||||
|
$result = $zones->listRules('023e105f4ecef8ad9ca31a8372d0c353');
|
||||||
|
|
||||||
|
$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 testCreateRule()
|
||||||
|
{
|
||||||
|
$config = new \Cloudflare\API\Configurations\AccessRules();
|
||||||
|
$config->setIP('1.2.3.4');
|
||||||
|
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createAccessRule.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/firewall/access_rules/rules'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo([
|
||||||
|
'mode' => 'challenge',
|
||||||
|
'configuration' => (object) $config->getArray(),
|
||||||
|
'notes' => 'This rule is on because of an event that occured on date X',
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$rules = new \Cloudflare\API\Endpoints\AccessRules($mock);
|
||||||
|
$rules->createRule(
|
||||||
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
|
'challenge',
|
||||||
|
$config,
|
||||||
|
'This rule is on because of an event that occured on date X'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpdateRule()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateAccessRule.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/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',
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$rules = new \Cloudflare\API\Endpoints\AccessRules($mock);
|
||||||
|
$rules->updateRule(
|
||||||
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
|
'92f17202ed8bd63d69a66b86a49a8f6b',
|
||||||
|
'challenge',
|
||||||
|
'This rule is on because of an event that occured on date X'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeleteRule()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteAccessRule.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/firewall/access_rules/rules/92f17202ed8bd63d69a66b86a49a8f6b'),
|
||||||
|
$this->equalTo([]),
|
||||||
|
$this->equalTo([
|
||||||
|
'cascade' => 'none'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$rules = new \Cloudflare\API\Endpoints\AccessRules($mock);
|
||||||
|
$rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '92f17202ed8bd63d69a66b86a49a8f6b');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,12 +57,12 @@ class DNSTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\DNS($mock);
|
$zones = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||||
$result = $zones->listRecords("023e105f4ecef8ad9ca31a8372d0c353", "A", "example.com", "127.0.0.1", 1, 20, "type", "desc", "all");
|
$result = $zones->listRecords('023e105f4ecef8ad9ca31a8372d0c353', 'A', 'example.com', '127.0.0.1', 1, 20, 'type', 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->result[0]->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ class DNSTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||||
$result = $dns->getRecordDetails("023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59");
|
$result = $dns->getRecordDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateDNSRecord()
|
public function testUpdateDNSRecord()
|
||||||
@@ -95,8 +95,8 @@ class DNSTest extends TestCase
|
|||||||
|
|
||||||
$details = [
|
$details = [
|
||||||
'type' => 'A',
|
'type' => 'A',
|
||||||
'name' => "example.com",
|
'name' => 'example.com',
|
||||||
'content' => "1.2.3.4",
|
'content' => '1.2.3.4',
|
||||||
'ttl' => 120,
|
'ttl' => 120,
|
||||||
'proxied' => false,
|
'proxied' => false,
|
||||||
];
|
];
|
||||||
@@ -110,9 +110,9 @@ class DNSTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
$dns = new \Cloudflare\API\Endpoints\DNS($mock);
|
||||||
$result = $dns->updateRecordDetails("023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", $details);
|
$result = $dns->updateRecordDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', $details);
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->result->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result->id);
|
||||||
|
|
||||||
foreach ($details as $property => $value) {
|
foreach ($details as $property => $value) {
|
||||||
$this->assertEquals($result->result->{ $property }, $value);
|
$this->assertEquals($result->result->{ $property }, $value);
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 20:16
|
* Time: 20:16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Endpoints\IPs;
|
|
||||||
|
|
||||||
class IPsTest extends TestCase
|
class IPsTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListIPs()
|
public function testListIPs()
|
||||||
@@ -26,7 +24,7 @@ class IPsTest extends TestCase
|
|||||||
|
|
||||||
$ips = new \Cloudflare\API\Endpoints\IPs($mock);
|
$ips = new \Cloudflare\API\Endpoints\IPs($mock);
|
||||||
$ips = $ips->listIPs();
|
$ips = $ips->listIPs();
|
||||||
$this->assertObjectHasAttribute("ipv4_cidrs", $ips);
|
$this->assertObjectHasAttribute('ipv4_cidrs', $ips);
|
||||||
$this->assertObjectHasAttribute("ipv6_cidrs", $ips);
|
$this->assertObjectHasAttribute('ipv6_cidrs', $ips);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 19:25
|
* Time: 19:25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Adapter\PageRules;
|
|
||||||
|
|
||||||
class PageRulesTest extends TestCase
|
class PageRulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testCreatePageRule()
|
public function testCreatePageRule()
|
||||||
|
|||||||
@@ -6,14 +6,12 @@
|
|||||||
* Time: 11:20
|
* Time: 11:20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Endpoints\Railgun;
|
|
||||||
|
|
||||||
class RailgunTest extends TestCase
|
class RailgunTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testcreate()
|
public function testcreate()
|
||||||
{
|
{
|
||||||
$details = [
|
$details = [
|
||||||
'name' => "My Railgun",
|
'name' => 'My Railgun',
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRailgun.json');
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRailgun.json');
|
||||||
@@ -59,7 +57,7 @@ class RailgunTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
$result = $railgun->list(1, 20, "desc");
|
$result = $railgun->list(1, 20, 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
@@ -80,9 +78,9 @@ class RailgunTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
$result = $railgun->get("e928d310693a83094309acf9ead50448");
|
$result = $railgun->get('e928d310693a83094309acf9ead50448');
|
||||||
|
|
||||||
$this->assertEquals("e928d310693a83094309acf9ead50448", $result->id);
|
$this->assertEquals('e928d310693a83094309acf9ead50448', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testgetZones()
|
public function testgetZones()
|
||||||
@@ -101,7 +99,7 @@ class RailgunTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
$railgun = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
$result = $railgun->getZones("e928d310693a83094309acf9ead50448");
|
$result = $railgun->getZones('e928d310693a83094309acf9ead50448');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
@@ -127,9 +125,9 @@ class RailgunTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
$result = $waf->update("e928d310693a83094309acf9ead50448", true);
|
$result = $waf->update('e928d310693a83094309acf9ead50448', true);
|
||||||
|
|
||||||
$this->assertEquals("e928d310693a83094309acf9ead50448", $result->id);
|
$this->assertEquals('e928d310693a83094309acf9ead50448', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testdelete()
|
public function testdelete()
|
||||||
@@ -148,6 +146,6 @@ class RailgunTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
$waf = new \Cloudflare\API\Endpoints\Railgun($mock);
|
||||||
$waf->delete("e928d310693a83094309acf9ead50448");
|
$waf->delete('e928d310693a83094309acf9ead50448');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ class UARulesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\UARules($mock);
|
$zones = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$result = $zones->listRules("023e105f4ecef8ad9ca31a8372d0c353", 1, 20);
|
$result = $zones->listRules('023e105f4ecef8ad9ca31a8372d0c353');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->result[0]->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,9 +84,9 @@ class UARulesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$lockdown = new \Cloudflare\API\Endpoints\UARules($mock);
|
$lockdown = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$result = $lockdown->getRuleDetails("023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59");
|
$result = $lockdown->getRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateRule()
|
public function testUpdateRule()
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ class UserTest extends TestCase
|
|||||||
$user = new \Cloudflare\API\Endpoints\User($mock);
|
$user = new \Cloudflare\API\Endpoints\User($mock);
|
||||||
$details = $user->getUserDetails();
|
$details = $user->getUserDetails();
|
||||||
|
|
||||||
$this->assertObjectHasAttribute("id", $details);
|
$this->assertObjectHasAttribute('id', $details);
|
||||||
$this->assertEquals("7c5dae5552338874e5053f2534d2767a", $details->id);
|
$this->assertEquals('7c5dae5552338874e5053f2534d2767a', $details->id);
|
||||||
$this->assertObjectHasAttribute("email", $details);
|
$this->assertObjectHasAttribute('email', $details);
|
||||||
$this->assertEquals("user@example.com", $details->email);
|
$this->assertEquals('user@example.com', $details->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetUserID()
|
public function testGetUserID()
|
||||||
@@ -31,7 +31,7 @@ class UserTest extends TestCase
|
|||||||
$mock->method('get')->willReturn($response);
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
$user = new \Cloudflare\API\Endpoints\User($mock);
|
$user = new \Cloudflare\API\Endpoints\User($mock);
|
||||||
$this->assertEquals("7c5dae5552338874e5053f2534d2767a", $user->getUserID());
|
$this->assertEquals('7c5dae5552338874e5053f2534d2767a', $user->getUserID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetUserEmail()
|
public function testGetUserEmail()
|
||||||
@@ -44,7 +44,7 @@ class UserTest extends TestCase
|
|||||||
$mock->expects($this->once())->method('get');
|
$mock->expects($this->once())->method('get');
|
||||||
|
|
||||||
$user = new \Cloudflare\API\Endpoints\User($mock);
|
$user = new \Cloudflare\API\Endpoints\User($mock);
|
||||||
$this->assertEquals("user@example.com", $user->getUserEmail());
|
$this->assertEquals('user@example.com', $user->getUserEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateUserDetails()
|
public function testUpdateUserDetails()
|
||||||
@@ -59,6 +59,6 @@ class UserTest extends TestCase
|
|||||||
->with($this->equalTo('user'), $this->equalTo([]), $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 = new \Cloudflare\API\Endpoints\User($mock);
|
||||||
$user->updateUserDetails(['email' => "user2@example.com"]);
|
$user->updateUserDetails(['email' => 'user2@example.com']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 13:34
|
* Time: 13:34
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Endpoints\WAF;
|
|
||||||
|
|
||||||
class WAFTest extends TestCase
|
class WAFTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testgetPackages()
|
public function testgetPackages()
|
||||||
@@ -32,12 +30,12 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getPackages("023e105f4ecef8ad9ca31a8372d0c353", 1, 20, "status", "desc", "all");
|
$result = $waf->getPackages('023e105f4ecef8ad9ca31a8372d0c353', 1, 20, 'status', 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("a25a9a7e9c00afc1fb2e0245519d725b", $result->result[0]->id);
|
$this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,9 +54,9 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getPackageInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b");
|
$result = $waf->getPackageInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b');
|
||||||
|
|
||||||
$this->assertEquals("a25a9a7e9c00afc1fb2e0245519d725b", $result->id);
|
$this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testgetRules()
|
public function testgetRules()
|
||||||
@@ -83,12 +81,12 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getRules("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", 1, 20, "status", "desc", "all");
|
$result = $waf->getRules('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 1, 20, 'status', 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("92f17202ed8bd63d69a66b86a49a8f6b", $result->result[0]->id);
|
$this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,9 +105,9 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getRuleInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "f939de3be84e66e757adcdcb87908023");
|
$result = $waf->getRuleInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'f939de3be84e66e757adcdcb87908023');
|
||||||
|
|
||||||
$this->assertEquals("f939de3be84e66e757adcdcb87908023", $result->id);
|
$this->assertEquals('f939de3be84e66e757adcdcb87908023', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testupdateRule()
|
public function testupdateRule()
|
||||||
@@ -120,7 +118,7 @@ class WAFTest extends TestCase
|
|||||||
$mock->method('patch')->willReturn($response);
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
$details = [
|
$details = [
|
||||||
'mode' => "on",
|
'mode' => 'on',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
@@ -132,9 +130,9 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->updateRule("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "f939de3be84e66e757adcdcb87908023", "on");
|
$result = $waf->updateRule('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'f939de3be84e66e757adcdcb87908023', 'on');
|
||||||
|
|
||||||
$this->assertEquals("f939de3be84e66e757adcdcb87908023", $result->id);
|
$this->assertEquals('f939de3be84e66e757adcdcb87908023', $result->id);
|
||||||
|
|
||||||
foreach ($details as $property => $value) {
|
foreach ($details as $property => $value) {
|
||||||
$this->assertEquals($result->{ $property }, $value);
|
$this->assertEquals($result->{ $property }, $value);
|
||||||
@@ -163,12 +161,12 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getGroups("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", 1, 20, "status", "desc", "all");
|
$result = $waf->getGroups('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 1, 20, 'status', 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->result[0]->id);
|
$this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,9 +185,9 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->getGroupInfo("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "de677e5818985db1285d0e80225f06e5");
|
$result = $waf->getGroupInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'de677e5818985db1285d0e80225f06e5');
|
||||||
|
|
||||||
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->id);
|
$this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testupdateGroup()
|
public function testupdateGroup()
|
||||||
@@ -200,7 +198,7 @@ class WAFTest extends TestCase
|
|||||||
$mock->method('patch')->willReturn($response);
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
$details = [
|
$details = [
|
||||||
'mode' => "off",
|
'mode' => 'off',
|
||||||
];
|
];
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
@@ -212,9 +210,9 @@ class WAFTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
$waf = new \Cloudflare\API\Endpoints\WAF($mock);
|
||||||
$result = $waf->updateGroup("023e105f4ecef8ad9ca31a8372d0c353", "a25a9a7e9c00afc1fb2e0245519d725b", "de677e5818985db1285d0e80225f06e5", "off");
|
$result = $waf->updateGroup('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'de677e5818985db1285d0e80225f06e5', 'off');
|
||||||
|
|
||||||
$this->assertEquals("de677e5818985db1285d0e80225f06e5", $result->id);
|
$this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->id);
|
||||||
|
|
||||||
foreach ($details as $property => $value) {
|
foreach ($details as $property => $value) {
|
||||||
$this->assertEquals($result->{ $property }, $value);
|
$this->assertEquals($result->{ $property }, $value);
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ class ZoneLockdownTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zones = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$result = $zones->listLockdowns("023e105f4ecef8ad9ca31a8372d0c353", 1, 20);
|
$result = $zones->listLockdowns('023e105f4ecef8ad9ca31a8372d0c353');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->result[0]->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo([
|
$this->equalTo([
|
||||||
'urls' => ["api.mysite.com/some/endpoint*"],
|
'urls' => ['api.mysite.com/some/endpoint*'],
|
||||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
'description' => 'Restrict access to these endpoints to requests from a known IP address',
|
'description' => 'Restrict access to these endpoints to requests from a known IP address',
|
||||||
'configurations' => $config->getArray(),
|
'configurations' => $config->getArray(),
|
||||||
@@ -62,7 +62,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$zoneLockdown->createLockdown(
|
$zoneLockdown->createLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
["api.mysite.com/some/endpoint*"],
|
['api.mysite.com/some/endpoint*'],
|
||||||
$config,
|
$config,
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
'Restrict access to these endpoints to requests from a known IP address'
|
'Restrict access to these endpoints to requests from a known IP address'
|
||||||
@@ -84,9 +84,9 @@ class ZoneLockdownTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$lockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$lockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$result = $lockdown->getLockdownDetails("023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59");
|
$result = $lockdown->getLockdownDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
|
|
||||||
$this->assertEquals("372e67954025e0ba6aaa6d586b9e0b59", $result->id);
|
$this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateLockdown()
|
public function testUpdateLockdown()
|
||||||
@@ -105,7 +105,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
|
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo([
|
$this->equalTo([
|
||||||
'urls' => ["api.mysite.com/some/endpoint*"],
|
'urls' => ['api.mysite.com/some/endpoint*'],
|
||||||
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
'id' => '372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
'description' => 'Restrict access to these endpoints to requests from a known IP address',
|
'description' => 'Restrict access to these endpoints to requests from a known IP address',
|
||||||
'configurations' => $config->getArray(),
|
'configurations' => $config->getArray(),
|
||||||
@@ -116,7 +116,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$zoneLockdown->updateLockdown(
|
$zoneLockdown->updateLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
["api.mysite.com/some/endpoint*"],
|
['api.mysite.com/some/endpoint*'],
|
||||||
$config,
|
$config,
|
||||||
'Restrict access to these endpoints to requests from a known IP address'
|
'Restrict access to these endpoints to requests from a known IP address'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,29 +24,30 @@ class ZonesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->addZone("example.com");
|
$result = $zones->addZone('example.com');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute("id", $result);
|
$this->assertObjectHasAttribute('id', $result);
|
||||||
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result->id);
|
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->id);
|
||||||
|
|
||||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.json');
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.json');
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
$org = new stdClass();
|
|
||||||
$org->id = "01a7362d577a6c3019a474fd6f485823";
|
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
->method('post')
|
->method('post')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('zones'),
|
$this->equalTo('zones'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo(['name' => 'example.com', 'jumpstart' => true, 'organization' => $org])
|
$this->equalTo([
|
||||||
|
'name' => 'example.com',
|
||||||
|
'jumpstart' => true,
|
||||||
|
'organization' => (object)['id' => '01a7362d577a6c3019a474fd6f485823']
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$zones->addZone("example.com", true, "01a7362d577a6c3019a474fd6f485823");
|
$zones->addZone('example.com', true, '01a7362d577a6c3019a474fd6f485823');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testActivationTest()
|
public function testActivationTest()
|
||||||
@@ -65,7 +66,7 @@ class ZonesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->activationCheck("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
|
$result = $zones->activationCheck('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -94,12 +95,12 @@ class ZonesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->listZones("example.com", "active", 1, 20, "status", "desc", "all");
|
$result = $zones->listZones('example.com', 'active', 1, 20, 'status', 'desc');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('result', $result);
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
$this->assertObjectHasAttribute('result_info', $result);
|
$this->assertObjectHasAttribute('result_info', $result);
|
||||||
|
|
||||||
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result->result[0]->id);
|
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->result[0]->id);
|
||||||
$this->assertEquals(1, $result->result_info->page);
|
$this->assertEquals(1, $result->result_info->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,9 +125,9 @@ class ZonesTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->getZoneID("example.com");
|
$result = $zones->getZoneID('example.com');
|
||||||
|
|
||||||
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result);
|
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAnalyticsDashboard()
|
public function testGetAnalyticsDashboard()
|
||||||
@@ -141,14 +142,14 @@ class ZonesTest extends TestCase
|
|||||||
->with(
|
->with(
|
||||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/analytics/dashboard'),
|
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/analytics/dashboard'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo(["since" => "-10080", "until" => "0", "continuous" => true])
|
$this->equalTo(['since' => '-10080', 'until' => '0', 'continuous' => true])
|
||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$analytics = $zones->getAnalyticsDashboard("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
|
$analytics = $zones->getAnalyticsDashboard('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||||
|
|
||||||
$this->assertObjectHasAttribute("since", $analytics->totals);
|
$this->assertObjectHasAttribute('since', $analytics->totals);
|
||||||
$this->assertObjectHasAttribute("since", $analytics->timeseries[0]);
|
$this->assertObjectHasAttribute('since', $analytics->timeseries[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testChangeDevelopmentMode()
|
public function testChangeDevelopmentMode()
|
||||||
@@ -163,11 +164,11 @@ class ZonesTest extends TestCase
|
|||||||
->with(
|
->with(
|
||||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/development_mode'),
|
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/development_mode'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo(["value" => "on"])
|
$this->equalTo(['value' => 'on'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->changeDevelopmentMode("c2547eb745079dac9320b638f5e225cf483cc5cfdda41", true);
|
$result = $zones->changeDevelopmentMode('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -184,11 +185,11 @@ class ZonesTest extends TestCase
|
|||||||
->with(
|
->with(
|
||||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||||
$this->equalTo([]),
|
$this->equalTo([]),
|
||||||
$this->equalTo(["purge_everything" => true])
|
$this->equalTo(['purge_everything' => true])
|
||||||
);
|
);
|
||||||
|
|
||||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||||
$result = $zones->cachePurgeEverything("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
|
$result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|||||||
30
tests/Fixtures/Endpoints/createAccessRule.json
Normal file
30
tests/Fixtures/Endpoints/createAccessRule.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
tests/Fixtures/Endpoints/deleteAccessRule.json
Normal file
12
tests/Fixtures/Endpoints/deleteAccessRule.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"messages": [
|
||||||
|
{}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"id": "92f17202ed8bd63d69a66b86a49a8f6b"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
tests/Fixtures/Endpoints/listAccessRules.json
Normal file
38
tests/Fixtures/Endpoints/listAccessRules.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
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Fixtures/Endpoints/updateAccessRule.json
Normal file
30
tests/Fixtures/Endpoints/updateAccessRule.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
|
|||||||
* Returns a PSR7 Stream for a given fixture.
|
* Returns a PSR7 Stream for a given fixture.
|
||||||
*
|
*
|
||||||
* @param string $fixture The fixture to create the stream for.
|
* @param string $fixture The fixture to create the stream for.
|
||||||
* @return Psr7Stream
|
* @return Psr7\Stream
|
||||||
*/
|
*/
|
||||||
protected function getPsr7StreamForFixture($fixture): Psr7\Stream
|
protected function getPsr7StreamForFixture($fixture): Psr7\Stream
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @param string $fixture The fixture to create the response for.
|
* @param string $fixture The fixture to create the response for.
|
||||||
* @param integer $statusCode A HTTP Status Code for the response.
|
* @param integer $statusCode A HTTP Status Code for the response.
|
||||||
* @return Psr7Response
|
* @return Psr7\Response
|
||||||
*/
|
*/
|
||||||
protected function getPsr7JsonResponseForFixture($fixture, $statusCode = 200): Psr7\Response
|
protected function getPsr7JsonResponseForFixture($fixture, $statusCode = 200): Psr7\Response
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user