diff --git a/src/Endpoints/TLS.php b/src/Endpoints/TLS.php index ca29420..d92a8b7 100644 --- a/src/Endpoints/TLS.php +++ b/src/Endpoints/TLS.php @@ -19,11 +19,11 @@ class TLS implements API $this->adapter = $adapter; } - public function enableTLS13($zoneID, $enable=false) + public function enableTLS13($zoneID) { $return = $this->adapter->patch( 'zones/' . $zoneID . '/settings/tls_1_3', - ['value' => $enable ? 'on' : 'off'] + ['value' => 'on'] ); $body = json_decode($return->getBody()); @@ -34,6 +34,23 @@ class TLS implements API 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( diff --git a/tests/Endpoints/TLSTest.php b/tests/Endpoints/TLSTest.php index f7d0360..d17aabb 100644 --- a/tests/Endpoints/TLSTest.php +++ b/tests/Endpoints/TLSTest.php @@ -23,8 +23,28 @@ class TLSTest extends TestCase $this->equalTo(['value' => 'on']) ); - $ZoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); - $result = $ZoneTLSSettings->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true); + $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); } @@ -43,8 +63,8 @@ class TLSTest extends TestCase $this->equalTo(['value' => '1.1']) ); - $ZoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); - $result = $ZoneTLSSettings->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1'); + $zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock); + $result = $zoneTLSSettings->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1'); $this->assertTrue($result); } 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" +}