|
5 | 5 |
|
6 | 6 | class CertificateTest extends AbstractTestCase
|
7 | 7 | {
|
| 8 | + private array $certificateProperties = [ |
| 9 | + 'bits' => 2048, |
| 10 | + 'country' => 'CH', |
| 11 | + 'state' => 'Schaffhausen', |
| 12 | + 'location' => 'Schaffhausen', |
| 13 | + 'company' => 'Plesk', |
| 14 | + |
| 15 | + 'name' => 'plesk.com', |
| 16 | + ]; |
| 17 | + |
8 | 18 | public function testGenerate()
|
9 | 19 | {
|
10 |
| - $certificate = static::$client->certificate()->generate([ |
11 |
| - 'bits' => 2048, |
12 |
| - 'country' => 'RU', |
13 |
| - 'state' => 'NSO', |
14 |
| - 'location' => 'Novosibirsk', |
15 |
| - 'company' => 'Plesk', |
16 |
| - |
17 |
| - 'name' => 'plesk.com', |
18 |
| - ]); |
| 20 | + $certificate = static::$client->certificate()->generate($this->certificateProperties); |
19 | 21 | $this->assertGreaterThan(0, strlen($certificate->request));
|
20 | 22 | $this->assertStringStartsWith('-----BEGIN CERTIFICATE REQUEST-----', $certificate->request);
|
21 | 23 | $this->assertGreaterThan(0, strlen($certificate->privateKey));
|
22 | 24 | $this->assertStringStartsWith('-----BEGIN PRIVATE KEY-----', $certificate->privateKey);
|
23 | 25 | }
|
| 26 | + |
| 27 | + public function testInstall() |
| 28 | + { |
| 29 | + $certificate = static::$client->certificate()->generate($this->certificateProperties); |
| 30 | + |
| 31 | + $result = static::$client->certificate()->install([ |
| 32 | + 'name' => 'test', |
| 33 | + 'admin' => true, |
| 34 | + ], $certificate->request, $certificate->privateKey); |
| 35 | + $this->assertTrue($result); |
| 36 | + |
| 37 | + static::$client->certificate()->delete('test', ['admin' => true]); |
| 38 | + } |
| 39 | + |
| 40 | + public function testDelete() |
| 41 | + { |
| 42 | + $certificate = static::$client->certificate()->generate($this->certificateProperties); |
| 43 | + |
| 44 | + static::$client->certificate()->install([ |
| 45 | + 'name' => 'test', |
| 46 | + 'admin' => true, |
| 47 | + ], $certificate->request, $certificate->privateKey); |
| 48 | + |
| 49 | + $result = static::$client->certificate()->delete('test', ['admin' => true]); |
| 50 | + $this->assertTrue($result); |
| 51 | + } |
24 | 52 | }
|
0 commit comments