Add More Custom Hostname Creation Parameters
This now matches what is available as per the documentation
This commit is contained in:
@@ -30,12 +30,15 @@ class CustomHostnames implements API
|
|||||||
* @param string $hostname
|
* @param string $hostname
|
||||||
* @param string $sslMethod
|
* @param string $sslMethod
|
||||||
* @param string $sslType
|
* @param string $sslType
|
||||||
* @param array $sslSettings
|
* @param array $sslSettings
|
||||||
* @param string $customOriginServer
|
* @param string $customOriginServer
|
||||||
* @param bool $wildcard
|
* @param bool $wildcard
|
||||||
|
* @param string $bundleMethod
|
||||||
|
* @param string $customKey
|
||||||
|
* @param string $customCertificate
|
||||||
* @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 = '', string $customKey = '', string $customCertificate = ''): \stdClass
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
'hostname' => $hostname,
|
'hostname' => $hostname,
|
||||||
@@ -51,6 +54,18 @@ class CustomHostnames implements API
|
|||||||
$options['custom_origin_server'] = $customOriginServer;
|
$options['custom_origin_server'] = $customOriginServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($bundleMethod) === false) {
|
||||||
|
$options['bundle_method'] = $bundleMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($customKey) === false) {
|
||||||
|
$options['custom_key'] = $customKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($customCertificate) === false) {
|
||||||
|
$options['custom_certificate'] = $customCertificate;
|
||||||
|
}
|
||||||
|
|
||||||
$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;
|
||||||
|
|||||||
@@ -17,6 +17,61 @@ class CustomHostnamesTest extends TestCase
|
|||||||
$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);
|
||||||
|
|
||||||
|
$customKey = <<<KEY
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDZfoCUkzkZLCzo
|
||||||
|
OFTtlXU9OYqNFx06J/GOKCwDCyfkY5RY1x6BVrVpTqf/JaU42DZmCjIiEugBg4bu
|
||||||
|
eu9/w21prIWgRKEe8mjrw83+3QSIyQrs+78rqwDptUfL+IyhYln6SBjqPQ569Y0w
|
||||||
|
x6A896PDMYPHgnWtclGwsxDNKJ2eWsH+C4UkLUeVM4BILEJ00YUjayowL/0sflTJ
|
||||||
|
yY58c9fVV27aGBJ4znreYkBojPQ0fzVZ3HJfYD+DgYUUkuzN/WohOLTNTxvzt/i2
|
||||||
|
GNxP8tZzi0E/t4KtGTsIVmROKaCXnmozQyv0VES5TNZL1nxLvVuPca9DKXwVst2o
|
||||||
|
v5czEM8fAgMBAAECggEBANgG/aIVpWYqaaRyp3CgviWE7Oh9J+um1xgzMJwJTaNd
|
||||||
|
gXDIoyUmweQKW3Vjp/uRTl8GC4uqqcUvJivj8dU+gIOw970bzcmWT7616vsV/rX6
|
||||||
|
sp524wh1vt9jzx97DfwSW3rsd8rZwHNDSO1FqxRDiOaNXO4i183iud8/zRVqHTy1
|
||||||
|
5girngsGl7ebTt3LDHDQQ86kND2nVr8xZuFaqs8Td41AsF6DGbB709wMUqoM/obO
|
||||||
|
iUtXCZ5Rrm2a78OUi0cqWsuxdhJjtOW0PBvrPTlSq+1EuQWAWV8HN1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A==
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
|
KEY;
|
||||||
|
$customCertificate = <<<CERTIFICATE
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDmTCCAoGgAwIBAgIULyaeNqp0tOut/wvuxNyKmUxOGYEwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwXDELMAkGA1UEBhMCWFgxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE
|
||||||
|
CgwTRGVmYXVsdCBDb21wYW55IEx0ZDEYMBYGA1UEAwwPYXBwLmV4YW1wbGUuY29t
|
||||||
|
MB4XDTIxMDYxNDIzMzU0MVoXDTIyMDYxNDIzMzU0MVowXDELMAkGA1UEBhMCWFgx
|
||||||
|
FTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55
|
||||||
|
IEx0ZDEYMBYGA1UEAwwPYXBwLmV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEF
|
||||||
|
AAOCAQ8AMIIBCgKCAQEA2X6AlJM5GSws6DhU7ZV1PTmKjRcdOifxjigsAwsn5GOU
|
||||||
|
WNcegVa1aU6n/yWlONg2ZgoyIhLoAYOG7nrvf8NtaayFoEShHvJo68PN/t0EiMkK
|
||||||
|
7Pu/K6sA6bVHy/iMoWJZ+kgY6j0OevWNMMegPPejwzGDx4J1rXJRsLMQzSidnlrB
|
||||||
|
/guFJC1HlTOASCxCdNGFI2sqMC/9LH5UycmOfHPX1Vdu2hgSeM563mJAaIz0NH81
|
||||||
|
WdxyX2A/g4GFFJLszf1qITi0zU8b87f4thjcT/LWc4tBP7eCrRk7CFZkTimgl55q
|
||||||
|
M0Mr9FREuUzWS9Z8S71bj3GvQyl8FbLdqL+XMxDPHwIDAQABo1MwUTAdBgNVHQ4E
|
||||||
|
FgQUbAfyBm0wpM7FqUb1yqeaF4voY/gwHwYDVR0jBBgwFoAUbAfyBm0wpM7FqUb1
|
||||||
|
yqeaF4voY/gwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAO2Dd
|
||||||
|
k/seFjp83caYE/NVdDy5B7l5JeVtruaUdlGbb0xtVhiIdoY43ukhHFw8zuWMW9RX
|
||||||
|
SUbrzwacfKLDBikcefk9go6cMimqYIRF8Hntph1gjjqB0papUm2WVYbsBRv2okys
|
||||||
|
ej0dGSeUEsWjKRTSMkJsbbiEv6oveeSki069zl+tln0UhbHedkIY3rJsFIyoddSu
|
||||||
|
g96r5HPHksnObm1JCym0xd09+msliDkBmq87mxok9m5aEqWX4XvdGfYERV/eD5vC
|
||||||
|
KcW4DoM1KZd8E6tlniglc1jC0pzKfho7Uoe6UtObgHZGNwRYwYy+BHvHYY46ctSI
|
||||||
|
NdZ7G/lUyrBFhsRrhw==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
CERTIFICATE;
|
||||||
|
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
->method('post')
|
->method('post')
|
||||||
->with(
|
->with(
|
||||||
@@ -33,6 +88,9 @@ class CustomHostnamesTest extends TestCase
|
|||||||
'min_tls_version' => '1.2'
|
'min_tls_version' => '1.2'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'bundle_method' => 'optimal',
|
||||||
|
'custom_key' => $customKey,
|
||||||
|
'custom_certificate' => $customCertificate,
|
||||||
'wildcard' => true,
|
'wildcard' => true,
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
@@ -43,7 +101,7 @@ 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', $customKey, $customCertificate);
|
||||||
$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