work on crypto tests
This commit is contained in:
@@ -44,7 +44,7 @@ class Crypto implements API
|
||||
);
|
||||
$body = json_decode($return->getBody());
|
||||
if ($body->result) {
|
||||
return $body->result;
|
||||
return $body;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,69 @@
|
||||
|
||||
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')
|
||||
);
|
||||
|
||||
$zoneSSLSetting = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $zoneSSLSetting->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')
|
||||
);
|
||||
|
||||
$zoneVerificationStatus = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $zoneVerificationStatus->getSSLVerificationStatus('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
$this->assertEquals('active', $result->result{0}->certificate_status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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'])
|
||||
);
|
||||
|
||||
$zoneSSLSetting = new \Cloudflare\API\Endpoints\Crypto($mock);
|
||||
$result = $zoneSSLSetting->updateSSLSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'full');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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/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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user