Merge pull request #107 from beltofte/ssl-change-verify-method

Add method to change SSL certificate pack validation method
This commit is contained in:
Junade
2019-09-20 02:45:08 +01:00
committed by GitHub
3 changed files with 52 additions and 0 deletions

View File

@@ -150,4 +150,27 @@ class SSL implements API
}
return false;
}
/**
* Update the SSL certificate pack validation method
*
* @param string $zoneID The ID of the zone
* @param string $certPackUUID The certificate pack UUID
* @param string $validationMethod The verification method
* @return bool
*/
public function updateSSLCertificatePackValidationMethod(string $zoneID, string $certPackUUID, string $validationMethod)
{
$return = $this->adapter->patch(
'zones/' . $zoneID . '/ssl/verification/' . $certPackUUID,
[
'validation_method' => $validationMethod,
]
);
$body = json_decode($return->getBody());
if (isset($body->success) && $body->success == true) {
return true;
}
return false;
}
}

View File

@@ -138,4 +138,24 @@ class SSLTest extends TestCase
$this->assertTrue($result);
}
public function testUpdateSSLCertificatePackValidationMethod()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateSSLCertificatePackValidationMethod.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/ssl/verification/a77f8bd7-3b47-46b4-a6f1-75cf98109948'),
$this->equalTo(['validation_method' => 'txt'])
);
$sslMock = new \Cloudflare\API\Endpoints\SSL($mock);
$result = $sslMock->updateSSLCertificatePackValidationMethod('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'a77f8bd7-3b47-46b4-a6f1-75cf98109948', 'txt');
$this->assertTrue($result);
}
}

View File

@@ -0,0 +1,9 @@
{
"success": true,
"errors": [],
"messages": [],
"result": {
"validation_method": "txt",
"status": "pending_validation"
}
}