Add changing TLS Zone Settings capability

This commit is contained in:
Marlin-Ops.com - Jurgen Coetsiers
2018-10-21 11:00:32 +02:00
parent a3a346ccb2
commit 8c68295daa
5 changed files with 3042 additions and 0 deletions

2947
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
<?php
/**
* Created by PhpStorm.
* User: junade
* Date: 06/06/2017
* Time: 15:45
*/
namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter;
class ZoneSettings implements API
{
private $adapter;
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
}
public function enableTLS13($zoneID, $enable=false) {
$return = $this->adapter->patch(
'zones/' . $zoneID . '/settings/tls_1_3',
['value' => $enable ? 'on' : 'off']
);
$body = json_decode($return->getBody());
return $body->result;
}
public function changeMinimumTLSVersion($zoneID, $minimumVersion) {
$return = $this->adapter->patch(
'zones/' . $zoneID . '/settings/min_tls_version',
[
'value' => $minimumVersion
]
);
$body = json_decode($return->getBody());
return $body->result;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: Jurgen Coetsiers
* Date: 21/10/2018
* Time: 09:09
*/
class ZoneSettingsTest extends TestCase
{
public function testEnableTLS13()
{
$response = $this->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'])
);
$zoneSettings = new \Cloudflare\API\Endpoints\ZoneSettings($mock);
$result = $zoneSettings->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
$this->assertTrue($result);
}
}

View File

@@ -0,0 +1,6 @@
{
"success": true,
"errors": [],
"messages": [],
"result": "1.0"
}

View File

@@ -0,0 +1,6 @@
{
"success": true,
"errors": [],
"messages": [],
"result": "off"
}