Skip to content

Commit d97cf24

Browse files
authored
Merge pull request cloudflare#180 from phily245/179-missing-support-for-custom-hostname-update-properties
Missing Support For Custom Hostname Update Properties
2 parents a73da76 + ba875c3 commit d97cf24

2 files changed

Lines changed: 63 additions & 9 deletions

File tree

src/Endpoints/CustomHostnames.php

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,33 @@ public function getHostname(string $zoneID, string $hostnameID)
143143

144144
/**
145145
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
146+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
147+
* @SuppressWarnings(PHPMD.NPathComplexity)
146148
*
147-
* @param string $zoneID
148-
* @param string $hostnameID
149-
* @param string $sslMethod
150-
* @param string $sslType
149+
* @param string $zoneID
150+
* @param string $hostnameID
151+
* @param string $sslMethod
152+
* @param string $sslType
153+
* @param array $sslSettings
154+
* @param string $customOriginServer
155+
* @param bool|null $wildcard
156+
* @param string $bundleMethod
157+
* @param array $customSsl
151158
* @return \stdClass
152159
*/
153-
public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = '', array $sslSettings = [], string $customOriginServer = ''): \stdClass
154-
{
160+
public function updateHostname(
161+
string $zoneID,
162+
string $hostnameID,
163+
string $sslMethod = '',
164+
string $sslType = '',
165+
array $sslSettings = [],
166+
string $customOriginServer = '',
167+
bool $wildcard = null,
168+
string $bundleMethod = '',
169+
array $customSsl = []
170+
): \stdClass {
155171
$query = [];
172+
$options = [];
156173

157174
if (!empty($sslMethod)) {
158175
$query['method'] = $sslMethod;
@@ -166,6 +183,22 @@ public function updateHostname(string $zoneID, string $hostnameID, string $sslMe
166183
$query['settings'] = $sslSettings;
167184
}
168185

186+
if (!is_null($wildcard)) {
187+
$query['wildcard'] = $wildcard;
188+
}
189+
190+
if (!empty($bundleMethod)) {
191+
$query['bundle_method'] = $bundleMethod;
192+
}
193+
194+
if (!empty($customSsl['key'])) {
195+
$query['custom_key'] = $customSsl['key'];
196+
}
197+
198+
if (!empty($customSsl['certificate'])) {
199+
$query['custom_certificate'] = $customSsl['certificate'];
200+
}
201+
169202
if (!empty($query)) {
170203
$options = [
171204
'ssl' => $query

tests/Endpoints/CustomHostnamesTest.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public function testUpdateHostname()
121121
{
122122
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json');
123123

124+
$customSsl = $this->getCustomSsl();
125+
124126
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
125127
$mock->method('patch')->willReturn($response);
126128

@@ -137,7 +139,12 @@ public function testUpdateHostname()
137139
'http2' => 'on',
138140
'http3' => 'on',
139141
'min_tls_version' => '1.2'
140-
]
142+
],
143+
'bundle_method' => 'optimal',
144+
'custom_key' => $customSsl['key'],
145+
'custom_certificate' => $customSsl['certificate'],
146+
'wildcard' => true,
147+
141148
]
142149
])
143150
);
@@ -148,7 +155,21 @@ public function testUpdateHostname()
148155
'http3' => 'on',
149156
'min_tls_version' => '1.2'
150157
];
151-
$result = $zones->updateHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 'http', 'dv', $sslSettings, 'origin.example.com');
158+
159+
$result = $zones->updateHostname(
160+
'023e105f4ecef8ad9ca31a8372d0c353',
161+
'0d89c70d-ad9f-4843-b99f-6cc0252067e9',
162+
'http',
163+
'dv',
164+
$sslSettings,
165+
'origin.example.com',
166+
true,
167+
'optimal',
168+
[
169+
'key' => $customSsl['key'],
170+
'certificate' => $customSsl['certificate'],
171+
]
172+
);
152173

153174
$this->assertObjectHasAttribute('id', $result);
154175
$this->assertObjectHasAttribute('hostname', $result);
@@ -194,7 +215,7 @@ public function testGetHostnameFallbackOrigin()
194215
$this->assertObjectHasAttribute('origin', $result);
195216
$this->assertObjectHasAttribute('status', $result);
196217
}
197-
218+
198219
private function getCustomSsl(): array
199220
{
200221
$customKey = <<<KEY

0 commit comments

Comments
 (0)