Add Crypto endpoints to crypto.php, update TLS.php
add php docs for methods add test class work on crypto tests add tls tests finish crypto tests update doc returns add type to parameter
This commit is contained in:
committed by
Michael
parent
fab0bc7a12
commit
fb9d75d94a
220
tests/Endpoints/CryptoTest.php
Normal file
220
tests/Endpoints/CryptoTest.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
class CryptoTest extends TestCase
|
||||
{
|
||||
public function testGetSSLSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getSSLSetting.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/settings/ssl')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getSSLSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testGetSSLVerificationStatus()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getSSLVerificationStatus.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/ssl/verification')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getSSLVerificationStatus('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
$this->assertEquals('active', $result->result{0}->certificate_status);
|
||||
}
|
||||
|
||||
public function testGetOpportunisticEncryptionSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getOpportunisticEncryptionSetting.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/settings/opportunistic_encryption')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getOpportunisticEncryptionSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testGetOnionRoutingSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getOnionRoutingSetting.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/settings/opportunistic_onion')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getOnionRoutingSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testGetHTTPSRedirectSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getHTTPSRedirectSetting.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/settings/always_use_https')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getHTTPSRedirectSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testGetHTTPSRewritesSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getHTTPSRewritesSetting.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/settings/automatic_https_rewrites')
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->getHTTPSRewritesSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testUpdateSSLSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateSSLSetting.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/ssl'),
|
||||
$this->equalTo(['value' => 'full'])
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->updateSSLSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'full');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateHTTPSRedirectSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHTTPSRedirectSetting.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/always_use_https'),
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->updateHTTPSRedirectSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateHTTPSRewritesSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHTTPSRewritesSetting.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/automatic_https_rewrites'),
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->updateHTTPSRewritesSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateOpportunisticEncryptionSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateOpportunisticEncryptionSetting.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/opportunistic_encryption'),
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->updateOpportunisticEncryptionSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateOnionRoutingSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateOnionRoutingSetting.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/opportunistic_onion'),
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$cryptoMock = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $cryptoMock->updateOnionRoutingSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,25 @@
|
||||
|
||||
class TLSTest extends TestCase
|
||||
{
|
||||
public function testGetTLSClientAuth()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getTLSClientAuth.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/settings/tls_client_auth')
|
||||
);
|
||||
|
||||
$tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $tlsMock->getTLSClientAuth('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('off', $result);
|
||||
}
|
||||
|
||||
public function testEnableTLS13()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/enableTLS13.json');
|
||||
@@ -23,8 +42,8 @@ class TLSTest extends TestCase
|
||||
$this->equalTo(['value' => 'on'])
|
||||
);
|
||||
|
||||
$zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $zoneTLSSettings->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
|
||||
$tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $tlsMock->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
@@ -43,8 +62,8 @@ class TLSTest extends TestCase
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $zoneTLSSettings->disableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
|
||||
$tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $tlsMock->disableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
@@ -63,8 +82,28 @@ class TLSTest extends TestCase
|
||||
$this->equalTo(['value' => '1.1'])
|
||||
);
|
||||
|
||||
$zoneTLSSettings = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $zoneTLSSettings->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1');
|
||||
$tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $tlsMock->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateTLSClientAuth()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateTLSClientAuth.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_client_auth'),
|
||||
$this->equalTo(['value' => 'off'])
|
||||
);
|
||||
|
||||
$tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
|
||||
$result = $tlsMock->updateTLSClientAuth('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
6
tests/Fixtures/Endpoints/getHTTPSRedirectSetting.json
Normal file
6
tests/Fixtures/Endpoints/getHTTPSRedirectSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/getHTTPSRewritesSetting.json
Normal file
6
tests/Fixtures/Endpoints/getHTTPSRewritesSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/getOnionRoutingSetting.json
Normal file
6
tests/Fixtures/Endpoints/getOnionRoutingSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "opportunistic_encryption",
|
||||
"value": "off",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/getSSLSetting.json
Normal file
11
tests/Fixtures/Endpoints/getSSLSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "ssl",
|
||||
"value": "off",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
16
tests/Fixtures/Endpoints/getSSLVerificationStatus.json
Normal file
16
tests/Fixtures/Endpoints/getSSLVerificationStatus.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"result": [
|
||||
{
|
||||
"certificate_status": "active",
|
||||
"verification_type": "cname",
|
||||
"verification_status": true,
|
||||
"verification_info": {
|
||||
"record_name": "b3b90cfedd89a3e487d3e383c56c4267.example.com",
|
||||
"record_target": "6979be7e4cfc9e5c603e31df7efac9cc60fee82d.comodoca.com"
|
||||
},
|
||||
"brand_check": false,
|
||||
"validation_method": "txt",
|
||||
"cert_pack_uuid": "a77f8bd7-3b47-46b4-a6f1-75cf98109948"
|
||||
}
|
||||
]
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/getTLSClientAuth.json
Normal file
11
tests/Fixtures/Endpoints/getTLSClientAuth.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "tls_client_auth",
|
||||
"value": "off",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/updateHTTPSRedirectSetting.json
Normal file
6
tests/Fixtures/Endpoints/updateHTTPSRedirectSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/updateHTTPSRewritesSetting.json
Normal file
6
tests/Fixtures/Endpoints/updateHTTPSRewritesSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/updateOnionRoutingSetting.json
Normal file
6
tests/Fixtures/Endpoints/updateOnionRoutingSetting.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": "off"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "opportunistic_encryption",
|
||||
"value": "on",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/updateSSLSetting.json
Normal file
11
tests/Fixtures/Endpoints/updateSSLSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "ssl",
|
||||
"value": "off",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/updateTLSClientAuth.json
Normal file
11
tests/Fixtures/Endpoints/updateTLSClientAuth.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "tls_client_auth",
|
||||
"value": "off",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user