This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Checkdomain\Comodo\Tests; |
||
3 | |||
4 | use Checkdomain\Comodo\Model\Result\AutoApplyResult; |
||
5 | use Checkdomain\Comodo\Model\Result\AutoReplaceResult; |
||
6 | use Checkdomain\Comodo\Model\Result\GetDCVEMailAddressListResult; |
||
7 | use Checkdomain\Comodo\Model\Result\GetMDCDomainDetailsResult; |
||
8 | |||
9 | class UtilTest extends AbstractTest |
||
10 | { |
||
11 | /** |
||
12 | * test for applying SSL |
||
13 | */ |
||
14 | public function testAutoApplySSL() |
||
15 | { |
||
16 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
17 | 'errorCode' => 1, |
||
18 | 'totalCost' => 12.98, |
||
19 | 'orderNumber' => '123456789', |
||
20 | 'certificateID' => 'abc123456', |
||
21 | 'expectedDeliveryTime' => '123456' |
||
22 | ]))); |
||
23 | |||
24 | $result = $util->autoApplySSL([ |
||
25 | 'test' => 'Y', |
||
26 | 'product' => 287, |
||
27 | 'serverSoftware' => 2, |
||
28 | 'csr' => ('-----BEGIN CERTIFICATE REQUEST-----base64-----END CERTIFICATE REQUEST-----'), |
||
29 | 'isCustomerValidated' => 'Y', |
||
30 | 'showCertificateID' => 'Y', |
||
31 | 'days' => 365, |
||
32 | ]); |
||
33 | |||
34 | $this->assertInstanceOf(AutoApplyResult::class, $result); |
||
35 | $this->assertEquals('12.98', $result->getTotalCost()); |
||
36 | $this->assertEquals('123456', $result->getExpectedDeliveryTime()); |
||
37 | $this->assertEquals('abc123456', $result->getCertificateID()); |
||
38 | $this->assertEquals('123456789', $result->getOrderNumber()); |
||
39 | $this->assertFalse($result->getPaid()); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * test for getting dvc mail addresses |
||
44 | */ |
||
45 | public function testGetDCVEMailAddressList() |
||
46 | { |
||
47 | // simulated response Text |
||
48 | $responseText = '0'.chr(10) |
||
49 | .'domain_name www.test-domain.org'.chr(10) |
||
50 | .'whois_email [email protected]'.chr(10) |
||
51 | .'level2_email [email protected]'.chr(10) |
||
52 | .'level2_email [email protected]'.chr(10) |
||
53 | .'level3_email [email protected]'.chr(10) |
||
54 | .'level3_email [email protected]'.chr(10); |
||
55 | |||
56 | $util = $this->createUtil($this->createGuzzleClient($responseText)); |
||
57 | |||
58 | $result = $util->getDCVEMailAddressList(['domainName' => 'www.test-domain.org']); |
||
59 | |||
60 | $this->assertInstanceOf(GetDCVEMailAddressListResult::class, $result); |
||
61 | $this->assertEquals(['[email protected]'], $result->getWhoisEmail()); |
||
62 | $this->assertEquals('www.test-domain.org', $result->getDomainName()); |
||
63 | $this->assertEquals(['[email protected]', '[email protected]'], $result->getLevel2Emails()); |
||
64 | $this->assertEquals( |
||
65 | ['[email protected]', '[email protected]'], |
||
66 | $result->getLevel3Emails() |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * test for resending dcv mail |
||
72 | */ |
||
73 | public function testResendDCVEMail() |
||
74 | { |
||
75 | $util = $this->createUtil($this->createGuzzleClient('errorCode=0')); |
||
76 | |||
77 | $this->assertTrue($util->resendDCVEMail([ |
||
78 | 'orderNumber' => '1234567', |
||
79 | 'dcvEmailAddress' => '[email protected]', |
||
80 | ])); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * test for entering dcv code |
||
85 | */ |
||
86 | public function testEnterDCVCode() |
||
87 | { |
||
88 | // simulated response Text |
||
89 | $responseText = '<html><body><p>You have entered the correct Domain Control Validation code. ' |
||
90 | .'Your certificate will now be issued and emailed to you shortly. ' |
||
91 | .'Please close this window now.' |
||
92 | .'</p></body></html>'; |
||
93 | |||
94 | $util = $this->createUtil($this->createGuzzleClient($responseText)); |
||
95 | |||
96 | $this->assertTrue($util->enterDcvCode([ |
||
97 | 'orderNumber' => '1234567', |
||
98 | 'dcvCode' => 'testtesttest', |
||
99 | ])); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * test for revoke ssl |
||
104 | */ |
||
105 | public function testAutoRevokeSSL() |
||
106 | { |
||
107 | $util = $this->createUtil($this->createGuzzleClient('errorCode=0')); |
||
108 | |||
109 | $this->assertTrue($util->autoRevokeSSL(['orderNumber' => '1234567'])); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * test for auto replacing ssl |
||
114 | */ |
||
115 | public function testAutoReplaceSSL() |
||
116 | { |
||
117 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
118 | 'errorCode' => 0, |
||
119 | 'expectedDeliveryTime' => 0, |
||
120 | 'certificateID' => 'abc123456', |
||
121 | ]))); |
||
122 | |||
123 | $result = $util->autoReplaceSSL(['orderNumber' => '1234567']); |
||
124 | |||
125 | $this->assertInstanceOf(AutoReplaceResult::class, $result); |
||
126 | $this->assertEquals('0', $result->getExpectedDeliveryTime()); |
||
127 | $this->assertEquals('abc123456', $result->getCertificateID()); |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * test for auto updating dcv method |
||
132 | */ |
||
133 | public function testAutoUpdateDcv() |
||
134 | { |
||
135 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
136 | 'errorCode' => 0, |
||
137 | 'expectedDeliveryTime' => 0, |
||
138 | 'certificateID' => 'abc123456', |
||
139 | ]))); |
||
140 | |||
141 | $this->assertTrue($util->autoUpdateDCV([ |
||
142 | 'orderNumber' => '1234567', |
||
143 | 'newDCVEmailAddress' => '[email protected]', |
||
144 | 'newMethod' => 'EMAIL', |
||
145 | ])); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * test for providing ev details |
||
150 | */ |
||
151 | public function testProvideEvDetails() |
||
152 | { |
||
153 | $util = $this->createUtil($this->createGuzzleClient('errorCode=0')); |
||
154 | |||
155 | $this->assertTrue($util->autoUpdateDCV([ |
||
156 | 'orderNumber' => '1234567', |
||
157 | 'certReqForename' => 'John', |
||
158 | 'certReqSurname' => 'Test', |
||
159 | ])); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * test for getting current dcv method |
||
164 | */ |
||
165 | public function testGetMdcDomainDetails() |
||
166 | { |
||
167 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
168 | 'errorCode' => 0, |
||
169 | '1_domainName' => 'test.com', |
||
170 | '1_dcvMethod' => 'EMAIL', |
||
171 | '1_dcvStatus' => 'Validated', |
||
172 | ]))); |
||
173 | |||
174 | $result = $util->getMDCDomainDetails(['orderNumber' => '1234567']); |
||
175 | |||
176 | $this->assertInstanceOf(GetMDCDomainDetailsResult::class, $result); |
||
177 | $this->assertEquals('test.com', $result->getDomainName()); |
||
178 | $this->assertEquals('EMAIL', $result->getDcvMethod()); |
||
179 | $this->assertEquals('Validated', $result->getDcvStatus()); |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * test, if request-string is correctly formatted |
||
184 | */ |
||
185 | public function testCheckRequestString() |
||
186 | { |
||
187 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
188 | 'errorCode' => 0, |
||
189 | 'certificateID' => 'abc1231556', |
||
190 | 'expectedDeliveryTime' => 0, |
||
191 | 'orderNumber' => 12345678, |
||
192 | 'totalCost' => 12.45, |
||
193 | ]))); |
||
194 | |||
195 | $result = $util->autoApplySSL([ |
||
196 | 'orderNumber' => '1234567', |
||
197 | 'dcvMethod' => 'EMAIL', |
||
198 | ]); |
||
199 | |||
200 | $this->assertEquals( |
||
201 | 'orderNumber=1234567&dcvMethod=EMAIL&responseFormat=1&showCertificateID=Y', |
||
202 | $result->getRequestQuery() |
||
203 | ); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * @expectedException \Checkdomain\Comodo\Model\Exception\RequestException |
||
208 | */ |
||
209 | View Code Duplication | public function testRequestException() |
|
0 ignored issues
–
show
|
|||
210 | { |
||
211 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
212 | 'errorCode' => -1, |
||
213 | 'errorMessage' => 'Invalid Request', |
||
214 | ]))); |
||
215 | |||
216 | $util->autoApplySSL([]); |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * @expectedException \Checkdomain\Comodo\Model\Exception\ArgumentException |
||
221 | */ |
||
222 | View Code Duplication | public function testArgumentException() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
223 | { |
||
224 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
225 | 'errorCode' => -2, |
||
226 | 'errorItem' => 'field', |
||
227 | 'errorMessage' => 'Invalid Request', |
||
228 | ]))); |
||
229 | |||
230 | $util->autoApplySSL([]); |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * @expectedException \Checkdomain\Comodo\Model\Exception\AccountException |
||
235 | */ |
||
236 | View Code Duplication | public function testAccountException() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
237 | { |
||
238 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
239 | 'errorCode' => -15, |
||
240 | 'errorMessage' => 'Invalid Request', |
||
241 | ]))); |
||
242 | |||
243 | $util->autoApplySSL([]); |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * @expectedException \Checkdomain\Comodo\Model\Exception\CsrException |
||
248 | */ |
||
249 | View Code Duplication | public function testCsrException() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
250 | { |
||
251 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
252 | 'errorCode' => -5, |
||
253 | 'errorMessage' => 'Invalid Request', |
||
254 | ]))); |
||
255 | |||
256 | $util->autoApplySSL([]); |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @expectedException \Checkdomain\Comodo\Model\Exception\UnknownApiException |
||
261 | */ |
||
262 | View Code Duplication | public function testUnknownApiException() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
263 | { |
||
264 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
265 | 'errorCode' => -14, |
||
266 | 'errorMessage' => 'Invalid Request', |
||
267 | ]))); |
||
268 | |||
269 | $util->autoApplySSL([]); |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * @expectedException \Checkdomain\Comodo\Model\Exception\UnknownException |
||
274 | */ |
||
275 | public function testUnknownException() |
||
276 | { |
||
277 | $util = $this->createUtil($this->createGuzzleClient('Internal Server Error')); |
||
278 | |||
279 | $util->autoApplySSL([]); |
||
280 | } |
||
281 | |||
282 | /** |
||
283 | * test, for getting status of certificate |
||
284 | */ |
||
285 | public function testCollectSslStatus() |
||
286 | { |
||
287 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
288 | 'errorCode' => 1, |
||
289 | 'orderNumber' => 12345678, |
||
290 | 'certificateStatus' => 'Issued', |
||
291 | ]))); |
||
292 | |||
293 | $result = $util->collectSsl(['showExtStatus' => 'Y']); |
||
294 | |||
295 | $this->assertEquals('Issued', $result->getCertificateStatus()); |
||
296 | } |
||
297 | |||
298 | |||
299 | /** |
||
300 | * test, for getting status of certificate |
||
301 | */ |
||
302 | public function testUpdateUserEvClickThrough() |
||
303 | { |
||
304 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
305 | 'errorCode' => 0, |
||
306 | 'status' => 1, |
||
307 | ]))); |
||
308 | |||
309 | $result = $util->updateUserEvClickThrough([]); |
||
310 | |||
311 | $this->assertEquals(1, $result->getStatus()); |
||
312 | } |
||
313 | |||
314 | /** |
||
315 | * test, for getting period of certificate |
||
316 | */ |
||
317 | public function testCollectSslPeriod() |
||
318 | { |
||
319 | $caCertificate = ['-----BEGIN CERTIFICATE-----'.chr(10).'123'.chr(10).'-----END CERTIFICATE-----']; |
||
320 | $certificate = '-----BEGIN CERTIFICATE-----'.chr(10).'234'.chr(10). '-----END CERTIFICATE-----'; |
||
321 | |||
322 | $util = $this->createUtil($this->createGuzzleClient(http_build_query([ |
||
323 | 'errorCode' => 1, |
||
324 | 'orderNumber' => 12345678, |
||
325 | 'notBefore' => 1388576001, |
||
326 | 'notAfter' => 1420112001, |
||
327 | 'csrStatus' => 4, |
||
328 | 'certificateStatus' => 3, |
||
329 | 'validationStatus' => 1, |
||
330 | 'certificate' => 234, |
||
331 | 'caCertificate' => 123, |
||
332 | 'ovCallBackStatus' => 2, |
||
333 | ]))); |
||
334 | |||
335 | $result = $util->collectSsl([]); |
||
336 | |||
337 | $this->assertEquals($caCertificate, $result->getCaCertificate()); |
||
338 | $this->assertEquals($certificate, $result->getCertificate()); |
||
339 | $this->assertEquals('1', $result->getValidationStatus()); |
||
340 | $this->assertEquals('2', $result->getOvCallBackStatus()); |
||
341 | $this->assertEquals('3', $result->getCertificateStatus()); |
||
342 | $this->assertEquals('4', $result->getCsrStatus()); |
||
343 | $this->assertEquals('12345678', $result->getOrderNumber()); |
||
344 | $this->assertEquals('01.01.2014', $result->getNotBefore()->format('d.m.Y')); |
||
345 | $this->assertEquals('01.01.2015', $result->getNotAfter()->format('d.m.Y')); |
||
346 | } |
||
347 | } |
||
348 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.