Add changing TLS Zone Settings capability
This commit is contained in:
2947
composer.lock
generated
Normal file
2947
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
50
src/Endpoints/ZoneSettings.php
Normal file
50
src/Endpoints/ZoneSettings.php
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
33
tests/Endpoints/ZoneSettingsTest.php
Normal file
33
tests/Endpoints/ZoneSettingsTest.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/changeMinimumTLSVersion.json
Normal file
6
tests/Fixtures/Endpoints/changeMinimumTLSVersion.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "1.0"
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/enableTLS13.json
Normal file
6
tests/Fixtures/Endpoints/enableTLS13.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
Reference in New Issue
Block a user