Merge pull request #180 from phily245/179-missing-support-for-custom-hostname-update-properties
Missing Support For Custom Hostname Update Properties
This commit is contained in:
@@ -143,16 +143,33 @@ class CustomHostnames implements API
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
*
|
*
|
||||||
* @param string $zoneID
|
* @param string $zoneID
|
||||||
* @param string $hostnameID
|
* @param string $hostnameID
|
||||||
* @param string $sslMethod
|
* @param string $sslMethod
|
||||||
* @param string $sslType
|
* @param string $sslType
|
||||||
|
* @param array $sslSettings
|
||||||
|
* @param string $customOriginServer
|
||||||
|
* @param bool|null $wildcard
|
||||||
|
* @param string $bundleMethod
|
||||||
|
* @param array $customSsl
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = '', array $sslSettings = [], string $customOriginServer = ''): \stdClass
|
public function updateHostname(
|
||||||
{
|
string $zoneID,
|
||||||
|
string $hostnameID,
|
||||||
|
string $sslMethod = '',
|
||||||
|
string $sslType = '',
|
||||||
|
array $sslSettings = [],
|
||||||
|
string $customOriginServer = '',
|
||||||
|
bool $wildcard = null,
|
||||||
|
string $bundleMethod = '',
|
||||||
|
array $customSsl = []
|
||||||
|
): \stdClass {
|
||||||
$query = [];
|
$query = [];
|
||||||
|
$options = [];
|
||||||
|
|
||||||
if (!empty($sslMethod)) {
|
if (!empty($sslMethod)) {
|
||||||
$query['method'] = $sslMethod;
|
$query['method'] = $sslMethod;
|
||||||
@@ -166,6 +183,22 @@ class CustomHostnames implements API
|
|||||||
$query['settings'] = $sslSettings;
|
$query['settings'] = $sslSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($wildcard)) {
|
||||||
|
$query['wildcard'] = $wildcard;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($bundleMethod)) {
|
||||||
|
$query['bundle_method'] = $bundleMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($customSsl['key'])) {
|
||||||
|
$query['custom_key'] = $customSsl['key'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($customSsl['certificate'])) {
|
||||||
|
$query['custom_certificate'] = $customSsl['certificate'];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($query)) {
|
if (!empty($query)) {
|
||||||
$options = [
|
$options = [
|
||||||
'ssl' => $query
|
'ssl' => $query
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ class CustomHostnamesTest extends TestCase
|
|||||||
{
|
{
|
||||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json');
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json');
|
||||||
|
|
||||||
|
$customSsl = $this->getCustomSsl();
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('patch')->willReturn($response);
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
@@ -137,7 +139,12 @@ class CustomHostnamesTest extends TestCase
|
|||||||
'http2' => 'on',
|
'http2' => 'on',
|
||||||
'http3' => 'on',
|
'http3' => 'on',
|
||||||
'min_tls_version' => '1.2'
|
'min_tls_version' => '1.2'
|
||||||
]
|
],
|
||||||
|
'bundle_method' => 'optimal',
|
||||||
|
'custom_key' => $customSsl['key'],
|
||||||
|
'custom_certificate' => $customSsl['certificate'],
|
||||||
|
'wildcard' => true,
|
||||||
|
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
@@ -148,7 +155,21 @@ class CustomHostnamesTest extends TestCase
|
|||||||
'http3' => 'on',
|
'http3' => 'on',
|
||||||
'min_tls_version' => '1.2'
|
'min_tls_version' => '1.2'
|
||||||
];
|
];
|
||||||
$result = $zones->updateHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 'http', 'dv', $sslSettings, 'origin.example.com');
|
|
||||||
|
$result = $zones->updateHostname(
|
||||||
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
|
'0d89c70d-ad9f-4843-b99f-6cc0252067e9',
|
||||||
|
'http',
|
||||||
|
'dv',
|
||||||
|
$sslSettings,
|
||||||
|
'origin.example.com',
|
||||||
|
true,
|
||||||
|
'optimal',
|
||||||
|
[
|
||||||
|
'key' => $customSsl['key'],
|
||||||
|
'certificate' => $customSsl['certificate'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('id', $result);
|
$this->assertObjectHasAttribute('id', $result);
|
||||||
$this->assertObjectHasAttribute('hostname', $result);
|
$this->assertObjectHasAttribute('hostname', $result);
|
||||||
|
|||||||
Reference in New Issue
Block a user