From 2b253659888efdc240f9a6348f173cf9fd1fce49 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Fri, 22 Feb 2019 23:54:14 +0000 Subject: [PATCH] Updated TLS.php and added new endpoints to new ZoneSettings.php --- CONTRIBUTING.md | 17 + LICENSE | 26 + Makefile | 17 + README.md | 47 + cloudflare-php | 1 + composer.json | 32 + composer.lock | 3002 +++++++++++++++++ paul | 30 + paul.pub | 1 + phpunit.xml | 13 + src/Adapter/Adapter.php | 76 + src/Adapter/Guzzle.php | 109 + src/Adapter/JSONException.php | 13 + src/Adapter/ResponseException.php | 13 + src/Auth/APIKey.php | 28 + src/Auth/Auth.php | 13 + src/Auth/None.php | 17 + src/Auth/UserServiceKey.php | 25 + src/Configurations/AccessRules.php | 28 + src/Configurations/Configurations.php | 14 + .../ConfigurationsException.php | 13 + src/Configurations/PageRulesActions.php | 313 ++ src/Configurations/PageRulesTargets.php | 32 + src/Configurations/UARules.php | 24 + src/Configurations/ZoneLockdown.php | 29 + src/Endpoints/API.php | 15 + src/Endpoints/AccessRules.php | 156 + src/Endpoints/CustomHostnames.php | 153 + src/Endpoints/DNS.php | 147 + src/Endpoints/EndpointException.php | 13 + src/Endpoints/IPs.php | 32 + src/Endpoints/PageRules.php | 161 + src/Endpoints/Railgun.php | 102 + src/Endpoints/TLS.php | 124 + src/Endpoints/UARules.php | 120 + src/Endpoints/User.php | 47 + src/Endpoints/WAF.php | 183 + src/Endpoints/ZoneLockdown.php | 119 + src/Endpoints/ZoneSettings.php | 153 + src/Endpoints/Zones.php | 195 ++ src/Traits/BodyAccessorTrait.php | 13 + tests/Adapter/GuzzleTest.php | 136 + tests/Auth/APIKeyTest.php | 23 + tests/Auth/NoneTest.php | 18 + tests/Auth/UserServiceKeyTest.php | 24 + .../ConfigurationsUARulesTest.php | 27 + .../ConfigurationsZoneLockdownTest.php | 34 + tests/Configurations/PageRulesActionTest.php | 21 + tests/Configurations/PageRulesTargetTest.php | 22 + tests/Endpoints/AccessRulesTest.php | 112 + tests/Endpoints/CustomHostnamesTest.php | 138 + tests/Endpoints/DNSTest.php | 121 + tests/Endpoints/IPsTest.php | 31 + tests/Endpoints/PageRulesTest.php | 132 + tests/Endpoints/RailgunTest.php | 149 + tests/Endpoints/TLSTest.php | 71 + tests/Endpoints/UARulesTest.php | 142 + tests/Endpoints/UserTest.php | 68 + tests/Endpoints/WAFTest.php | 221 ++ tests/Endpoints/ZoneLockdownTest.php | 145 + tests/Endpoints/ZonesTest.php | 246 ++ tests/Fixtures/Endpoints/activationTest.json | 8 + tests/Fixtures/Endpoints/addLockdown.json | 18 + tests/Fixtures/Endpoints/addRecord.json | 20 + tests/Fixtures/Endpoints/addZone.json | 54 + tests/Fixtures/Endpoints/cachePurge.json | 8 + .../Endpoints/cachePurgeEverything.json | 8 + tests/Fixtures/Endpoints/cachePurgeHost.json | 8 + .../Endpoints/changeDevelopmentMode.json | 12 + .../Endpoints/changeMinimumTLSVersion.json | 6 + .../Fixtures/Endpoints/createAccessRule.json | 30 + .../Endpoints/createCustomHostname.json | 20 + tests/Fixtures/Endpoints/createPageRule.json | 31 + tests/Fixtures/Endpoints/createRailgun.json | 23 + tests/Fixtures/Endpoints/createRule.json | 18 + .../Fixtures/Endpoints/deleteAccessRule.json | 12 + tests/Fixtures/Endpoints/deleteHostname.json | 3 + tests/Fixtures/Endpoints/deleteLockdown.json | 12 + tests/Fixtures/Endpoints/deletePageRule.json | 12 + tests/Fixtures/Endpoints/deleteRailgun.json | 12 + tests/Fixtures/Endpoints/deleteRule.json | 12 + tests/Fixtures/Endpoints/disableTLS13.json | 6 + tests/Fixtures/Endpoints/enableTLS13.json | 6 + .../Endpoints/getAnalyticsDashboard.json | 176 + .../Endpoints/getDNSRecordDetails.json | 20 + tests/Fixtures/Endpoints/getHostname.json | 20 + .../Endpoints/getPackageGroupInfo.json | 22 + tests/Fixtures/Endpoints/getPackageInfo.json | 17 + .../Endpoints/getPackageRuleInfo.json | 24 + .../Endpoints/getPageRuleDetails.json | 31 + tests/Fixtures/Endpoints/getRailgun.json | 23 + .../Fixtures/Endpoints/getRecordDetails.json | 22 + tests/Fixtures/Endpoints/getRuleDetails.json | 18 + tests/Fixtures/Endpoints/getUserDetails.json | 18 + tests/Fixtures/Endpoints/getUserEmail.json | 18 + tests/Fixtures/Endpoints/getUserId.json | 18 + tests/Fixtures/Endpoints/getZoneId.json | 62 + tests/Fixtures/Endpoints/listAccessRules.json | 38 + tests/Fixtures/Endpoints/listHostnames.json | 28 + tests/Fixtures/Endpoints/listIPs.json | 13 + tests/Fixtures/Endpoints/listLockdowns.json | 26 + .../Fixtures/Endpoints/listPackageGroups.json | 30 + .../Fixtures/Endpoints/listPackageRules.json | 38 + tests/Fixtures/Endpoints/listPackages.json | 25 + tests/Fixtures/Endpoints/listPageRules.json | 39 + .../Fixtures/Endpoints/listRailgunZones.json | 30 + tests/Fixtures/Endpoints/listRailguns.json | 31 + tests/Fixtures/Endpoints/listRecords.json | 28 + tests/Fixtures/Endpoints/listRules.json | 26 + tests/Fixtures/Endpoints/listZones.json | 62 + .../Fixtures/Endpoints/updateAccessRule.json | 30 + tests/Fixtures/Endpoints/updateDNSRecord.json | 24 + tests/Fixtures/Endpoints/updateHostname.json | 20 + tests/Fixtures/Endpoints/updateLockdown.json | 22 + .../Endpoints/updatePackageGroup.json | 22 + .../Fixtures/Endpoints/updatePackageRule.json | 24 + tests/Fixtures/Endpoints/updatePageRule.json | 31 + tests/Fixtures/Endpoints/updateRailgun.json | 23 + tests/Fixtures/Endpoints/updateRule.json | 18 + .../Fixtures/Endpoints/updateUserDetails.json | 18 + tests/TestCase.php | 46 + 121 files changed, 9067 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 160000 cloudflare-php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 paul create mode 100644 paul.pub create mode 100644 phpunit.xml create mode 100644 src/Adapter/Adapter.php create mode 100644 src/Adapter/Guzzle.php create mode 100644 src/Adapter/JSONException.php create mode 100644 src/Adapter/ResponseException.php create mode 100644 src/Auth/APIKey.php create mode 100644 src/Auth/Auth.php create mode 100644 src/Auth/None.php create mode 100644 src/Auth/UserServiceKey.php create mode 100644 src/Configurations/AccessRules.php create mode 100644 src/Configurations/Configurations.php create mode 100644 src/Configurations/ConfigurationsException.php create mode 100644 src/Configurations/PageRulesActions.php create mode 100644 src/Configurations/PageRulesTargets.php create mode 100644 src/Configurations/UARules.php create mode 100644 src/Configurations/ZoneLockdown.php create mode 100644 src/Endpoints/API.php create mode 100644 src/Endpoints/AccessRules.php create mode 100644 src/Endpoints/CustomHostnames.php create mode 100644 src/Endpoints/DNS.php create mode 100644 src/Endpoints/EndpointException.php create mode 100644 src/Endpoints/IPs.php create mode 100644 src/Endpoints/PageRules.php create mode 100644 src/Endpoints/Railgun.php create mode 100644 src/Endpoints/TLS.php create mode 100644 src/Endpoints/UARules.php create mode 100644 src/Endpoints/User.php create mode 100644 src/Endpoints/WAF.php create mode 100644 src/Endpoints/ZoneLockdown.php create mode 100644 src/Endpoints/ZoneSettings.php create mode 100644 src/Endpoints/Zones.php create mode 100644 src/Traits/BodyAccessorTrait.php create mode 100644 tests/Adapter/GuzzleTest.php create mode 100644 tests/Auth/APIKeyTest.php create mode 100644 tests/Auth/NoneTest.php create mode 100644 tests/Auth/UserServiceKeyTest.php create mode 100644 tests/Configurations/ConfigurationsUARulesTest.php create mode 100644 tests/Configurations/ConfigurationsZoneLockdownTest.php create mode 100644 tests/Configurations/PageRulesActionTest.php create mode 100644 tests/Configurations/PageRulesTargetTest.php create mode 100644 tests/Endpoints/AccessRulesTest.php create mode 100644 tests/Endpoints/CustomHostnamesTest.php create mode 100644 tests/Endpoints/DNSTest.php create mode 100644 tests/Endpoints/IPsTest.php create mode 100644 tests/Endpoints/PageRulesTest.php create mode 100644 tests/Endpoints/RailgunTest.php create mode 100644 tests/Endpoints/TLSTest.php create mode 100644 tests/Endpoints/UARulesTest.php create mode 100644 tests/Endpoints/UserTest.php create mode 100644 tests/Endpoints/WAFTest.php create mode 100644 tests/Endpoints/ZoneLockdownTest.php create mode 100644 tests/Endpoints/ZonesTest.php create mode 100644 tests/Fixtures/Endpoints/activationTest.json create mode 100644 tests/Fixtures/Endpoints/addLockdown.json create mode 100644 tests/Fixtures/Endpoints/addRecord.json create mode 100644 tests/Fixtures/Endpoints/addZone.json create mode 100644 tests/Fixtures/Endpoints/cachePurge.json create mode 100644 tests/Fixtures/Endpoints/cachePurgeEverything.json create mode 100644 tests/Fixtures/Endpoints/cachePurgeHost.json create mode 100644 tests/Fixtures/Endpoints/changeDevelopmentMode.json create mode 100644 tests/Fixtures/Endpoints/changeMinimumTLSVersion.json create mode 100644 tests/Fixtures/Endpoints/createAccessRule.json create mode 100644 tests/Fixtures/Endpoints/createCustomHostname.json create mode 100644 tests/Fixtures/Endpoints/createPageRule.json create mode 100644 tests/Fixtures/Endpoints/createRailgun.json create mode 100644 tests/Fixtures/Endpoints/createRule.json create mode 100644 tests/Fixtures/Endpoints/deleteAccessRule.json create mode 100644 tests/Fixtures/Endpoints/deleteHostname.json create mode 100644 tests/Fixtures/Endpoints/deleteLockdown.json create mode 100644 tests/Fixtures/Endpoints/deletePageRule.json create mode 100644 tests/Fixtures/Endpoints/deleteRailgun.json create mode 100644 tests/Fixtures/Endpoints/deleteRule.json create mode 100644 tests/Fixtures/Endpoints/disableTLS13.json create mode 100644 tests/Fixtures/Endpoints/enableTLS13.json create mode 100644 tests/Fixtures/Endpoints/getAnalyticsDashboard.json create mode 100644 tests/Fixtures/Endpoints/getDNSRecordDetails.json create mode 100644 tests/Fixtures/Endpoints/getHostname.json create mode 100644 tests/Fixtures/Endpoints/getPackageGroupInfo.json create mode 100644 tests/Fixtures/Endpoints/getPackageInfo.json create mode 100644 tests/Fixtures/Endpoints/getPackageRuleInfo.json create mode 100644 tests/Fixtures/Endpoints/getPageRuleDetails.json create mode 100644 tests/Fixtures/Endpoints/getRailgun.json create mode 100644 tests/Fixtures/Endpoints/getRecordDetails.json create mode 100644 tests/Fixtures/Endpoints/getRuleDetails.json create mode 100644 tests/Fixtures/Endpoints/getUserDetails.json create mode 100644 tests/Fixtures/Endpoints/getUserEmail.json create mode 100644 tests/Fixtures/Endpoints/getUserId.json create mode 100644 tests/Fixtures/Endpoints/getZoneId.json create mode 100644 tests/Fixtures/Endpoints/listAccessRules.json create mode 100644 tests/Fixtures/Endpoints/listHostnames.json create mode 100644 tests/Fixtures/Endpoints/listIPs.json create mode 100644 tests/Fixtures/Endpoints/listLockdowns.json create mode 100644 tests/Fixtures/Endpoints/listPackageGroups.json create mode 100644 tests/Fixtures/Endpoints/listPackageRules.json create mode 100644 tests/Fixtures/Endpoints/listPackages.json create mode 100644 tests/Fixtures/Endpoints/listPageRules.json create mode 100644 tests/Fixtures/Endpoints/listRailgunZones.json create mode 100644 tests/Fixtures/Endpoints/listRailguns.json create mode 100644 tests/Fixtures/Endpoints/listRecords.json create mode 100644 tests/Fixtures/Endpoints/listRules.json create mode 100644 tests/Fixtures/Endpoints/listZones.json create mode 100644 tests/Fixtures/Endpoints/updateAccessRule.json create mode 100644 tests/Fixtures/Endpoints/updateDNSRecord.json create mode 100644 tests/Fixtures/Endpoints/updateHostname.json create mode 100644 tests/Fixtures/Endpoints/updateLockdown.json create mode 100644 tests/Fixtures/Endpoints/updatePackageGroup.json create mode 100644 tests/Fixtures/Endpoints/updatePackageRule.json create mode 100644 tests/Fixtures/Endpoints/updatePageRule.json create mode 100644 tests/Fixtures/Endpoints/updateRailgun.json create mode 100644 tests/Fixtures/Endpoints/updateRule.json create mode 100644 tests/Fixtures/Endpoints/updateUserDetails.json create mode 100644 tests/TestCase.php diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f8d4e37 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing to Cloudflare PHP API Binding + +👍🎉 First off, thanks for taking the time to contribute! 🎉👍 + +## How To Contribute + +We welcome community contribution to this repository. To help add functionality or address issues, please take the following steps: + +* Fork the repository from the master branch. +* Create a new branch for your features / fixes. +* Make the changes you wish to see. +* Add tests for all changes. +* Run `make fix` command to ensure the code is styled. +* Run `make test` command to ensure the tests pass. +* Create a pull request with details of what changes have been made and explanation of new behaviour. +* Ensure documentation contains the correct information. +* Pull requests will be reviewed and hopefully merged into a release. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..534ca68 --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2015-2016, Cloudflare. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2bd666d --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +THIS := $(realpath $(lastword $(MAKEFILE_LIST))) +HERE := $(shell dirname $(THIS)) + +.PHONY: all fix lint test + +all: lint test + +fix: + php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs + +lint: + php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs --dry-run + php $(HERE)/vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode + php $(HERE)/vendor/bin/phpmd tests/ text cleancode,codesize,controversial,design,naming,unusedcode + +test: + php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0f52fe --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Cloudflare SDK (v4 API Binding for PHP 7) + +[![Build Status](https://travis-ci.org/cloudflare/cloudflare-php.svg?branch=master)](https://travis-ci.org/cloudflare/cloudflare-php) + +## Installation + +The recommended way to install this package is via the Packagist Dependency Manager ([cloudflare/sdk](https://packagist.org/packages/cloudflare/sdk)). You can get specific usage examples on the Cloudflare Knowledge Base under: [Cloudflare PHP API Binding](https://support.cloudflare.com/hc/en-us/articles/115001661191) + +## Cloudflare API version 4 + +The Cloudflare API can be found [here](https://api.cloudflare.com/). +Each API call is provided via a similarly named function within various classes in the **Cloudflare\API\Endpoints** namespace: + +- [x] [DNS Records](https://www.cloudflare.com/dns/) +- [x] Zones +- [x] User Administration (partial) +- [x] [Cloudflare IPs](https://www.cloudflare.com/ips/) +- [x] [Page Rules](https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-) +- [x] [Web Application Firewall (WAF)](https://www.cloudflare.com/waf/) +- [ ] Virtual DNS Management +- [x] Custom hostnames +- [x] Manage TLS settings +- [x] Zone Lockdown and User-Agent Block rules +- [ ] Organization Administration +- [x] [Railgun](https://www.cloudflare.com/railgun/) administration +- [ ] [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/) +- [ ] [Origin CA](https://blog.cloudflare.com/universal-ssl-encryption-all-the-way-to-the-origin-for-free/) + +Note that this repository is currently under development, additional classes and endpoints being actively added. + +## Getting Started + +```php +$key = new Cloudflare\API\Auth\APIKey('user@example.com', 'apiKey'); +$adapter = new Cloudflare\API\Adapter\Guzzle($key); +$user = new Cloudflare\API\Endpoints\User($adapter); + +echo $user->getUserID(); +``` + +## Contributions + +We welcome community contribution to this repository. [CONTRIBUTING.md](CONTRIBUTING.md) will help you start contributing. + +## Licensing + +Licensed under the 3-clause BSD license. See the [LICENSE](LICENSE) file for details. diff --git a/cloudflare-php b/cloudflare-php new file mode 160000 index 0000000..4694904 --- /dev/null +++ b/cloudflare-php @@ -0,0 +1 @@ +Subproject commit 4694904b38fdf5f251559a473cecf77a63cf9202 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a6dbadd --- /dev/null +++ b/composer.json @@ -0,0 +1,32 @@ +{ + "name": "cloudflare/sdk", + "description": "PHP binding for v4 of the Cloudflare Client API.", + "type": "library", + "require": { + "guzzlehttp/guzzle": "^6.2.2", + "php": ">=7.0.0", + "psr/http-message": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "5.7.5", + "phpmd/phpmd" : "@stable", + "friendsofphp/php-cs-fixer": "^2.6" + }, + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Junade Ali", + "email": "junade@cloudflare.com" + } + ], + "autoload": { + "psr-4": { + "Cloudflare\\API\\": "src/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..0b8441f --- /dev/null +++ b/composer.lock @@ -0,0 +1,3002 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "9a243e606c74dcbd67ae934182df9d2c", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-04-22T15:46:56+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + } + ], + "packages-dev": [ + { + "name": "composer/semver", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5", + "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2016-08-30T16:08:34+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-08-31T19:07:57+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-02-24T16:22:25+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14T21:17:01+00:00" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09T13:34:57+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.13.1", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "54814c62d5beef3ba55297b9b3186ed8b8a1b161" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/54814c62d5beef3ba55297b9b3186ed8b8a1b161", + "reference": "54814c62d5beef3ba55297b9b3186ed8b8a1b161", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || >=7.0 <7.3", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6", + "symfony/event-dispatcher": "^3.0 || ^4.0", + "symfony/filesystem": "^3.0 || ^4.0", + "symfony/finder": "^3.0 || ^4.0", + "symfony/options-resolver": "^3.0 || ^4.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0", + "symfony/stopwatch": "^3.0 || ^4.0" + }, + "conflict": { + "hhvm": "*" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.1", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", + "phpunitgoodpractices/traits": "^1.5.1", + "symfony/phpunit-bridge": "^4.0" + }, + "suggest": { + "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2018-10-21T00:32:10+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, + { + "name": "pdepend/pdepend", + "version": "2.5.2", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "9daf26d0368d4a12bed1cacae1a9f3a6f0adf239" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/9daf26d0368d4a12bed1cacae1a9f3a6f0adf239", + "reference": "9daf26d0368d4a12bed1cacae1a9f3a6f0adf239", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3|^4", + "symfony/dependency-injection": "^2.3.0|^3|^4", + "symfony/filesystem": "^2.3.0|^3|^4" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "time": "2017-12-13T13:21:38+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-30T07:14:17+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpmd/phpmd", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "4e9924b2c157a3eb64395460fcf56b31badc8374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/4e9924b2c157a3eb64395460fcf56b31badc8374", + "reference": "4e9924b2c157a3eb64395460fcf56b31badc8374", + "shasum": "" + }, + "require": { + "ext-xml": "*", + "pdepend/pdepend": "^2.5", + "php": ">=5.3.9" + }, + "require-dev": { + "phpunit/phpunit": "^4.0", + "squizlabs/php_codesniffer": "^2.0" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "project", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "http://phpmd.org/", + "keywords": [ + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "time": "2017-01-20T14:41:10+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-08-05T17:53:17+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" + }, + "require-dev": { + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" + }, + "suggest": { + "ext-xdebug": "^2.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2017-04-02T07:44:40+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2017-11-27T13:52:08+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26T11:10:40+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "791198a2c6254db10131eecfe8c06670700904db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-11-27T05:48:46+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "5.7.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50fd2be8f3e23e91da825f36f08e5f9633076ffe", + "reference": "50fd2be8f3e23e91da825f36f08e5f9633076ffe", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.3", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "~1.2.2", + "sebastian/diff": "~1.2", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.0 || ^2.0", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0|~2.0", + "symfony/yaml": "~2.1|~3.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2016-12-28T07:18:51+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2017-06-30T09:13:00+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29T09:50:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2017-05-22T07:24:03+00:00" + }, + { + "name": "sebastian/environment", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-11-26T07:53:53+00:00" + }, + { + "name": "sebastian/exporter", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-11-19T08:54:04+00:00" + }, + { + "name": "sebastian/global-state", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2017-04-27T15:39:26+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18T15:18:39+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-11-19T07:33:16+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "symfony/config", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "e5389132dc6320682de3643091121c048ff796b3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/e5389132dc6320682de3643091121c048ff796b3", + "reference": "e5389132dc6320682de3643091121c048ff796b3", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2018-09-08T13:15:14+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b", + "reference": "3b2b415d4c48fbefca7dc742aa0a0171bfae4e0b", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log-implementation": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T16:33:53+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/0a612e9dfbd2ccce03eb174365f31ecdca930ff6", + "reference": "0a612e9dfbd2ccce03eb174365f31ecdca930ff6", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T16:33:53+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "aea20fef4e92396928b5db175788b90234c0270d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/aea20fef4e92396928b5db175788b90234c0270d", + "reference": "aea20fef4e92396928b5db175788b90234c0270d", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" + }, + "conflict": { + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "psr/container-implementation": "1.0" + }, + "require-dev": { + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T12:28:39+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb", + "reference": "b2e1f19280c09a42dc64c0b72b80fe44dd6e88fb", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2018-07-26T09:06:28+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "d69930fc337d767607267d57c20a7403d0a822a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/d69930fc337d767607267d57c20a7403d0a822a4", + "reference": "d69930fc337d767607267d57c20a7403d0a822a4", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T12:28:39+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "54ba444dddc5bd5708a34bd095ea67c6eb54644d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/54ba444dddc5bd5708a34bd095ea67c6eb54644d", + "reference": "54ba444dddc5bd5708a34bd095ea67c6eb54644d", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2018-10-03T08:46:40+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "1cf7d8e704a9cc4164c92e430f2dfa3e6983661d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/1cf7d8e704a9cc4164c92e430f2dfa3e6983661d", + "reference": "1cf7d8e704a9cc4164c92e430f2dfa3e6983661d", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2018-09-17T17:29:18+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "1e24b0c4a56d55aaf368763a06c6d1c7d3194934" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/1e24b0c4a56d55aaf368763a06c6d1c7d3194934", + "reference": "1e24b0c4a56d55aaf368763a06c6d1c7d3194934", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "95c50420b0baed23852452a7f0c7b527303ed5ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/95c50420b0baed23852452a7f0c7b527303ed5ae", + "reference": "95c50420b0baed23852452a7f0c7b527303ed5ae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/process", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "1dc2977afa7d70f90f3fefbcd84152813558910e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/1dc2977afa7d70f90f3fefbcd84152813558910e", + "reference": "1dc2977afa7d70f90f3fefbcd84152813558910e", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T12:28:39+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "05e52a39de52ba690aebaed462b2bc8a9649f0a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/05e52a39de52ba690aebaed462b2bc8a9649f0a4", + "reference": "05e52a39de52ba690aebaed462b2bc8a9649f0a4", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T12:28:39+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/640b6c27fed4066d64b64d5903a86043f4a4de7f", + "reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T16:33:53+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-01-29T19:49:41+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "phpmd/phpmd": 0 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.0.0" + }, + "platform-dev": [] +} diff --git a/paul b/paul new file mode 100644 index 0000000..f4053e3 --- /dev/null +++ b/paul @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,FFE357F099C6FA798FDA620AFC29061B + +TfyWfEzwfCdPB75tX3E6niZBGvOFpP4det7fNPGw0rfUPhn4lgBDMdL1zXgAZred +Ham1RQ6u0KZiaiGjn111ZP5XA6y8WV46IFaT59UMl1ZPu5AjMjZIAZ9WTJvhIaz2 +pMJhcBAe9M5guWX0qGgiajS+3DvVISxwmgOjFjNIFUjrJKxxD+J2HESf8+uO19NA +jZpxxF47KipaaTLFe4IGX8rf6aaSqaxDOGC8u4T9eyEDwsARe2H6g8Wm4ABnE/cB +kn6KoPupky20UIOZlOTc+R3UDrVK0w1ZcxgQi9Ly8qM+oPRemgvIbUHQWRgeXUaU +4p2hze04yQANwpZiWgz7+j5qU4CFfneLVJc1SNvzx+lPNgzwAihv4AKlJ3dBtpSw +41RyGbisE/RuPcaHGDOXf0g+wA2Bz1ByspQaB05BcqCef+rMvyavgaT2o5rgOVcF +D6AfKCYu0nO3RvCCm9jE19JDHW5oynnw8qiY9spvMkKaFGwXNYtBkvxdrW/xbNfu +VotHxKUcJbxjci2dJ10I7w58p2czlMA2vWtPqXqo7eDgrCLOBFM6CKQea8lsQKvA +uis2QMoWJYAhl20fxB8VxA77Gh5Fp402tj7Qu2/D8bDkZwqD6/ShFDqA6sK83JF+ +2QNfm3hTOmYytVSyl9uCjGJTqchK6O3zoteVihST4CGaIufbLjk6PkjzQc6JSFdG +aPWNBM4whR7LcUJ2LQ4lTcbcChB7d1ox+KRgKQ9FxmG1F9cftjKtfPAn3h2AYk+P +g/BBMmwV5R4Ly580QD0GgNYCYyKtT9Rn0inWh9o+tcX7B98xrghM1FOVBFuyw4P0 +eQrmi6oBXPWB7X5HzedFclpo/SjUinq4mVUfMHEv3vwaJI7XoFSNvd4sboc2IKkA +NbsbL5rk+QPTtCJJohIG4urAJPrpEqOfAQL26YJg+aamefmoiUCF46xb+sMYgPlq +a6P7kGv5iYvKsvVfZr1JCNJGa4f4R3toded0sYpvyodzm+X1Y+VzjgspXT0lh6EH +AR+JZ8w4zPnPaVaeDbkp0dgHFSyFWRl4CQSmQHGthaFAPagwJt2JJYmKEgPZYz7f +65kaMmhSANNUw0rtFfctA6VJqWRbdG1Gyn77nmg69SrwBUc17f+Mtui03FSIAFjg +yYooJxdNMT31wItBcDVEAvcLd/b4Bp2xKsKm7XYj3aWVgBFZO0scAGMqPfJaJy3o +o3dE4AvYzup46GbH3fz3xwDUjCbPSLNdKPLc37Yv5v0SAQaGuQbhwovp0Y4Mvsqt +lE74zywcxCJzp2pCJ9FlSjE+FPyHd+2Y3y3sod1Gs1s3IC8/u3sVOQ4velvVyO2v +Il86j9yglrNQ2vhq6KBedqeukPI71HnYjXSU/H5NLlMyRt/Y5g1F5yfgHmZyioVT +lyrvJCX//hm9K/8NLV1uIczT1Z+Lcpdrm2c8QpsCZseaCD/yVtNmo/LvRD5TH7aT +/QGUbfvkCUl8HVOId/LLZrDscdcDSj9LYcp+KDLm6qfLQX+uqHzXFgI2t8g2k3KR +N9sEFJq1rDX4PDzrUkWXrqW33LneOm+7KeXFHvdEzRnZylgo14ZkdAgKx6smaPuj +-----END RSA PRIVATE KEY----- diff --git a/paul.pub b/paul.pub new file mode 100644 index 0000000..680eaed --- /dev/null +++ b/paul.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4RGhsoezP9fixY7Q+UkiUuKQDEVeOY2B5e15PG6lu90AM9nfvvUYvMu+w4/xB1MNsfBihKGJEcMuau9LiSuQjnym5BQ29ECL3Qm9nJ7BZB3jH7hA9uSep5+mvBchqSMFRMW/TUQFAm7o0/+GDRGKI8LnEGApyKrxIm4UaB/est9sVr9J5t+3HuldrUmxFt0o2oTreBgIrBKuDZ4QNP8G+l8A9sFiPJXnYrTo96J79LN7cx5jKWrJFybBwN6UgUMhTfWOOEoo5O61sepg/i9Jr+mz4/zCP5ai2U/Ea/CL4XZW+iHYnGWfEQ7eJLENILC25XlBfrI5Px3gi/2HV+wMn paul.adams@ADAMS-MBP.local diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..65002f7 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,13 @@ + + + + + ./tests/ + + + + + ./src/ + + + diff --git a/src/Adapter/Adapter.php b/src/Adapter/Adapter.php new file mode 100644 index 0000000..44d83c5 --- /dev/null +++ b/src/Adapter/Adapter.php @@ -0,0 +1,76 @@ +getHeaders(); + + $this->client = new Client([ + 'base_uri' => $baseURI, + 'headers' => $headers, + 'Accept' => 'application/json' + ]); + } + + + /** + * @inheritDoc + */ + public function get(string $uri, array $data = [], array $headers = []): ResponseInterface + { + return $this->request('get', $uri, $data, $headers); + } + + /** + * @inheritDoc + */ + public function post(string $uri, array $data = [], array $headers = []): ResponseInterface + { + return $this->request('post', $uri, $data, $headers); + } + + /** + * @inheritDoc + */ + public function put(string $uri, array $data = [], array $headers = []): ResponseInterface + { + return $this->request('put', $uri, $data, $headers); + } + + /** + * @inheritDoc + */ + public function patch(string $uri, array $data = [], array $headers = []): ResponseInterface + { + return $this->request('patch', $uri, $data, $headers); + } + + /** + * @inheritDoc + */ + public function delete(string $uri, array $data = [], array $headers = []): ResponseInterface + { + return $this->request('delete', $uri, $data, $headers); + } + + public function request(string $method, string $uri, array $data = [], array $headers = []) + { + if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) { + throw new \InvalidArgumentException('Request method must be get, post, put, patch, or delete'); + } + + $response = $this->client->$method($uri, [ + 'headers' => $headers, + ($method === 'get' ? 'query' : 'json') => $data, + ]); + + $this->checkError($response); + + return $response; + } + + private function checkError(ResponseInterface $response) + { + $json = json_decode($response->getBody()); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new JSONException(); + } + + if (isset($json->errors) && count($json->errors) >= 1) { + throw new ResponseException($json->errors[0]->message, $json->errors[0]->code); + } + + if (isset($json->success) && !$json->success) { + throw new ResponseException('Request was unsuccessful.'); + } + } +} diff --git a/src/Adapter/JSONException.php b/src/Adapter/JSONException.php new file mode 100644 index 0000000..e9da7e4 --- /dev/null +++ b/src/Adapter/JSONException.php @@ -0,0 +1,13 @@ +email = $email; + $this->apiKey = $apiKey; + } + + public function getHeaders(): array + { + return [ + 'X-Auth-Email' => $this->email, + 'X-Auth-Key' => $this->apiKey + ]; + } +} diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php new file mode 100644 index 0000000..55cead8 --- /dev/null +++ b/src/Auth/Auth.php @@ -0,0 +1,13 @@ +userServiceKey = $userServiceKey; + } + + public function getHeaders(): array + { + return [ + 'X-Auth-User-Service-Key' => $this->userServiceKey, + ]; + } +} diff --git a/src/Configurations/AccessRules.php b/src/Configurations/AccessRules.php new file mode 100644 index 0000000..17ea57f --- /dev/null +++ b/src/Configurations/AccessRules.php @@ -0,0 +1,28 @@ +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; + } +} diff --git a/src/Configurations/Configurations.php b/src/Configurations/Configurations.php new file mode 100644 index 0000000..ba20907 --- /dev/null +++ b/src/Configurations/Configurations.php @@ -0,0 +1,14 @@ +addConfigurationOption('always_online', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setAlwaysUseHTTPS(bool $active) + { + $this->addConfigurationOption('always_use_https', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setBrowserCacheTTL(int $ttl) + { + $this->addConfigurationOption('browser_cache_ttl', [ + 'value' => $ttl + ]); + } + + public function setBrowserIntegrityCheck(bool $active) + { + $this->addConfigurationOption('browser_check', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setBypassCacheOnCookie(string $value) + { + if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) { + throw new ConfigurationsException('Invalid cookie string.'); + } + + $this->addConfigurationOption('bypass_cache_on_cookie', [ + 'value' => $value + ]); + } + + public function setCacheByDeviceType(bool $active) + { + $this->addConfigurationOption('cache_by_device_type', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setCacheKey(string $value) + { + $this->addConfigurationOption('cache_key', [ + 'value' => $value + ]); + } + + public function setCacheLevel(string $value) + { + if (!in_array($value, ['bypass', 'basic', 'simplified', 'aggressive', 'cache_everything'])) { + throw new ConfigurationsException('Invalid cache level'); + } + + $this->addConfigurationOption('cache_level', [ + 'value' => $value + ]); + } + + public function setCacheOnCookie(string $value) + { + if (preg_match('/^([a-zA-Z0-9\.=|_*-]+)$/i', $value) < 1) { + throw new ConfigurationsException('Invalid cookie string.'); + } + + $this->addConfigurationOption('cache_on_cookie', [ + 'value' => $value + ]); + } + + public function setDisableApps(bool $active) + { + $this->addConfigurationOption('disable_apps', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setDisablePerformance(bool $active) + { + $this->addConfigurationOption('disable_performance', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setDisableSecurity(bool $active) + { + $this->addConfigurationOption('disable_security', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setEdgeCacheTTL(int $value) + { + if ($value > 2419200) { + throw new ConfigurationsException('Edge Cache TTL too high.'); + } + + $this->addConfigurationOption('edge_cache_ttl', [ + 'value' => $value + ]); + } + + public function setEmailObfuscation(bool $active) + { + $this->addConfigurationOption('disable_security', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setForwardingURL(int $statusCode, string $forwardingUrl) + { + if (!in_array($statusCode, ['301', '302'])) { + throw new ConfigurationsException('Status Codes can only be 301 or 302.'); + } + + $this->addConfigurationOption("forwarding_url", [ + 'value' => [ + 'status_code' => $statusCode, + 'url' => $forwardingUrl, + ], + ]); + } + + public function setHostHeaderOverride(bool $active) + { + $this->addConfigurationOption('host_header_override', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setHotlinkProtection(bool $active) + { + $this->addConfigurationOption('hotlink_protection', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setIPGeoLocationHeader(bool $active) + { + $this->addConfigurationOption('ip_geolocation', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setMinification(bool $html, bool $css, bool $javascript) + { + $this->addConfigurationOption('minification', [ + 'html' => $this->getBoolAsOnOrOff($html), + 'css' => $this->getBoolAsOnOrOff($css), + 'js' => $this->getBoolAsOnOrOff($javascript), + ]); + } + + public function setMirage(bool $active) + { + $this->addConfigurationOption('mirage', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setOriginErrorPagePassthru(bool $active) + { + $this->addConfigurationOption('origin_error_page_pass_thru', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setQueryStringSort(bool $active) + { + $this->addConfigurationOption('sort_query_string_for_cache', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setDisableRailgun(bool $active) + { + $this->addConfigurationOption('disable_railgun', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setResolveOverride(bool $value) + { + $this->addConfigurationOption('resolve_override', [ + 'value' => $value + ]); + } + + public function setRespectStrongEtag(bool $active) + { + $this->addConfigurationOption('respect_strong_etag', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setResponseBuffering(bool $active) + { + $this->addConfigurationOption('response_buffering', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setRocketLoader(string $value) + { + if (!in_array($value, ['off', 'manual', 'automatic'])) { + throw new ConfigurationsException('Rocket Loader can only be off, automatic, or manual.'); + } + + $this->addConfigurationOption('rocket_loader', [ + 'value' => $value + ]); + } + + public function setSecurityLevel(string $value) + { + 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.'); + } + + $this->addConfigurationOption('security_level', [ + 'value' => $value + ]); + } + + public function setServerSideExcludes(bool $active) + { + $this->addConfigurationOption('server_side_exclude', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setSmartErrors(bool $active) + { + $this->addConfigurationOption('smart_errors', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setSSL(string $value) + { + if (!in_array($value, ['off', 'flexible', 'full', 'strict', 'origin_pull'])) { + throw new ConfigurationsException('Can only be set to off, flexible, full, strict, origin_pull.'); + } + + $this->addConfigurationOption('ssl', [ + 'value' => $value + ]); + } + + public function setTrueClientIpHeader(bool $active) + { + $this->addConfigurationOption('true_client_ip_header', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setWAF(bool $active) + { + $this->addConfigurationOption('waf', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setAutomatedHTTPSRewrites(bool $active) + { + $this->addConfigurationOption('automatic_https_rewrites', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function setOpportunisticEncryption(bool $active) + { + $this->addConfigurationOption('opportunistic_encryption', [ + 'value' => $this->getBoolAsOnOrOff($active) + ]); + } + + public function getArray(): array + { + return $this->configs; + } + + private function addConfigurationOption(string $setting, array $configuration) + { + $configuration['id'] = $setting; + + array_push($this->configs, $configuration); + } + + private function getBoolAsOnOrOff(bool $value): string + { + return true === $value ? 'on' : 'off'; + } +} diff --git a/src/Configurations/PageRulesTargets.php b/src/Configurations/PageRulesTargets.php new file mode 100644 index 0000000..0c13a4c --- /dev/null +++ b/src/Configurations/PageRulesTargets.php @@ -0,0 +1,32 @@ +targets = [ + [ + 'target' => 'url', + 'constraint' => [ + 'operator' => 'matches', + 'value' => $queryUrl + ] + ] + ]; + } + + public function getArray(): array + { + return $this->targets; + } +} diff --git a/src/Configurations/UARules.php b/src/Configurations/UARules.php new file mode 100644 index 0000000..9acbc29 --- /dev/null +++ b/src/Configurations/UARules.php @@ -0,0 +1,24 @@ +configs[] = ['target' => 'ua', 'value' => $value]; + } + + public function getArray(): array + { + return $this->configs; + } +} diff --git a/src/Configurations/ZoneLockdown.php b/src/Configurations/ZoneLockdown.php new file mode 100644 index 0000000..a530677 --- /dev/null +++ b/src/Configurations/ZoneLockdown.php @@ -0,0 +1,29 @@ +configs[] = ['target' => 'ip', 'value' => $value]; + } + + public function addIPRange(string $value) + { + $this->configs[] = ['target' => 'ip_range', 'value' => $value]; + } + + public function getArray(): array + { + return $this->configs; + } +} diff --git a/src/Endpoints/API.php b/src/Endpoints/API.php new file mode 100644 index 0000000..113075f --- /dev/null +++ b/src/Endpoints/API.php @@ -0,0 +1,15 @@ +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); + $this->body = json_decode($data->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function createRule( + string $zoneID, + string $mode, + Configurations $configuration, + string $notes = null + ): bool { + $options = [ + 'mode' => $mode, + 'configuration' => $configuration->getArray() + ]; + + if ($notes !== null) { + $options['notes'] = $notes; + } + + $query = $this->adapter->post('zones/' . $zoneID . '/firewall/access_rules/rules', $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->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); + + $this->body = json_decode($query->getBody()); + + if (isset($this->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); + + $this->body = json_decode($data->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/CustomHostnames.php b/src/Endpoints/CustomHostnames.php new file mode 100644 index 0000000..4af5c9e --- /dev/null +++ b/src/Endpoints/CustomHostnames.php @@ -0,0 +1,153 @@ +adapter = $adapter; + } + + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param string $hostname + * @param string $sslMethod + * @param string $sslType + * @return \stdClass + */ + public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv'): \stdClass + { + $options = [ + 'hostname' => $hostname, + 'ssl' => [ + 'method' => $sslMethod, + 'type' => $sslType + ] + ]; + + $zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options); + $this->body = json_decode($zone->getBody()); + return $this->body->result; + } + + /** + * @param string $zoneID + * @param string $hostname + * @param string $id + * @param int $page + * @param int $perPage + * @param string $order + * @param string $direction + * @param int $ssl + * @return \stdClass + */ + public function listHostnames( + string $zoneID, + string $hostname = '', + string $hostnameID = '', + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + int $ssl = 0 + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'ssl' => $ssl + ]; + + if (!empty($hostname)) { + $query['hostname'] = $hostname; + } + + if (!empty($hostnameID)) { + $query['id'] = $hostnameID; + } + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $zone = $this->adapter->get('zones/'.$zoneID.'/custom_hostnames', $query); + $this->body = json_decode($zone->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + /** + * @param string $zoneID + * @param string $hostnameID + * @return mixed + */ + public function getHostname(string $zoneID, string $hostnameID) + { + $zone = $this->adapter->get('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID); + $this->body = json_decode($zone->getBody()); + + return $this->body->result; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param string $hostnameID + * @param string $sslMethod + * @param string $sslType + * @return \stdClass + */ + public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = ''): \stdClass + { + $query = []; + + if (!empty($sslMethod)) { + $query['method'] = $sslMethod; + } + + if (!empty($sslType)) { + $query['type'] = $sslType; + } + + $options = [ + 'ssl' => $query + ]; + + $zone = $this->adapter->patch('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID, $options); + $this->body = json_decode($zone->getBody()); + return $this->body->result; + } + + /** + * @param string $zoneID + * @param string $hostnameID + * @return \stdClass + */ + public function deleteHostname(string $zoneID, string $hostnameID): \stdClass + { + $zone = $this->adapter->delete('zones/'.$zoneID.'/custom_hostnames/'.$hostnameID); + $this->body = json_decode($zone->getBody()); + return $this->body; + } +} diff --git a/src/Endpoints/DNS.php b/src/Endpoints/DNS.php new file mode 100644 index 0000000..d06116f --- /dev/null +++ b/src/Endpoints/DNS.php @@ -0,0 +1,147 @@ +adapter = $adapter; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param string $type + * @param string $name + * @param string $content + * @param int $ttl + * @param bool $proxied + * @param string $priority + * @param array $data + * @return bool + */ + public function addRecord( + string $zoneID, + string $type, + string $name, + string $content, + int $ttl = 0, + bool $proxied = true, + string $priority = '', + array $data = [] + ): bool { + $options = [ + 'type' => $type, + 'name' => $name, + 'content' => $content, + 'proxied' => $proxied + ]; + + if ($ttl > 0) { + $options['ttl'] = $ttl; + } + + if (!empty($priority)) { + $options['priority'] = (int)$priority; + } + + if (!empty($data)) { + $options['data'] = $data; + } + + $user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function listRecords( + string $zoneID, + string $type = '', + string $name = '', + string $content = '', + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + string $match = 'all' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'match' => $match + ]; + + if (!empty($type)) { + $query['type'] = $type; + } + + if (!empty($name)) { + $query['name'] = $name; + } + + if (!empty($content)) { + $query['content'] = $content; + } + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $user = $this->adapter->get('zones/' . $zoneID . '/dns_records', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function getRecordDetails(string $zoneID, string $recordID): \stdClass + { + $user = $this->adapter->get('zones/' . $zoneID . '/dns_records/' . $recordID); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function updateRecordDetails(string $zoneID, string $recordID, array $details): \stdClass + { + $response = $this->adapter->put('zones/' . $zoneID . '/dns_records/' . $recordID, $details); + $this->body = json_decode($response->getBody()); + return $this->body; + } + + public function deleteRecord(string $zoneID, string $recordID): bool + { + $user = $this->adapter->delete('zones/' . $zoneID . '/dns_records/' . $recordID); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/EndpointException.php b/src/Endpoints/EndpointException.php new file mode 100644 index 0000000..2855e00 --- /dev/null +++ b/src/Endpoints/EndpointException.php @@ -0,0 +1,13 @@ +adapter = $adapter; + } + + public function listIPs(): \stdClass + { + $ips = $this->adapter->get('ips'); + $this->body = json_decode($ips->getBody()); + + return $this->body->result; + } +} diff --git a/src/Endpoints/PageRules.php b/src/Endpoints/PageRules.php new file mode 100644 index 0000000..3e56007 --- /dev/null +++ b/src/Endpoints/PageRules.php @@ -0,0 +1,161 @@ +adapter = $adapter; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param PageRulesTargets $target + * @param PageRulesActions $actions + * @param bool $active + * @param int|null $priority + * @return bool + */ + public function createPageRule( + string $zoneID, + PageRulesTargets $target, + PageRulesActions $actions, + bool $active = true, + int $priority = null + ): bool { + $options = [ + 'targets' => $target->getArray(), + 'actions' => $actions->getArray() + ]; + + if ($active !== null) { + $options['status'] = $active == true ? 'active' : 'disabled'; + } + + if ($priority !== null) { + $options['priority'] = $priority; + } + + + $query = $this->adapter->post('zones/' . $zoneID . '/pagerules', $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function listPageRules( + string $zoneID, + string $status = null, + string $order = null, + string $direction = null, + string $match = null + ): array { + if ($status === null && !in_array($status, ['active', 'disabled'])) { + throw new EndpointException('Page Rules can only be listed by status of active or disabled.'); + } + + if ($order === null && !in_array($order, ['status', 'priority'])) { + throw new EndpointException('Page Rules can only be ordered by status or priority.'); + } + + if ($direction === null && !in_array($direction, ['asc', 'desc'])) { + throw new EndpointException('Direction of Page Rule ordering can only be asc or desc.'); + } + + if ($match === null && !in_array($match, ['all', 'any'])) { + throw new EndpointException('Match can only be any or all.'); + } + + $query = [ + 'status' => $status, + 'order' => $order, + 'direction' => $direction, + 'match' => $match + ]; + + $user = $this->adapter->get('zones/' . $zoneID . '/pagerules', $query); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function getPageRuleDetails(string $zoneID, string $ruleID): \stdClass + { + $user = $this->adapter->get('zones/' . $zoneID . '/pagerules/' . $ruleID); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function updatePageRule( + string $zoneID, + PageRulesTargets $target = null, + PageRulesActions $actions = null, + bool $active = null, + int $priority = null + ): bool { + $options = []; + + if ($target !== null) { + $options['targets'] = $target->getArray(); + } + + if ($actions !== null) { + $options['actions'] = $actions->getArray(); + } + + if ($active !== null) { + $options['status'] = $active == true ? 'active' : 'disabled'; + } + + if ($priority !== null) { + $options['priority'] = $priority; + } + + + $query = $this->adapter->patch('zones/' . $zoneID . '/pagerules', $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function deletePageRule(string $zoneID, string $ruleID): bool + { + $user = $this->adapter->delete('zones/' . $zoneID . '/pagerules/' . $ruleID); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/Railgun.php b/src/Endpoints/Railgun.php new file mode 100644 index 0000000..8ba3182 --- /dev/null +++ b/src/Endpoints/Railgun.php @@ -0,0 +1,102 @@ +adapter = $adapter; + } + + public function create( + string $name + ): \stdClass { + $query = [ + 'name' => $name, + ]; + + $user = $this->adapter->post('railguns', $query); + $this->body = json_decode($user->getBody()); + + return $this->body; + } + + public function list( + int $page = 1, + int $perPage = 20, + string $direction = '' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage + ]; + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $user = $this->adapter->get('railguns', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function get( + string $railgunID + ): \stdClass { + $user = $this->adapter->get('railguns/' . $railgunID); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function getZones( + string $railgunID + ): \stdClass { + $user = $this->adapter->get('railguns/' . $railgunID . '/zones'); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function update( + string $railgunID, + bool $status + ): \stdClass { + $query = [ + 'enabled' => $status + ]; + + $user = $this->adapter->patch('railguns/' . $railgunID, $query); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function delete( + string $railgunID + ): bool { + $user = $this->adapter->delete('railguns/' . $railgunID); + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/TLS.php b/src/Endpoints/TLS.php new file mode 100644 index 0000000..f539d9a --- /dev/null +++ b/src/Endpoints/TLS.php @@ -0,0 +1,124 @@ +adapter = $adapter; + } + + public function enableTLS13($zoneID) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/tls_1_3', + ['value' => 'on'] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function disableTLS13($zoneID) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/tls_1_3', + ['value' => 'off'] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + + + public function changeMinimumTLSVersion($zoneID, $minimumVersion) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/min_tls_version', + [ + 'value' => $minimumVersion + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function getHTTPSRedirectStatus($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/always_use_https' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function getHTTPSRewritesStatus($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/automatic_https_rewrites' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function updateHTTPSRedirects($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/always_use_https', + [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function updateHTTPSRewrites($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/automatic_https_rewrites', + [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/UARules.php b/src/Endpoints/UARules.php new file mode 100644 index 0000000..8c7bfd9 --- /dev/null +++ b/src/Endpoints/UARules.php @@ -0,0 +1,120 @@ +adapter = $adapter; + } + + public function listRules( + string $zoneID, + int $page = 1, + int $perPage = 20 + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage + ]; + + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function createRule( + string $zoneID, + string $mode, + Configurations $configuration, + string $ruleID = null, + string $description = null + ): bool { + $options = [ + 'mode' => $mode, + 'configurations' => $configuration->getArray() + ]; + + if ($ruleID !== null) { + $options['id'] = $ruleID; + } + + if ($description !== null) { + $options['description'] = $description; + } + + $user = $this->adapter->post('zones/' . $zoneID . '/firewall/ua_rules', $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function getRuleDetails(string $zoneID, string $blockID): \stdClass + { + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/ua_rules/' . $blockID); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function updateRule( + string $zoneID, + string $ruleID, + string $mode, + \Cloudflare\API\Configurations\UARules $configuration, + string $description = null + ): bool { + $options = [ + 'mode' => $mode, + 'id' => $ruleID, + 'configurations' => $configuration->getArray() + ]; + + if ($description !== null) { + $options['description'] = $description; + } + + $user = $this->adapter->put('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID, $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function deleteRule(string $zoneID, string $ruleID): bool + { + $user = $this->adapter->delete('zones/' . $zoneID . '/firewall/ua_rules/' . $ruleID); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/User.php b/src/Endpoints/User.php new file mode 100644 index 0000000..93d3826 --- /dev/null +++ b/src/Endpoints/User.php @@ -0,0 +1,47 @@ +adapter = $adapter; + } + + public function getUserDetails(): \stdClass + { + $user = $this->adapter->get('user'); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function getUserID(): string + { + return $this->getUserDetails()->id; + } + + public function getUserEmail(): string + { + return $this->getUserDetails()->email; + } + + public function updateUserDetails(array $details): \stdClass + { + $response = $this->adapter->patch('user', $details); + $this->body = json_decode($response->getBody()); + return $this->body; + } +} diff --git a/src/Endpoints/WAF.php b/src/Endpoints/WAF.php new file mode 100644 index 0000000..b1e3611 --- /dev/null +++ b/src/Endpoints/WAF.php @@ -0,0 +1,183 @@ +adapter = $adapter; + } + + public function getPackages( + string $zoneID, + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + string $match = 'all' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'match' => $match + ]; + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + + public function getPackageInfo( + string $zoneID, + string $packageID + ): \stdClass { + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function getRules( + string $zoneID, + string $packageID, + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + string $match = 'all' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'match' => $match + ]; + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function getRuleInfo( + string $zoneID, + string $packageID, + string $ruleID + ): \stdClass { + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function updateRule( + string $zoneID, + string $packageID, + string $ruleID, + string $status + ): \stdClass { + $query = [ + 'mode' => $status, + ]; + + $user = $this->adapter->patch( + 'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/rules/' . $ruleID, + $query + ); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function getGroups( + string $zoneID, + string $packageID, + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + string $match = 'all' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'match' => $match + ]; + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $user = $this->adapter->get( + 'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups', + $query + ); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function getGroupInfo( + string $zoneID, + string $packageID, + string $groupID + ): \stdClass { + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } + + public function updateGroup( + string $zoneID, + string $packageID, + string $groupID, + string $status + ): \stdClass { + $query = [ + 'mode' => $status + ]; + + $user = $this->adapter->patch( + 'zones/' . $zoneID . '/firewall/waf/packages/' . $packageID . '/groups/' . $groupID, + $query + ); + $this->body = json_decode($user->getBody()); + + return $this->body->result; + } +} diff --git a/src/Endpoints/ZoneLockdown.php b/src/Endpoints/ZoneLockdown.php new file mode 100644 index 0000000..aeccb25 --- /dev/null +++ b/src/Endpoints/ZoneLockdown.php @@ -0,0 +1,119 @@ +adapter = $adapter; + } + + public function listLockdowns( + string $zoneID, + int $page = 1, + int $perPage = 20 + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage + ]; + + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function createLockdown( + string $zoneID, + array $urls, + \Cloudflare\API\Configurations\ZoneLockdown $configuration, + string $lockdownID = null, + string $description = null + ): bool { + $options = [ + 'urls' => $urls, + 'configurations' => $configuration->getArray() + ]; + + if ($lockdownID !== null) { + $options['id'] = $lockdownID; + } + + if ($description !== null) { + $options['description'] = $description; + } + + $user = $this->adapter->post('zones/' . $zoneID . '/firewall/lockdowns', $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function getLockdownDetails(string $zoneID, string $lockdownID): \stdClass + { + $user = $this->adapter->get('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function updateLockdown( + string $zoneID, + string $lockdownID, + array $urls, + \Cloudflare\API\Configurations\ZoneLockdown $configuration, + string $description = null + ): bool { + $options = [ + 'urls' => $urls, + 'id' => $lockdownID, + 'configurations' => $configuration->getArray() + ]; + + if ($description !== null) { + $options['description'] = $description; + } + + $user = $this->adapter->put('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID, $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function deleteLockdown(string $zoneID, string $lockdownID): bool + { + $user = $this->adapter->delete('zones/' . $zoneID . '/firewall/lockdowns/' . $lockdownID); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Endpoints/ZoneSettings.php b/src/Endpoints/ZoneSettings.php new file mode 100644 index 0000000..7fc9f2f --- /dev/null +++ b/src/Endpoints/ZoneSettings.php @@ -0,0 +1,153 @@ +adapter = $adapter; + } + public function getMinifySetting($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/minify' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function getRocketLoaderSetting($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/rocket_loader' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function getAlwaysOnlineSetting($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/always_online' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function getEmailObfuscationSetting($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/email_obfuscation' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function getHotlinkProtectionSetting($zoneID) { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/hotlink_protection' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result; + } + + return false; + } + public function updateMinifySetting($zoneID, $html, $css, $js) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/minify', [ + 'html' => $html, + 'css' => $css, + 'js' => $js + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function updateRocketLoaderSetting($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/rocket_loader', [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function updateAlwaysOnlineSetting($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/always_online', [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function updateEmailObfuscationSetting($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/email_obfuscation', [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + public function updateHotlinkProtectionSetting($zoneID, $value) { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/hotlink_protection', [ + 'value' => $value + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php new file mode 100644 index 0000000..8595cb6 --- /dev/null +++ b/src/Endpoints/Zones.php @@ -0,0 +1,195 @@ +adapter = $adapter; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $name + * @param bool $jumpStart + * @param string $organizationID + * @return \stdClass + */ + public function addZone(string $name, bool $jumpStart = false, string $organizationID = ''): \stdClass + { + $options = [ + 'name' => $name, + 'jump_start' => $jumpStart + ]; + + if (!empty($organizationID)) { + $options['organization'] = ['id' => $organizationID]; + } + + $user = $this->adapter->post('zones', $options); + $this->body = json_decode($user->getBody()); + return $this->body->result; + } + + public function activationCheck(string $zoneID): bool + { + $user = $this->adapter->put('zones/' . $zoneID . '/activation_check'); + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function listZones( + string $name = '', + string $status = '', + int $page = 1, + int $perPage = 20, + string $order = '', + string $direction = '', + string $match = 'all' + ): \stdClass { + $query = [ + 'page' => $page, + 'per_page' => $perPage, + 'match' => $match + ]; + + if (!empty($name)) { + $query['name'] = $name; + } + + if (!empty($status)) { + $query['status'] = $status; + } + + if (!empty($order)) { + $query['order'] = $order; + } + + if (!empty($direction)) { + $query['direction'] = $direction; + } + + $user = $this->adapter->get('zones', $query); + $this->body = json_decode($user->getBody()); + + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + } + + public function getZoneID(string $name = ''): string + { + $zones = $this->listZones($name); + + if (count($zones->result) < 1) { + throw new EndpointException('Could not find zones with specified name.'); + } + + return $zones->result[0]->id; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param string $since + * @param string $until + * @param bool $continuous + * @return \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' => var_export($continuous, true)]); + + $this->body = $response->getBody(); + + return json_decode($this->body)->result; + } + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param bool $enable + * @return bool + */ + public function changeDevelopmentMode(string $zoneID, bool $enable = false): bool + { + $response = $this->adapter->patch('zones/' . $zoneID . '/settings/development_mode', ['value' => $enable ? 'on' : 'off']); + + $this->body = json_decode($response->getBody()); + + if ($this->body->success) { + return true; + } + + return false; + } + + + /** + * Purge Everything + * @param string $zoneID + * @return bool + */ + public function cachePurgeEverything(string $zoneID): bool + { + $user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', ['purge_everything' => true]); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + public function cachePurge(string $zoneID, array $files = null, array $tags = null, array $hosts = null): bool + { + if ($files === null && $tags === null && $hosts === null) { + throw new EndpointException('No files, tags or hosts to purge.'); + } + + $options = []; + if (!is_null($files)) { + $options['files'] = $files; + } + + if (!is_null($tags)) { + $options['tags'] = $tags; + } + + if (!is_null($hosts)) { + $options['hosts'] = $hosts; + } + + $user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', $options); + + $this->body = json_decode($user->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/src/Traits/BodyAccessorTrait.php b/src/Traits/BodyAccessorTrait.php new file mode 100644 index 0000000..add13ad --- /dev/null +++ b/src/Traits/BodyAccessorTrait.php @@ -0,0 +1,13 @@ +body; + } +} diff --git a/tests/Adapter/GuzzleTest.php b/tests/Adapter/GuzzleTest.php new file mode 100644 index 0000000..505ed72 --- /dev/null +++ b/tests/Adapter/GuzzleTest.php @@ -0,0 +1,136 @@ +getMockBuilder(\Cloudflare\API\Auth\Auth::class) + ->setMethods(['getHeaders']) + ->getMock(); + + $auth->method('getHeaders') + ->willReturn(['X-Testing' => 'Test']); + + $this->client = new \Cloudflare\API\Adapter\Guzzle($auth, 'https://httpbin.org/'); + } + + public function testGet() + { + $response = $this->client->get('https://httpbin.org/get'); + + $headers = $response->getHeaders(); + $this->assertEquals('application/json', $headers['Content-Type'][0]); + + $body = json_decode($response->getBody()); + $this->assertEquals('Test', $body->headers->{'X-Testing'}); + + $response = $this->client->get('https://httpbin.org/get', [], ['X-Another-Test' => 'Test2']); + $body = json_decode($response->getBody()); + $this->assertEquals('Test2', $body->headers->{'X-Another-Test'}); + } + + public function testPost() + { + $response = $this->client->post('https://httpbin.org/post', ['X-Post-Test' => 'Testing a POST request.']); + + $headers = $response->getHeaders(); + $this->assertEquals('application/json', $headers['Content-Type'][0]); + + $body = json_decode($response->getBody()); + $this->assertEquals('Testing a POST request.', $body->json->{'X-Post-Test'}); + } + + public function testPut() + { + $response = $this->client->put('https://httpbin.org/put', ['X-Put-Test' => 'Testing a PUT request.']); + + $headers = $response->getHeaders(); + $this->assertEquals('application/json', $headers['Content-Type'][0]); + + $body = json_decode($response->getBody()); + $this->assertEquals('Testing a PUT request.', $body->json->{'X-Put-Test'}); + } + + public function testPatch() + { + $response = $this->client->patch( + 'https://httpbin.org/patch', + ['X-Patch-Test' => 'Testing a PATCH request.'] + ); + + $headers = $response->getHeaders(); + $this->assertEquals('application/json', $headers['Content-Type'][0]); + + $body = json_decode($response->getBody()); + $this->assertEquals('Testing a PATCH request.', $body->json->{'X-Patch-Test'}); + } + + public function testDelete() + { + $response = $this->client->delete( + 'https://httpbin.org/delete', + ['X-Delete-Test' => 'Testing a DELETE request.'] + ); + + $headers = $response->getHeaders(); + $this->assertEquals('application/json', $headers['Content-Type'][0]); + + $body = json_decode($response->getBody()); + $this->assertEquals('Testing a DELETE request.', $body->json->{'X-Delete-Test'}); + } + + public function testErrors() + { + $class = new ReflectionClass(\Cloudflare\API\Adapter\Guzzle::class); + $method = $class->getMethod('checkError'); + $method->setAccessible(true); + + $body = + '{ + "result": null, + "success": false, + "errors": [{"code":1003,"message":"Invalid or missing zone id."}], + "messages": [] + }' + ; + $response = new Response(200, [], $body); + + $this->expectException(\Cloudflare\API\Adapter\ResponseException::class); + $method->invokeArgs($this->client, [$response]); + + $body = + '{ + "result": null, + "success": false, + "errors": [], + "messages": [] + }' + ; + $response = new Response(200, [], $body); + + $this->expectException(\Cloudflare\API\Adapter\ResponseException::class); + $method->invokeArgs($this->client, [$response]); + + $body = 'this isnt json.'; + $response = new Response(200, [], $body); + + $this->expectException(\Cloudflare\API\Adapter\JSONException::class); + $method->invokeArgs($this->client, [$response]); + } + + public function testNotFound() + { + $this->expectException(\GuzzleHttp\Exception\RequestException::class); + $this->client->get('https://httpbin.org/status/404'); + } +} diff --git a/tests/Auth/APIKeyTest.php b/tests/Auth/APIKeyTest.php new file mode 100644 index 0000000..10a788b --- /dev/null +++ b/tests/Auth/APIKeyTest.php @@ -0,0 +1,23 @@ +getHeaders(); + + $this->assertArrayHasKey('X-Auth-Key', $headers); + $this->assertArrayHasKey('X-Auth-Email', $headers); + + $this->assertEquals('example@example.com', $headers['X-Auth-Email']); + $this->assertEquals('1234567893feefc5f0q5000bfo0c38d90bbeb', $headers['X-Auth-Key']); + + $this->assertCount(2, $headers); + } +} diff --git a/tests/Auth/NoneTest.php b/tests/Auth/NoneTest.php new file mode 100644 index 0000000..7e46b42 --- /dev/null +++ b/tests/Auth/NoneTest.php @@ -0,0 +1,18 @@ +getHeaders(); + + $this->assertEquals([], $headers); + } +} diff --git a/tests/Auth/UserServiceKeyTest.php b/tests/Auth/UserServiceKeyTest.php new file mode 100644 index 0000000..53e29b3 --- /dev/null +++ b/tests/Auth/UserServiceKeyTest.php @@ -0,0 +1,24 @@ +getHeaders(); + + $this->assertArrayHasKey('X-Auth-User-Service-Key', $headers); + + $this->assertEquals( + 'v1.0-e24fd090c02efcfecb4de8f4ff246fd5c75b48946fdf0ce26c59f91d0d90797b-cfa33fe60e8e34073c149323454383fc9005d25c9b4c502c2f063457ef65322eade065975001a0b4b4c591c5e1bd36a6e8f7e2d4fa8a9ec01c64c041e99530c2-07b9efe0acd78c82c8d9c690aacb8656d81c369246d7f996a205fe3c18e9254a', + $headers['X-Auth-User-Service-Key'] + ); + + $this->assertCount(1, $headers); + } +} diff --git a/tests/Configurations/ConfigurationsUARulesTest.php b/tests/Configurations/ConfigurationsUARulesTest.php new file mode 100644 index 0000000..bd6d45b --- /dev/null +++ b/tests/Configurations/ConfigurationsUARulesTest.php @@ -0,0 +1,27 @@ +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(); + $this->assertCount(1, $array); + + $this->assertArrayHasKey('target', $array[0]); + $this->assertEquals('ua', $array[0]['target']); + $this->assertArrayHasKey('value', $array[0]); + $this->assertEquals( + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4', + $array[0]['value'] + ); + } +} diff --git a/tests/Configurations/ConfigurationsZoneLockdownTest.php b/tests/Configurations/ConfigurationsZoneLockdownTest.php new file mode 100644 index 0000000..7614042 --- /dev/null +++ b/tests/Configurations/ConfigurationsZoneLockdownTest.php @@ -0,0 +1,34 @@ +addIP('1.2.3.4'); + + $array = $configuration->getArray(); + $this->assertCount(1, $array); + + $this->assertArrayHasKey('target', $array[0]); + $this->assertEquals('ip', $array[0]['target']); + $this->assertArrayHasKey('value', $array[0]); + $this->assertEquals('1.2.3.4', $array[0]['value']); + + $configuration->addIPRange('1.2.3.4/24'); + + $array = $configuration->getArray(); + $this->assertCount(2, $array); + + $this->assertArrayHasKey('target', $array[1]); + $this->assertEquals('ip_range', $array[1]['target']); + $this->assertArrayHasKey('value', $array[1]); + $this->assertEquals('1.2.3.4/24', $array[1]['value']); + } +} diff --git a/tests/Configurations/PageRulesActionTest.php b/tests/Configurations/PageRulesActionTest.php new file mode 100644 index 0000000..cc0f871 --- /dev/null +++ b/tests/Configurations/PageRulesActionTest.php @@ -0,0 +1,21 @@ +setForwardingURL($statusCode, $forwardingURL); + $configuration = $actions->getArray(); + + $this->assertCount(1, $configuration); + $this->assertEquals($identifier, $configuration[0]['id']); + $this->assertEquals($statusCode, $configuration[0]['value']['status_code']); + $this->assertEquals($forwardingURL, $configuration[0]['value']['url']); + } +} diff --git a/tests/Configurations/PageRulesTargetTest.php b/tests/Configurations/PageRulesTargetTest.php new file mode 100644 index 0000000..d322c5e --- /dev/null +++ b/tests/Configurations/PageRulesTargetTest.php @@ -0,0 +1,22 @@ +getArray(); + + $this->assertCount(1, $array); + $this->assertEquals('junade.com/*', $array[0]['constraint']['value']); + $this->assertEquals('matches', $array[0]['constraint']['operator']); + } +} diff --git a/tests/Endpoints/AccessRulesTest.php b/tests/Endpoints/AccessRulesTest.php new file mode 100644 index 0000000..fbe4bd4 --- /dev/null +++ b/tests/Endpoints/AccessRulesTest.php @@ -0,0 +1,112 @@ +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' + ]) + ); + + $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); + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $zones->getBody()->result[0]->id); + } + + 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([ + 'mode' => 'challenge', + 'configuration' => $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' + ); + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $rules->getBody()->result->id); + } + + 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([ + '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' + ); + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $rules->getBody()->result->id); + } + + 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([ + 'cascade' => 'none' + ]) + ); + + $rules = new \Cloudflare\API\Endpoints\AccessRules($mock); + $rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '92f17202ed8bd63d69a66b86a49a8f6b'); + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $rules->getBody()->result->id); + } +} diff --git a/tests/Endpoints/CustomHostnamesTest.php b/tests/Endpoints/CustomHostnamesTest.php new file mode 100644 index 0000000..faa247f --- /dev/null +++ b/tests/Endpoints/CustomHostnamesTest.php @@ -0,0 +1,138 @@ +getPsr7JsonResponseForFixture('Endpoints/createCustomHostname.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames'), + $this->equalTo([ + 'hostname' => 'app.example.com', + 'ssl' => [ + 'method' => 'http', + 'type' => 'dv' + ] + ]) + ); + + $hostname = new CustomHostnames($mock); + $hostname->addHostname('023e105f4ecef8ad9ca31a8372d0c353', 'app.example.com', 'http', 'dv'); + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $hostname->getBody()->result->id); + } + + public function testListHostnames() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listHostnames.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames'), + $this->equalTo([ + 'hostname' => 'app.example.com', + 'id' => '0d89c70d-ad9f-4843-b99f-6cc0252067e9', + 'page' => 1, + 'per_page' => 20, + 'order' => 'ssl', + 'direction' => 'desc', + 'ssl' => 0 + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock); + $result = $zones->listHostnames('023e105f4ecef8ad9ca31a8372d0c353', 'app.example.com', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 1, 20, 'ssl', 'desc', 0); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $zones->getBody()->result[0]->id); + } + + public function testGetHostname() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getHostname.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9') + ); + + $zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock); + $result = $zones->getHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', '0d89c70d-ad9f-4843-b99f-6cc0252067e9'); + + $this->assertObjectHasAttribute('id', $result); + $this->assertObjectHasAttribute('hostname', $result); + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $zones->getBody()->result->id); + } + + public function testUpdateHostname() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('patch')->willReturn($response); + + $mock->expects($this->once()) + ->method('patch') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9'), + $this->equalTo([ + 'ssl' => [ + 'method' => 'http', + 'type' => 'dv' + ] + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock); + $result = $zones->updateHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 'http', 'dv'); + + $this->assertObjectHasAttribute('id', $result); + $this->assertObjectHasAttribute('hostname', $result); + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $zones->getBody()->result->id); + } + + public function testDeleteHostname() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteHostname.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/0d89c70d-ad9f-4843-b99f-6cc0252067e9') + ); + + $zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock); + $result = $zones->deleteHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9'); + + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $result->id); + $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $zones->getBody()->id); + } +} diff --git a/tests/Endpoints/DNSTest.php b/tests/Endpoints/DNSTest.php new file mode 100644 index 0000000..11c21fa --- /dev/null +++ b/tests/Endpoints/DNSTest.php @@ -0,0 +1,121 @@ +getPsr7JsonResponseForFixture('Endpoints/addRecord.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/dns_records'), + $this->equalTo([ + 'type' => 'A', + 'name' => 'example.com', + 'content' => '127.0.0.1', + 'ttl' => 120, + 'proxied' => false + ]) + ); + + $dns = new \Cloudflare\API\Endpoints\DNS($mock); + $dns->addRecord('023e105f4ecef8ad9ca31a8372d0c353', 'A', 'example.com', '127.0.0.1', '120', false); + } + + public function testListRecords() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listRecords.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/dns_records'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'type' => 'A', + 'name' => 'example.com', + 'content' => '127.0.0.1', + 'order' => 'type', + 'direction' => 'desc', + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\DNS($mock); + $result = $zones->listRecords('023e105f4ecef8ad9ca31a8372d0c353', 'A', 'example.com', '127.0.0.1', 1, 20, 'type', 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zones->getBody()->result[0]->id); + } + + public function testGetDNSRecordDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getDNSRecordDetails.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/dns_records/372e67954025e0ba6aaa6d586b9e0b59') + ); + + $dns = new \Cloudflare\API\Endpoints\DNS($mock); + $result = $dns->getRecordDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $dns->getBody()->result->id); + } + + public function testUpdateDNSRecord() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateDNSRecord.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('put')->willReturn($response); + + $details = [ + 'type' => 'A', + 'name' => 'example.com', + 'content' => '1.2.3.4', + 'ttl' => 120, + 'proxied' => false, + ]; + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records/372e67954025e0ba6aaa6d586b9e0b59'), + $this->equalTo($details) + ); + + $dns = new \Cloudflare\API\Endpoints\DNS($mock); + $result = $dns->updateRecordDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', $details); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result->id); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $dns->getBody()->result->id); + + foreach ($details as $property => $value) { + $this->assertEquals($result->result->{ $property }, $value); + } + } +} diff --git a/tests/Endpoints/IPsTest.php b/tests/Endpoints/IPsTest.php new file mode 100644 index 0000000..1f92804 --- /dev/null +++ b/tests/Endpoints/IPsTest.php @@ -0,0 +1,31 @@ +getPsr7JsonResponseForFixture('Endpoints/listIPs.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('ips') + ); + + $ipsMock = new \Cloudflare\API\Endpoints\IPs($mock); + $ips = $ipsMock->listIPs(); + $this->assertObjectHasAttribute('ipv4_cidrs', $ips); + $this->assertObjectHasAttribute('ipv6_cidrs', $ips); + $this->assertObjectHasAttribute('ipv4_cidrs', $ipsMock->getBody()->result); + $this->assertObjectHasAttribute('ipv6_cidrs', $ipsMock->getBody()->result); + } +} diff --git a/tests/Endpoints/PageRulesTest.php b/tests/Endpoints/PageRulesTest.php new file mode 100644 index 0000000..f2813fd --- /dev/null +++ b/tests/Endpoints/PageRulesTest.php @@ -0,0 +1,132 @@ +setAlwaysOnline(true); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.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/pagerules'), + $this->equalTo([ + 'targets' => $target->getArray(), + 'actions' => $action->getArray(), + 'status' => 'active', + 'priority' => 1 + ]) + ); + + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); + + $this->assertTrue($result); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $pageRules->getBody()->result->id); + } + + public function testListPageRules() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listPageRules.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/pagerules'), + $this->equalTo([ + 'status' => 'active', + 'order' => 'status', + 'direction' => 'desc', + 'match' => 'all' + ]) + ); + + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $pageRules->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all'); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $pageRules->getBody()->result[0]->id); + } + + public function testGetPageRuleDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getPageRuleDetails.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/pagerules/9a7806061c88ada191ed06f989cc3dac') + ); + + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $pageRules->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $pageRules->getBody()->result->id); + } + + public function testUpdatePageRule() + { + $target = new \Cloudflare\API\Configurations\PageRulesTargets('*example.com/images/*'); + $action = new \Cloudflare\API\Configurations\PageRulesActions(); + $action->setAlwaysOnline(true); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePageRule.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/pagerules'), + $this->equalTo([ + 'targets' => $target->getArray(), + 'actions' => $action->getArray(), + 'status' => 'active', + 'priority' => 1 + ]) + ); + + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); + + $this->assertTrue($result); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $pageRules->getBody()->result->id); + } + + public function testDeletePageRule() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deletePageRule.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/pagerules/9a7806061c88ada191ed06f989cc3dac') + ); + + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); + + $this->assertTrue($result); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $pageRules->getBody()->result->id); + } +} diff --git a/tests/Endpoints/RailgunTest.php b/tests/Endpoints/RailgunTest.php new file mode 100644 index 0000000..15e210b --- /dev/null +++ b/tests/Endpoints/RailgunTest.php @@ -0,0 +1,149 @@ + 'My Railgun', + ]; + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createRailgun.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('railguns'), + $this->equalTo(['name' => $details['name']]) + ); + + $railgun = new \Cloudflare\API\Endpoints\Railgun($mock); + $result = $railgun->create($details['name']); + + $this->assertObjectHasAttribute('result', $result); + + foreach ($details as $property => $value) { + $this->assertEquals($result->result->{ $property }, $value); + } + $this->assertEquals('e928d310693a83094309acf9ead50448', $railgun->getBody()->result->id); + } + + public function testlist() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listRailguns.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('railguns'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'direction' => 'desc' + ]) + ); + + $railgun = new \Cloudflare\API\Endpoints\Railgun($mock); + $result = $railgun->list(1, 20, 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + $this->assertEquals('e928d310693a83094309acf9ead50448', $railgun->getBody()->result[0]->id); + } + + public function testget() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getRailgun.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('railguns/e928d310693a83094309acf9ead50448') + ); + + $railgun = new \Cloudflare\API\Endpoints\Railgun($mock); + $result = $railgun->get('e928d310693a83094309acf9ead50448'); + + $this->assertEquals('e928d310693a83094309acf9ead50448', $result->id); + $this->assertEquals('e928d310693a83094309acf9ead50448', $railgun->getBody()->result->id); + } + + public function testgetZones() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listRailgunZones.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('railguns/e928d310693a83094309acf9ead50448/zones') + ); + + $railgun = new \Cloudflare\API\Endpoints\Railgun($mock); + $result = $railgun->getZones('e928d310693a83094309acf9ead50448'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $railgun->getBody()->result[0]->id); + } + + public function testupdate() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateRailgun.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('patch')->willReturn($response); + + $details = [ + 'enabled' => true, + ]; + + $mock->expects($this->once()) + ->method('patch') + ->with( + $this->equalTo('railguns/e928d310693a83094309acf9ead50448'), + $this->equalTo($details) + ); + + $waf = new \Cloudflare\API\Endpoints\Railgun($mock); + $result = $waf->update('e928d310693a83094309acf9ead50448', true); + + $this->assertEquals('e928d310693a83094309acf9ead50448', $result->id); + $this->assertEquals('e928d310693a83094309acf9ead50448', $waf->getBody()->result->id); + } + + public function testdelete() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRailgun.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('railguns/e928d310693a83094309acf9ead50448') + ); + + $waf = new \Cloudflare\API\Endpoints\Railgun($mock); + $waf->delete('e928d310693a83094309acf9ead50448'); + $this->assertEquals('e928d310693a83094309acf9ead50448', $waf->getBody()->result->id); + } +} diff --git a/tests/Endpoints/TLSTest.php b/tests/Endpoints/TLSTest.php new file mode 100644 index 0000000..d17aabb --- /dev/null +++ b/tests/Endpoints/TLSTest.php @@ -0,0 +1,71 @@ +getPsr7JsonResponseForFixture('Endpoints/enableTLS13.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/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_1_3'), + $this->equalTo(['value' => 'on']) + ); + + $zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); + $result = $zoneTLSSettings->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true); + + $this->assertTrue($result); + } + + public function testDisableTLS13() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/disableTLS13.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/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_1_3'), + $this->equalTo(['value' => 'off']) + ); + + $zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); + $result = $zoneTLSSettings->disableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true); + + $this->assertTrue($result); + } + + public function testChangeMinimimTLSVersion() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/changeMinimumTLSVersion.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/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/min_tls_version'), + $this->equalTo(['value' => '1.1']) + ); + + $zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); + $result = $zoneTLSSettings->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1'); + + $this->assertTrue($result); + } +} diff --git a/tests/Endpoints/UARulesTest.php b/tests/Endpoints/UARulesTest.php new file mode 100644 index 0000000..fec94b5 --- /dev/null +++ b/tests/Endpoints/UARulesTest.php @@ -0,0 +1,142 @@ +getPsr7JsonResponseForFixture('Endpoints/listRules.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/ua_rules'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20 + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\UARules($mock); + $result = $zones->listRules('023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zones->getBody()->result[0]->id); + } + + public function testCreateRule() + { + $config = new \Cloudflare\API\Configurations\UARules(); + $config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createRule.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/ua_rules'), + $this->equalTo([ + 'mode' => 'js_challenge', + 'id' => '372e67954025e0ba6aaa6d586b9e0b59', + 'description' => 'Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack', + 'configurations' => $config->getArray(), + ]) + ); + + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->createRule( + '023e105f4ecef8ad9ca31a8372d0c353', + 'js_challenge', + $config, + '372e67954025e0ba6aaa6d586b9e0b59', + 'Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack' + ); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $rules->getBody()->result->id); + } + + public function getRuleDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getRuleDetails.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/ua_rules/372e67954025e0ba6aaa6d586b9e0b59') + ); + + $lockdown = new \Cloudflare\API\Endpoints\UARules($mock); + $result = $lockdown->getRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $lockdown->getBody()->result->id); + } + + public function testUpdateRule() + { + $config = new \Cloudflare\API\Configurations\UARules(); + $config->addUA('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateRule.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('put')->willReturn($response); + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules/372e67954025e0ba6aaa6d586b9e0b59'), + $this->equalTo([ + 'mode' => 'js_challenge', + 'id' => '372e67954025e0ba6aaa6d586b9e0b59', + 'description' => 'Restrict access to these endpoints to requests from a known IP address', + 'configurations' => $config->getArray(), + ]) + ); + + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->updateRule( + '023e105f4ecef8ad9ca31a8372d0c353', + '372e67954025e0ba6aaa6d586b9e0b59', + 'js_challenge', + $config, + 'Restrict access to these endpoints to requests from a known IP address' + ); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $rules->getBody()->result->id); + } + + public function testDeleteRule() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRule.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/ua_rules/372e67954025e0ba6aaa6d586b9e0b59') + ); + + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $rules->getBody()->result->id); + } +} diff --git a/tests/Endpoints/UserTest.php b/tests/Endpoints/UserTest.php new file mode 100644 index 0000000..07dc424 --- /dev/null +++ b/tests/Endpoints/UserTest.php @@ -0,0 +1,68 @@ +getPsr7JsonResponseForFixture('Endpoints/getUserDetails.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $user = new \Cloudflare\API\Endpoints\User($mock); + $details = $user->getUserDetails(); + + $this->assertObjectHasAttribute('id', $details); + $this->assertEquals('7c5dae5552338874e5053f2534d2767a', $details->id); + $this->assertObjectHasAttribute('email', $details); + $this->assertEquals('user@example.com', $details->email); + $this->assertEquals('7c5dae5552338874e5053f2534d2767a', $user->getBody()->result->id); + } + + public function testGetUserID() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getUserId.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $user = new \Cloudflare\API\Endpoints\User($mock); + $this->assertEquals('7c5dae5552338874e5053f2534d2767a', $user->getUserID()); + $this->assertEquals('7c5dae5552338874e5053f2534d2767a', $user->getBody()->result->id); + } + + public function testGetUserEmail() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getUserEmail.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once())->method('get'); + + $user = new \Cloudflare\API\Endpoints\User($mock); + $this->assertEquals('user@example.com', $user->getUserEmail()); + $this->assertEquals('user@example.com', $user->getBody()->result->email); + } + + public function testUpdateUserDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateUserDetails.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('patch')->willReturn($response); + + $mock->expects($this->once()) + ->method('patch') + ->with($this->equalTo('user'), $this->equalTo(['email' => 'user2@example.com'])); + + $user = new \Cloudflare\API\Endpoints\User($mock); + $user->updateUserDetails(['email' => 'user2@example.com']); + $this->assertEquals('7c5dae5552338874e5053f2534d2767a', $user->getBody()->result->id); + } +} diff --git a/tests/Endpoints/WAFTest.php b/tests/Endpoints/WAFTest.php new file mode 100644 index 0000000..f0c97aa --- /dev/null +++ b/tests/Endpoints/WAFTest.php @@ -0,0 +1,221 @@ +getPsr7JsonResponseForFixture('Endpoints/listPackages.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'order' => 'status', + 'direction' => 'desc' + ]) + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getPackages('023e105f4ecef8ad9ca31a8372d0c353', 1, 20, 'status', 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $waf->getBody()->result[0]->id); + } + + public function testgetPackageInfo() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageInfo.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b') + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getPackageInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b'); + + $this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $result->id); + $this->assertEquals('a25a9a7e9c00afc1fb2e0245519d725b', $waf->getBody()->result->id); + } + + public function testgetRules() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listPackageRules.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'order' => 'status', + 'direction' => 'desc' + ]) + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getRules('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 1, 20, 'status', 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('92f17202ed8bd63d69a66b86a49a8f6b', $waf->getBody()->result[0]->id); + } + + public function testgetRuleInfo() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageRuleInfo.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023') + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getRuleInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'f939de3be84e66e757adcdcb87908023'); + + $this->assertEquals('f939de3be84e66e757adcdcb87908023', $result->id); + $this->assertEquals('f939de3be84e66e757adcdcb87908023', $waf->getBody()->result->id); + } + + public function testupdateRule() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePackageRule.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('patch')->willReturn($response); + + $details = [ + 'mode' => 'on', + ]; + + $mock->expects($this->once()) + ->method('patch') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/rules/f939de3be84e66e757adcdcb87908023'), + $this->equalTo($details) + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->updateRule('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'f939de3be84e66e757adcdcb87908023', 'on'); + + $this->assertEquals('f939de3be84e66e757adcdcb87908023', $result->id); + + foreach ($details as $property => $value) { + $this->assertEquals($result->{ $property }, $value); + } + $this->assertEquals('f939de3be84e66e757adcdcb87908023', $waf->getBody()->result->id); + } + + public function getGroups() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listPackageGroups.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'order' => 'status', + 'direction' => 'desc' + ]) + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getGroups('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 1, 20, 'status', 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $waf->getBody()->result[0]->id); + } + + public function testgetGroupInfo() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getPackageGroupInfo.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5') + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->getGroupInfo('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'de677e5818985db1285d0e80225f06e5'); + + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->id); + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $waf->getBody()->result->id); + } + + public function testupdateGroup() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePackageGroup.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('patch')->willReturn($response); + + $details = [ + 'mode' => 'off', + ]; + + $mock->expects($this->once()) + ->method('patch') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/waf/packages/a25a9a7e9c00afc1fb2e0245519d725b/groups/de677e5818985db1285d0e80225f06e5'), + $this->equalTo($details) + ); + + $waf = new \Cloudflare\API\Endpoints\WAF($mock); + $result = $waf->updateGroup('023e105f4ecef8ad9ca31a8372d0c353', 'a25a9a7e9c00afc1fb2e0245519d725b', 'de677e5818985db1285d0e80225f06e5', 'off'); + + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $result->id); + + foreach ($details as $property => $value) { + $this->assertEquals($result->{ $property }, $value); + } + $this->assertEquals('de677e5818985db1285d0e80225f06e5', $waf->getBody()->result->id); + } +} diff --git a/tests/Endpoints/ZoneLockdownTest.php b/tests/Endpoints/ZoneLockdownTest.php new file mode 100644 index 0000000..2af55ac --- /dev/null +++ b/tests/Endpoints/ZoneLockdownTest.php @@ -0,0 +1,145 @@ +getPsr7JsonResponseForFixture('Endpoints/listLockdowns.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/lockdowns'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $result = $zones->listLockdowns('023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zones->getBody()->result[0]->id); + } + + public function testAddLockdown() + { + $config = new \Cloudflare\API\Configurations\ZoneLockdown(); + $config->addIP('1.2.3.4'); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/addLockdown.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/lockdowns'), + $this->equalTo([ + 'urls' => ['api.mysite.com/some/endpoint*'], + 'id' => '372e67954025e0ba6aaa6d586b9e0b59', + 'description' => 'Restrict access to these endpoints to requests from a known IP address', + 'configurations' => $config->getArray(), + ]) + ); + + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->createLockdown( + '023e105f4ecef8ad9ca31a8372d0c353', + ['api.mysite.com/some/endpoint*'], + $config, + '372e67954025e0ba6aaa6d586b9e0b59', + 'Restrict access to these endpoints to requests from a known IP address' + ); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zoneLockdown->getBody()->result->id); + } + + public function testGetRecordDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getRecordDetails.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/lockdowns/372e67954025e0ba6aaa6d586b9e0b59') + ); + + $lockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $result = $lockdown->getLockdownDetails('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $result->id); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $lockdown->getBody()->result->id); + } + + public function testUpdateLockdown() + { + $config = new \Cloudflare\API\Configurations\ZoneLockdown(); + $config->addIP('1.2.3.4'); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateLockdown.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('put')->willReturn($response); + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/lockdowns/372e67954025e0ba6aaa6d586b9e0b59'), + $this->equalTo([ + 'urls' => ['api.mysite.com/some/endpoint*'], + 'id' => '372e67954025e0ba6aaa6d586b9e0b59', + 'description' => 'Restrict access to these endpoints to requests from a known IP address', + 'configurations' => $config->getArray(), + ]) + ); + + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->updateLockdown( + '023e105f4ecef8ad9ca31a8372d0c353', + '372e67954025e0ba6aaa6d586b9e0b59', + ['api.mysite.com/some/endpoint*'], + $config, + 'Restrict access to these endpoints to requests from a known IP address' + ); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zoneLockdown->getBody()->result->id); + } + + public function testDeleteLockdown() + { + $config = new \Cloudflare\API\Configurations\ZoneLockdown(); + $config->addIP('1.2.3.4'); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteLockdown.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/lockdowns/372e67954025e0ba6aaa6d586b9e0b59') + ); + + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + $this->assertEquals('372e67954025e0ba6aaa6d586b9e0b59', $zoneLockdown->getBody()->result->id); + } +} diff --git a/tests/Endpoints/ZonesTest.php b/tests/Endpoints/ZonesTest.php new file mode 100644 index 0000000..0bda651 --- /dev/null +++ b/tests/Endpoints/ZonesTest.php @@ -0,0 +1,246 @@ +getPsr7JsonResponseForFixture('Endpoints/addZone.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'), + $this->equalTo(['name' => 'example.com', 'jump_start' => false]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->addZone('example.com'); + + $this->assertObjectHasAttribute('id', $result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->id); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createPageRule.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'), + $this->equalTo([ + 'name' => 'example.com', + 'jump_start' => true, + 'organization' => ['id' => '01a7362d577a6c3019a474fd6f485823'] + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $zones->addZone('example.com', true, '01a7362d577a6c3019a474fd6f485823'); + $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $zones->getBody()->result->id); + } + + public function testActivationTest() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/activationTest.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('put')->willReturn($response); + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/activation_check') + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->activationCheck('c2547eb745079dac9320b638f5e225cf483cc5cfdda41'); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } + + public function testListZones() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listZones.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'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'name' => 'example.com', + 'status' => 'active', + 'order' => 'status', + 'direction' => 'desc', + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->listZones('example.com', 'active', 1, 20, 'status', 'desc'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result[0]->id); + } + + public function testGetZoneID() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getZoneId.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'), + $this->equalTo([ + 'page' => 1, + 'per_page' => 20, + 'match' => 'all', + 'name' => 'example.com', + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->getZoneID('example.com'); + + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result[0]->id); + } + + public function testGetAnalyticsDashboard() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getAnalyticsDashboard.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/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/analytics/dashboard'), + $this->equalTo(['since' => '-10080', 'until' => '0', 'continuous' => var_export(true, true)]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $analytics = $zones->getAnalyticsDashboard('c2547eb745079dac9320b638f5e225cf483cc5cfdda41'); + + $this->assertObjectHasAttribute('since', $analytics->totals); + $this->assertObjectHasAttribute('since', $analytics->timeseries[0]); + } + + public function testChangeDevelopmentMode() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/changeDevelopmentMode.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/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/development_mode'), + $this->equalTo(['value' => 'on']) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->changeDevelopmentMode('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true); + + $this->assertTrue($result); + $this->assertEquals('development_mode', $zones->getBody()->result->id); + } + + public function testCachePurgeEverything() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo(['purge_everything' => true]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41'); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } + + public function testCachePurgeHost() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo( + [ + 'files' => [], + 'tags' => [], + 'hosts' => ['dash.cloudflare.com'] + ] + ) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } + + public function testCachePurge() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurge.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo(['files' => [ + 'https://example.com/file.jpg', + ] + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [ + 'https://example.com/file.jpg', + ]); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } +} diff --git a/tests/Fixtures/Endpoints/activationTest.json b/tests/Fixtures/Endpoints/activationTest.json new file mode 100644 index 0000000..bedd2f5 --- /dev/null +++ b/tests/Fixtures/Endpoints/activationTest.json @@ -0,0 +1,8 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "023e105f4ecef8ad9ca31a8372d0c353" + } +} diff --git a/tests/Fixtures/Endpoints/addLockdown.json b/tests/Fixtures/Endpoints/addLockdown.json new file mode 100644 index 0000000..48d1311 --- /dev/null +++ b/tests/Fixtures/Endpoints/addLockdown.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Restrict access to these endpoints to requests from a known IP address", + "urls": [ + "api.mysite.com/some/endpoint*" + ], + "configurations": [ + { + "target": "ip", + "value": "1.2.3.4" + } + ] + } +} diff --git a/tests/Fixtures/Endpoints/addRecord.json b/tests/Fixtures/Endpoints/addRecord.json new file mode 100644 index 0000000..e5c6225 --- /dev/null +++ b/tests/Fixtures/Endpoints/addRecord.json @@ -0,0 +1,20 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "type": "A", + "name": "example.com", + "content": "1.2.3.4", + "proxiable": true, + "proxied": false, + "ttl": 120, + "locked": false, + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "zone_name": "example.com", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "data": {} + } +} diff --git a/tests/Fixtures/Endpoints/addZone.json b/tests/Fixtures/Endpoints/addZone.json new file mode 100644 index 0000000..d3903c1 --- /dev/null +++ b/tests/Fixtures/Endpoints/addZone.json @@ -0,0 +1,54 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com", + "development_mode": 7200, + "original_name_servers": [ + "ns1.originaldnshost.com", + "ns2.originaldnshost.com" + ], + "original_registrar": "GoDaddy", + "original_dnshost": "NameCheap", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "name_servers": [ + "tony.ns.cloudflare.com", + "woz.ns.cloudflare.com" + ], + "owner": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "owner_type": "user" + }, + "permissions": [ + "#zone:read", + "#zone:edit" + ], + "plan": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "plan_pending": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "status": "active", + "paused": false, + "type": "full" + } +} diff --git a/tests/Fixtures/Endpoints/cachePurge.json b/tests/Fixtures/Endpoints/cachePurge.json new file mode 100644 index 0000000..bedd2f5 --- /dev/null +++ b/tests/Fixtures/Endpoints/cachePurge.json @@ -0,0 +1,8 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "023e105f4ecef8ad9ca31a8372d0c353" + } +} diff --git a/tests/Fixtures/Endpoints/cachePurgeEverything.json b/tests/Fixtures/Endpoints/cachePurgeEverything.json new file mode 100644 index 0000000..bedd2f5 --- /dev/null +++ b/tests/Fixtures/Endpoints/cachePurgeEverything.json @@ -0,0 +1,8 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "023e105f4ecef8ad9ca31a8372d0c353" + } +} diff --git a/tests/Fixtures/Endpoints/cachePurgeHost.json b/tests/Fixtures/Endpoints/cachePurgeHost.json new file mode 100644 index 0000000..bedd2f5 --- /dev/null +++ b/tests/Fixtures/Endpoints/cachePurgeHost.json @@ -0,0 +1,8 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "023e105f4ecef8ad9ca31a8372d0c353" + } +} diff --git a/tests/Fixtures/Endpoints/changeDevelopmentMode.json b/tests/Fixtures/Endpoints/changeDevelopmentMode.json new file mode 100644 index 0000000..2180658 --- /dev/null +++ b/tests/Fixtures/Endpoints/changeDevelopmentMode.json @@ -0,0 +1,12 @@ +{ + "result": { + "id": "development_mode", + "value": "on", + "modified_on": "2017-11-06T05:16:42.864300Z", + "time_remaining": 10800, + "editable": true + }, + "success": true, + "errors": [], + "messages": [] +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/changeMinimumTLSVersion.json b/tests/Fixtures/Endpoints/changeMinimumTLSVersion.json new file mode 100644 index 0000000..f136586 --- /dev/null +++ b/tests/Fixtures/Endpoints/changeMinimumTLSVersion.json @@ -0,0 +1,6 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": "1.1" +} diff --git a/tests/Fixtures/Endpoints/createAccessRule.json b/tests/Fixtures/Endpoints/createAccessRule.json new file mode 100644 index 0000000..3f34b6a --- /dev/null +++ b/tests/Fixtures/Endpoints/createAccessRule.json @@ -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" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/createCustomHostname.json b/tests/Fixtures/Endpoints/createCustomHostname.json new file mode 100644 index 0000000..1ea6dae --- /dev/null +++ b/tests/Fixtures/Endpoints/createCustomHostname.json @@ -0,0 +1,20 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9", + "hostname": "app.example.com", + "ssl": { + "status": "pending_validation", + "method": "http", + "type": "dv", + "cname_target": "dcv.digicert.com", + "cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com" + } + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/createPageRule.json b/tests/Fixtures/Endpoints/createPageRule.json new file mode 100644 index 0000000..8996def --- /dev/null +++ b/tests/Fixtures/Endpoints/createPageRule.json @@ -0,0 +1,31 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "9a7806061c88ada191ed06f989cc3dac", + "targets": [ + { + "target": "url", + "constraint": { + "operator": "matches", + "value": "*example.com/images/*" + } + } + ], + "actions": [ + { + "id": "always_online", + "value": "on" + } + ], + "priority": 1, + "status": "active", + "modified_on": "2014-01-01T05:20:00.12345Z", + "created_on": "2014-01-01T05:20:00.12345Z" + } +} diff --git a/tests/Fixtures/Endpoints/createRailgun.json b/tests/Fixtures/Endpoints/createRailgun.json new file mode 100644 index 0000000..33054a7 --- /dev/null +++ b/tests/Fixtures/Endpoints/createRailgun.json @@ -0,0 +1,23 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "e928d310693a83094309acf9ead50448", + "name": "My Railgun", + "status": "active", + "enabled": true, + "zones_connected": 2, + "build": "b1234", + "version": "2.1", + "revision": "123", + "activation_key": "e4edc00281cb56ebac22c81be9bac8f3", + "activated_on": "2014-01-02T02:20:00Z", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/createRule.json b/tests/Fixtures/Endpoints/createRule.json new file mode 100644 index 0000000..af721e6 --- /dev/null +++ b/tests/Fixtures/Endpoints/createRule.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack", + "mode": "js_challenge", + "configuration": { + "target": "ua", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4" + } + } +} diff --git a/tests/Fixtures/Endpoints/deleteAccessRule.json b/tests/Fixtures/Endpoints/deleteAccessRule.json new file mode 100644 index 0000000..2c1ae81 --- /dev/null +++ b/tests/Fixtures/Endpoints/deleteAccessRule.json @@ -0,0 +1,12 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "92f17202ed8bd63d69a66b86a49a8f6b" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/deleteHostname.json b/tests/Fixtures/Endpoints/deleteHostname.json new file mode 100644 index 0000000..4ac88c9 --- /dev/null +++ b/tests/Fixtures/Endpoints/deleteHostname.json @@ -0,0 +1,3 @@ +{ + "id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9" +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/deleteLockdown.json b/tests/Fixtures/Endpoints/deleteLockdown.json new file mode 100644 index 0000000..7599aee --- /dev/null +++ b/tests/Fixtures/Endpoints/deleteLockdown.json @@ -0,0 +1,12 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59" + } +} diff --git a/tests/Fixtures/Endpoints/deletePageRule.json b/tests/Fixtures/Endpoints/deletePageRule.json new file mode 100644 index 0000000..330525b --- /dev/null +++ b/tests/Fixtures/Endpoints/deletePageRule.json @@ -0,0 +1,12 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "9a7806061c88ada191ed06f989cc3dac" + } +} diff --git a/tests/Fixtures/Endpoints/deleteRailgun.json b/tests/Fixtures/Endpoints/deleteRailgun.json new file mode 100644 index 0000000..a16e6c7 --- /dev/null +++ b/tests/Fixtures/Endpoints/deleteRailgun.json @@ -0,0 +1,12 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "e928d310693a83094309acf9ead50448" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/deleteRule.json b/tests/Fixtures/Endpoints/deleteRule.json new file mode 100644 index 0000000..7599aee --- /dev/null +++ b/tests/Fixtures/Endpoints/deleteRule.json @@ -0,0 +1,12 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59" + } +} diff --git a/tests/Fixtures/Endpoints/disableTLS13.json b/tests/Fixtures/Endpoints/disableTLS13.json new file mode 100644 index 0000000..5fe9c2c --- /dev/null +++ b/tests/Fixtures/Endpoints/disableTLS13.json @@ -0,0 +1,6 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": "off" +} diff --git a/tests/Fixtures/Endpoints/enableTLS13.json b/tests/Fixtures/Endpoints/enableTLS13.json new file mode 100644 index 0000000..cb21ca2 --- /dev/null +++ b/tests/Fixtures/Endpoints/enableTLS13.json @@ -0,0 +1,6 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": "on" +} diff --git a/tests/Fixtures/Endpoints/getAnalyticsDashboard.json b/tests/Fixtures/Endpoints/getAnalyticsDashboard.json new file mode 100644 index 0000000..893b0f9 --- /dev/null +++ b/tests/Fixtures/Endpoints/getAnalyticsDashboard.json @@ -0,0 +1,176 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "totals": { + "since": "2015-01-01T12:23:00Z", + "until": "2015-01-02T12:23:00Z", + "requests": { + "all": 1234085328, + "cached": 1234085328, + "uncached": 13876154, + "content_type": { + "css": 15343, + "html": 1234213, + "javascript": 318236, + "gif": 23178, + "jpeg": 1982048 + }, + "country": { + "US": 4181364, + "AG": 37298, + "GI": 293846 + }, + "ssl": { + "encrypted": 12978361, + "unencrypted": 781263 + }, + "http_status": { + "200": 13496983, + "301": 283, + "400": 187936, + "402": 1828, + "404": 1293 + } + }, + "bandwidth": { + "all": 213867451, + "cached": 113205063, + "uncached": 113205063, + "content_type": { + "css": 237421, + "html": 1231290, + "javascript": 123245, + "gif": 1234242, + "jpeg": 784278 + }, + "country": { + "US": 123145433, + "AG": 2342483, + "GI": 984753 + }, + "ssl": { + "encrypted": 37592942, + "unencrypted": 237654192 + } + }, + "threats": { + "all": 23423873, + "country": { + "US": 123, + "CN": 523423, + "AU": 91 + }, + "type": { + "user.ban.ip": 123, + "hot.ban.unknown": 5324, + "macro.chl.captchaErr": 1341, + "macro.chl.jschlErr": 5323 + } + }, + "pageviews": { + "all": 5724723, + "search_engines": { + "googlebot": 35272, + "pingdom": 13435, + "bingbot": 5372, + "baidubot": 1345 + } + }, + "uniques": { + "all": 12343 + } + }, + "timeseries": [ + { + "since": "2015-01-01T12:23:00Z", + "until": "2015-01-02T12:23:00Z", + "requests": { + "all": 1234085328, + "cached": 1234085328, + "uncached": 13876154, + "content_type": { + "css": 15343, + "html": 1234213, + "javascript": 318236, + "gif": 23178, + "jpeg": 1982048 + }, + "country": { + "US": 4181364, + "AG": 37298, + "GI": 293846 + }, + "ssl": { + "encrypted": 12978361, + "unencrypted": 781263 + }, + "http_status": { + "200": 13496983, + "301": 283, + "400": 187936, + "402": 1828, + "404": 1293 + } + }, + "bandwidth": { + "all": 213867451, + "cached": 113205063, + "uncached": 113205063, + "content_type": { + "css": 237421, + "html": 1231290, + "javascript": 123245, + "gif": 1234242, + "jpeg": 784278 + }, + "country": { + "US": 123145433, + "AG": 2342483, + "GI": 984753 + }, + "ssl": { + "encrypted": 37592942, + "unencrypted": 237654192 + } + }, + "threats": { + "all": 23423873, + "country": { + "US": 123, + "CN": 523423, + "AU": 91 + }, + "type": { + "user.ban.ip": 123, + "hot.ban.unknown": 5324, + "macro.chl.captchaErr": 1341, + "macro.chl.jschlErr": 5323 + } + }, + "pageviews": { + "all": 5724723, + "search_engines": { + "googlebot": 35272, + "pingdom": 13435, + "bingbot": 5372, + "baidubot": 1345 + } + }, + "uniques": { + "all": 12343 + } + } + ] + }, + "query": { + "since": "2015-01-01T12:23:00Z", + "until": "2015-01-02T12:23:00Z", + "time_delta": 60 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getDNSRecordDetails.json b/tests/Fixtures/Endpoints/getDNSRecordDetails.json new file mode 100644 index 0000000..e5c6225 --- /dev/null +++ b/tests/Fixtures/Endpoints/getDNSRecordDetails.json @@ -0,0 +1,20 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "type": "A", + "name": "example.com", + "content": "1.2.3.4", + "proxiable": true, + "proxied": false, + "ttl": 120, + "locked": false, + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "zone_name": "example.com", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "data": {} + } +} diff --git a/tests/Fixtures/Endpoints/getHostname.json b/tests/Fixtures/Endpoints/getHostname.json new file mode 100644 index 0000000..1ea6dae --- /dev/null +++ b/tests/Fixtures/Endpoints/getHostname.json @@ -0,0 +1,20 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9", + "hostname": "app.example.com", + "ssl": { + "status": "pending_validation", + "method": "http", + "type": "dv", + "cname_target": "dcv.digicert.com", + "cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com" + } + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getPackageGroupInfo.json b/tests/Fixtures/Endpoints/getPackageGroupInfo.json new file mode 100644 index 0000000..e607ddd --- /dev/null +++ b/tests/Fixtures/Endpoints/getPackageGroupInfo.json @@ -0,0 +1,22 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "de677e5818985db1285d0e80225f06e5", + "name": "Project Honey Pot", + "description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks", + "rules_count": 10, + "modified_rules_count": 2, + "package_id": "a25a9a7e9c00afc1fb2e0245519d725b", + "mode": "on", + "allowed_modes": [ + "on", + "off" + ] + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getPackageInfo.json b/tests/Fixtures/Endpoints/getPackageInfo.json new file mode 100644 index 0000000..5c94df8 --- /dev/null +++ b/tests/Fixtures/Endpoints/getPackageInfo.json @@ -0,0 +1,17 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "a25a9a7e9c00afc1fb2e0245519d725b", + "name": "WordPress rules", + "description": "Common WordPress exploit protections", + "detection_mode": "traditional", + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "status": "active" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getPackageRuleInfo.json b/tests/Fixtures/Endpoints/getPackageRuleInfo.json new file mode 100644 index 0000000..c40c3d2 --- /dev/null +++ b/tests/Fixtures/Endpoints/getPackageRuleInfo.json @@ -0,0 +1,24 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "f939de3be84e66e757adcdcb87908023", + "description": "SQL injection prevention for SELECT statements", + "priority": 5, + "group": { + "id": "de677e5818985db1285d0e80225f06e5", + "name": "Project Honey Pot" + }, + "package_id": "a25a9a7e9c00afc1fb2e0245519d725b", + "allowed_modes": [ + "on", + "off" + ], + "mode": "on" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getPageRuleDetails.json b/tests/Fixtures/Endpoints/getPageRuleDetails.json new file mode 100644 index 0000000..8996def --- /dev/null +++ b/tests/Fixtures/Endpoints/getPageRuleDetails.json @@ -0,0 +1,31 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "9a7806061c88ada191ed06f989cc3dac", + "targets": [ + { + "target": "url", + "constraint": { + "operator": "matches", + "value": "*example.com/images/*" + } + } + ], + "actions": [ + { + "id": "always_online", + "value": "on" + } + ], + "priority": 1, + "status": "active", + "modified_on": "2014-01-01T05:20:00.12345Z", + "created_on": "2014-01-01T05:20:00.12345Z" + } +} diff --git a/tests/Fixtures/Endpoints/getRailgun.json b/tests/Fixtures/Endpoints/getRailgun.json new file mode 100644 index 0000000..33054a7 --- /dev/null +++ b/tests/Fixtures/Endpoints/getRailgun.json @@ -0,0 +1,23 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "e928d310693a83094309acf9ead50448", + "name": "My Railgun", + "status": "active", + "enabled": true, + "zones_connected": 2, + "build": "b1234", + "version": "2.1", + "revision": "123", + "activation_key": "e4edc00281cb56ebac22c81be9bac8f3", + "activated_on": "2014-01-02T02:20:00Z", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getRecordDetails.json b/tests/Fixtures/Endpoints/getRecordDetails.json new file mode 100644 index 0000000..5a3900d --- /dev/null +++ b/tests/Fixtures/Endpoints/getRecordDetails.json @@ -0,0 +1,22 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Restrict access to these endpoints to requests from a known IP address", + "urls": [ + "api.mysite.com/some/endpoint*" + ], + "configurations": [ + { + "target": "ip", + "value": "1.2.3.4" + } + ] + } +} diff --git a/tests/Fixtures/Endpoints/getRuleDetails.json b/tests/Fixtures/Endpoints/getRuleDetails.json new file mode 100644 index 0000000..af721e6 --- /dev/null +++ b/tests/Fixtures/Endpoints/getRuleDetails.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack", + "mode": "js_challenge", + "configuration": { + "target": "ua", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4" + } + } +} diff --git a/tests/Fixtures/Endpoints/getUserDetails.json b/tests/Fixtures/Endpoints/getUserDetails.json new file mode 100644 index 0000000..18d9111 --- /dev/null +++ b/tests/Fixtures/Endpoints/getUserDetails.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "first_name": "John", + "last_name": "Appleseed", + "username": "cfuser12345", + "telephone": "+1 123-123-1234", + "country": "US", + "zipcode": "12345", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z", + "two_factor_authentication_enabled": false + } +} diff --git a/tests/Fixtures/Endpoints/getUserEmail.json b/tests/Fixtures/Endpoints/getUserEmail.json new file mode 100644 index 0000000..18d9111 --- /dev/null +++ b/tests/Fixtures/Endpoints/getUserEmail.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "first_name": "John", + "last_name": "Appleseed", + "username": "cfuser12345", + "telephone": "+1 123-123-1234", + "country": "US", + "zipcode": "12345", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z", + "two_factor_authentication_enabled": false + } +} diff --git a/tests/Fixtures/Endpoints/getUserId.json b/tests/Fixtures/Endpoints/getUserId.json new file mode 100644 index 0000000..18d9111 --- /dev/null +++ b/tests/Fixtures/Endpoints/getUserId.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "first_name": "John", + "last_name": "Appleseed", + "username": "cfuser12345", + "telephone": "+1 123-123-1234", + "country": "US", + "zipcode": "12345", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z", + "two_factor_authentication_enabled": false + } +} diff --git a/tests/Fixtures/Endpoints/getZoneId.json b/tests/Fixtures/Endpoints/getZoneId.json new file mode 100644 index 0000000..462e4b4 --- /dev/null +++ b/tests/Fixtures/Endpoints/getZoneId.json @@ -0,0 +1,62 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com", + "development_mode": 7200, + "original_name_servers": [ + "ns1.originaldnshost.com", + "ns2.originaldnshost.com" + ], + "original_registrar": "GoDaddy", + "original_dnshost": "NameCheap", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "name_servers": [ + "tony.ns.cloudflare.com", + "woz.ns.cloudflare.com" + ], + "owner": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "owner_type": "user" + }, + "permissions": [ + "#zone:read", + "#zone:edit" + ], + "plan": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "plan_pending": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "status": "active", + "paused": false, + "type": "full" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/listAccessRules.json b/tests/Fixtures/Endpoints/listAccessRules.json new file mode 100644 index 0000000..a11d418 --- /dev/null +++ b/tests/Fixtures/Endpoints/listAccessRules.json @@ -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 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listHostnames.json b/tests/Fixtures/Endpoints/listHostnames.json new file mode 100644 index 0000000..e89ade5 --- /dev/null +++ b/tests/Fixtures/Endpoints/listHostnames.json @@ -0,0 +1,28 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9", + "hostname": "app.example.com", + "ssl": { + "status": "pending_validation", + "method": "http", + "type": "dv", + "cname_target": "dcv.digicert.com", + "cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com" + } + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listIPs.json b/tests/Fixtures/Endpoints/listIPs.json new file mode 100644 index 0000000..3a8ffbf --- /dev/null +++ b/tests/Fixtures/Endpoints/listIPs.json @@ -0,0 +1,13 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "ipv4_cidrs": [ + "199.27.128.0/21" + ], + "ipv6_cidrs": [ + "2400:cb00::/32" + ] + } +} diff --git a/tests/Fixtures/Endpoints/listLockdowns.json b/tests/Fixtures/Endpoints/listLockdowns.json new file mode 100644 index 0000000..c9b1ce0 --- /dev/null +++ b/tests/Fixtures/Endpoints/listLockdowns.json @@ -0,0 +1,26 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Restrict access to these endpoints to requests from a known IP address", + "urls": [ + "api.mysite.com/some/endpoint*" + ], + "configurations": [ + { + "target": "ip", + "value": "1.2.3.4" + } + ] + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/listPackageGroups.json b/tests/Fixtures/Endpoints/listPackageGroups.json new file mode 100644 index 0000000..11855a0 --- /dev/null +++ b/tests/Fixtures/Endpoints/listPackageGroups.json @@ -0,0 +1,30 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "de677e5818985db1285d0e80225f06e5", + "name": "Project Honey Pot", + "description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks", + "rules_count": 10, + "modified_rules_count": 2, + "package_id": "a25a9a7e9c00afc1fb2e0245519d725b", + "mode": "on", + "allowed_modes": [ + "on", + "off" + ] + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listPackageRules.json b/tests/Fixtures/Endpoints/listPackageRules.json new file mode 100644 index 0000000..a11d418 --- /dev/null +++ b/tests/Fixtures/Endpoints/listPackageRules.json @@ -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 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listPackages.json b/tests/Fixtures/Endpoints/listPackages.json new file mode 100644 index 0000000..d6be34c --- /dev/null +++ b/tests/Fixtures/Endpoints/listPackages.json @@ -0,0 +1,25 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "a25a9a7e9c00afc1fb2e0245519d725b", + "name": "WordPress rules", + "description": "Common WordPress exploit protections", + "detection_mode": "traditional", + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "status": "active" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listPageRules.json b/tests/Fixtures/Endpoints/listPageRules.json new file mode 100644 index 0000000..5d51042 --- /dev/null +++ b/tests/Fixtures/Endpoints/listPageRules.json @@ -0,0 +1,39 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "9a7806061c88ada191ed06f989cc3dac", + "targets": [ + { + "target": "url", + "constraint": { + "operator": "matches", + "value": "*example.com/images/*" + } + } + ], + "actions": [ + { + "id": "always_online", + "value": "on" + } + ], + "priority": 1, + "status": "active", + "modified_on": "2014-01-01T05:20:00.12345Z", + "created_on": "2014-01-01T05:20:00.12345Z" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/listRailgunZones.json b/tests/Fixtures/Endpoints/listRailgunZones.json new file mode 100644 index 0000000..983004a --- /dev/null +++ b/tests/Fixtures/Endpoints/listRailgunZones.json @@ -0,0 +1,30 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com", + "development_mode": 7200, + "original_name_servers": [ + "ns1.originaldnshost.com", + "ns2.originaldnshost.com" + ], + "original_registrar": "GoDaddy", + "original_dnshost": "NameCheap", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listRailguns.json b/tests/Fixtures/Endpoints/listRailguns.json new file mode 100644 index 0000000..7a4db43 --- /dev/null +++ b/tests/Fixtures/Endpoints/listRailguns.json @@ -0,0 +1,31 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "e928d310693a83094309acf9ead50448", + "name": "My Railgun", + "status": "active", + "enabled": true, + "zones_connected": 2, + "build": "b1234", + "version": "2.1", + "revision": "123", + "activation_key": "e4edc00281cb56ebac22c81be9bac8f3", + "activated_on": "2014-01-02T02:20:00Z", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listRecords.json b/tests/Fixtures/Endpoints/listRecords.json new file mode 100644 index 0000000..9d87373 --- /dev/null +++ b/tests/Fixtures/Endpoints/listRecords.json @@ -0,0 +1,28 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "type": "A", + "name": "example.com", + "content": "1.2.3.4", + "proxiable": true, + "proxied": false, + "ttl": 120, + "locked": false, + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "zone_name": "example.com", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "data": {} + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/listRules.json b/tests/Fixtures/Endpoints/listRules.json new file mode 100644 index 0000000..a168aa8 --- /dev/null +++ b/tests/Fixtures/Endpoints/listRules.json @@ -0,0 +1,26 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": [ + { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack", + "mode": "js_challenge", + "configuration": { + "target": "ua", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4" + } + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/listZones.json b/tests/Fixtures/Endpoints/listZones.json new file mode 100644 index 0000000..462e4b4 --- /dev/null +++ b/tests/Fixtures/Endpoints/listZones.json @@ -0,0 +1,62 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com", + "development_mode": 7200, + "original_name_servers": [ + "ns1.originaldnshost.com", + "ns2.originaldnshost.com" + ], + "original_registrar": "GoDaddy", + "original_dnshost": "NameCheap", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "name_servers": [ + "tony.ns.cloudflare.com", + "woz.ns.cloudflare.com" + ], + "owner": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "owner_type": "user" + }, + "permissions": [ + "#zone:read", + "#zone:edit" + ], + "plan": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "plan_pending": { + "id": "e592fd9519420ba7405e1307bff33214", + "name": "Pro Plan", + "price": 20, + "currency": "USD", + "frequency": "monthly", + "legacy_id": "pro", + "is_subscribed": true, + "can_subscribe": true + }, + "status": "active", + "paused": false, + "type": "full" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} diff --git a/tests/Fixtures/Endpoints/updateAccessRule.json b/tests/Fixtures/Endpoints/updateAccessRule.json new file mode 100644 index 0000000..3f34b6a --- /dev/null +++ b/tests/Fixtures/Endpoints/updateAccessRule.json @@ -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" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updateDNSRecord.json b/tests/Fixtures/Endpoints/updateDNSRecord.json new file mode 100644 index 0000000..33253a4 --- /dev/null +++ b/tests/Fixtures/Endpoints/updateDNSRecord.json @@ -0,0 +1,24 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "type": "A", + "name": "example.com", + "content": "1.2.3.4", + "proxiable": true, + "proxied": false, + "ttl": 120, + "locked": false, + "zone_id": "023e105f4ecef8ad9ca31a8372d0c353", + "zone_name": "example.com", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "data": {} + } +} diff --git a/tests/Fixtures/Endpoints/updateHostname.json b/tests/Fixtures/Endpoints/updateHostname.json new file mode 100644 index 0000000..1ea6dae --- /dev/null +++ b/tests/Fixtures/Endpoints/updateHostname.json @@ -0,0 +1,20 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "0d89c70d-ad9f-4843-b99f-6cc0252067e9", + "hostname": "app.example.com", + "ssl": { + "status": "pending_validation", + "method": "http", + "type": "dv", + "cname_target": "dcv.digicert.com", + "cname": "810b7d5f01154524b961ba0cd578acc2.app.example.com" + } + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updateLockdown.json b/tests/Fixtures/Endpoints/updateLockdown.json new file mode 100644 index 0000000..5a3900d --- /dev/null +++ b/tests/Fixtures/Endpoints/updateLockdown.json @@ -0,0 +1,22 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Restrict access to these endpoints to requests from a known IP address", + "urls": [ + "api.mysite.com/some/endpoint*" + ], + "configurations": [ + { + "target": "ip", + "value": "1.2.3.4" + } + ] + } +} diff --git a/tests/Fixtures/Endpoints/updatePackageGroup.json b/tests/Fixtures/Endpoints/updatePackageGroup.json new file mode 100644 index 0000000..61db152 --- /dev/null +++ b/tests/Fixtures/Endpoints/updatePackageGroup.json @@ -0,0 +1,22 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "de677e5818985db1285d0e80225f06e5", + "name": "Project Honey Pot", + "description": "Group designed to protect against IP addresses that are a threat and typically used to launch DDoS attacks", + "rules_count": 10, + "modified_rules_count": 2, + "package_id": "a25a9a7e9c00afc1fb2e0245519d725b", + "mode": "off", + "allowed_modes": [ + "on", + "off" + ] + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updatePackageRule.json b/tests/Fixtures/Endpoints/updatePackageRule.json new file mode 100644 index 0000000..c40c3d2 --- /dev/null +++ b/tests/Fixtures/Endpoints/updatePackageRule.json @@ -0,0 +1,24 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "f939de3be84e66e757adcdcb87908023", + "description": "SQL injection prevention for SELECT statements", + "priority": 5, + "group": { + "id": "de677e5818985db1285d0e80225f06e5", + "name": "Project Honey Pot" + }, + "package_id": "a25a9a7e9c00afc1fb2e0245519d725b", + "allowed_modes": [ + "on", + "off" + ], + "mode": "on" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updatePageRule.json b/tests/Fixtures/Endpoints/updatePageRule.json new file mode 100644 index 0000000..8996def --- /dev/null +++ b/tests/Fixtures/Endpoints/updatePageRule.json @@ -0,0 +1,31 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "9a7806061c88ada191ed06f989cc3dac", + "targets": [ + { + "target": "url", + "constraint": { + "operator": "matches", + "value": "*example.com/images/*" + } + } + ], + "actions": [ + { + "id": "always_online", + "value": "on" + } + ], + "priority": 1, + "status": "active", + "modified_on": "2014-01-01T05:20:00.12345Z", + "created_on": "2014-01-01T05:20:00.12345Z" + } +} diff --git a/tests/Fixtures/Endpoints/updateRailgun.json b/tests/Fixtures/Endpoints/updateRailgun.json new file mode 100644 index 0000000..33054a7 --- /dev/null +++ b/tests/Fixtures/Endpoints/updateRailgun.json @@ -0,0 +1,23 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "e928d310693a83094309acf9ead50448", + "name": "My Railgun", + "status": "active", + "enabled": true, + "zones_connected": 2, + "build": "b1234", + "version": "2.1", + "revision": "123", + "activation_key": "e4edc00281cb56ebac22c81be9bac8f3", + "activated_on": "2014-01-02T02:20:00Z", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updateRule.json b/tests/Fixtures/Endpoints/updateRule.json new file mode 100644 index 0000000..af721e6 --- /dev/null +++ b/tests/Fixtures/Endpoints/updateRule.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [ + {} + ], + "messages": [ + {} + ], + "result": { + "id": "372e67954025e0ba6aaa6d586b9e0b59", + "description": "Prevent access from abusive clients identified by this UserAgent to mitigate DDoS attack", + "mode": "js_challenge", + "configuration": { + "target": "ua", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4" + } + } +} diff --git a/tests/Fixtures/Endpoints/updateUserDetails.json b/tests/Fixtures/Endpoints/updateUserDetails.json new file mode 100644 index 0000000..18d9111 --- /dev/null +++ b/tests/Fixtures/Endpoints/updateUserDetails.json @@ -0,0 +1,18 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "7c5dae5552338874e5053f2534d2767a", + "email": "user@example.com", + "first_name": "John", + "last_name": "Appleseed", + "username": "cfuser12345", + "telephone": "+1 123-123-1234", + "country": "US", + "zipcode": "12345", + "created_on": "2014-01-01T05:20:00Z", + "modified_on": "2014-01-01T05:20:00Z", + "two_factor_authentication_enabled": false + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..418bc92 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,46 @@ +assertFileExists($path); + + $stream = Psr7\stream_for(file_get_contents($path)); + + $this->assertInstanceOf(Psr7\Stream::class, $stream); + + return $stream; + } + + /** + * Returns a PSR7 Response (JSON) for a given fixture. + * + * @param string $fixture The fixture to create the response for. + * @param integer $statusCode A HTTP Status Code for the response. + * @return Psr7\Response + */ + protected function getPsr7JsonResponseForFixture($fixture, $statusCode = 200): Psr7\Response + { + $stream = $this->getPsr7StreamForFixture($fixture); + + $this->assertNotNull(json_decode($stream)); + $this->assertEquals(JSON_ERROR_NONE, json_last_error()); + + return new Psr7\Response($statusCode, ['Content-Type' => 'application/json'], $stream); + } +}