Merge branch 'master' into 179-missing-support-for-custom-hostname-update-properties
This commit is contained in:
@@ -33,24 +33,47 @@ class CustomHostnames implements API
|
|||||||
* @param array $sslSettings
|
* @param array $sslSettings
|
||||||
* @param string $customOriginServer
|
* @param string $customOriginServer
|
||||||
* @param bool $wildcard
|
* @param bool $wildcard
|
||||||
|
* @param string $bundleMethod
|
||||||
|
* @param array $customSsl
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv', array $sslSettings = [], string $customOriginServer = '', bool $wildcard = false): \stdClass
|
public function addHostname(
|
||||||
{
|
string $zoneID,
|
||||||
|
string $hostname,
|
||||||
|
string $sslMethod = 'http',
|
||||||
|
string $sslType = 'dv',
|
||||||
|
array $sslSettings = [],
|
||||||
|
string $customOriginServer = '',
|
||||||
|
bool $wildcard = false,
|
||||||
|
string $bundleMethod = '',
|
||||||
|
array $customSsl = []
|
||||||
|
): \stdClass {
|
||||||
$options = [
|
$options = [
|
||||||
'hostname' => $hostname,
|
'hostname' => $hostname,
|
||||||
'ssl' => [
|
'ssl' => [
|
||||||
'method' => $sslMethod,
|
'method' => $sslMethod,
|
||||||
'type' => $sslType,
|
'type' => $sslType,
|
||||||
'settings' => $sslSettings
|
'settings' => $sslSettings,
|
||||||
],
|
|
||||||
'wildcard' => $wildcard,
|
'wildcard' => $wildcard,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($customOriginServer)) {
|
if (!empty($customOriginServer)) {
|
||||||
$options['custom_origin_server'] = $customOriginServer;
|
$options['custom_origin_server'] = $customOriginServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($bundleMethod)) {
|
||||||
|
$options['ssl']['bundle_method'] = $bundleMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($customSsl['key'])) {
|
||||||
|
$options['ssl']['custom_key'] = $customSsl['key'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($customSsl['certificate'])) {
|
||||||
|
$options['ssl']['custom_certificate'] = $customSsl['certificate'];
|
||||||
|
}
|
||||||
|
|
||||||
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);
|
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);
|
||||||
$this->body = json_decode($zone->getBody());
|
$this->body = json_decode($zone->getBody());
|
||||||
return $this->body->result;
|
return $this->body->result;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class CustomHostnamesTest extends TestCase
|
|||||||
{
|
{
|
||||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createCustomHostname.json');
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createCustomHostname.json');
|
||||||
|
|
||||||
|
$customSsl = $this->getCustomSsl();
|
||||||
|
|
||||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||||
$mock->method('post')->willReturn($response);
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
@@ -30,10 +32,13 @@ class CustomHostnamesTest extends TestCase
|
|||||||
'settings' => [
|
'settings' => [
|
||||||
'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,
|
'wildcard' => true,
|
||||||
|
],
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -43,7 +48,18 @@ class CustomHostnamesTest extends TestCase
|
|||||||
'http3' => 'on',
|
'http3' => 'on',
|
||||||
'min_tls_version' => '1.2'
|
'min_tls_version' => '1.2'
|
||||||
];
|
];
|
||||||
$hostname->addHostname('023e105f4ecef8ad9ca31a8372d0c353', 'app.example.com', 'http', 'dv', $sslSettings, 'origin.example.com', true);
|
|
||||||
|
$hostname->addHostname(
|
||||||
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
|
'app.example.com',
|
||||||
|
'http',
|
||||||
|
'dv',
|
||||||
|
$sslSettings,
|
||||||
|
'origin.example.com',
|
||||||
|
true,
|
||||||
|
'optimal',
|
||||||
|
$customSsl
|
||||||
|
);
|
||||||
$this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $hostname->getBody()->result->id);
|
$this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $hostname->getBody()->result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user