Skip to content

Commit

Permalink
Adds in ability to enable/diable SSL certificates. (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius authored May 7, 2020
1 parent 45c0eee commit 1da4c05
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion src/Commands/SslCertificateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function sslCertificateList(
* @command ssl:info
*/
public function sslCertificateInfo(
OutputInterface $output,
SslCertificates $certificatesAdapter,
$uuid,
$environment,
Expand All @@ -86,4 +85,52 @@ public function sslCertificateInfo(
$this->yell('Private Key');
$this->writeln($certificate->private_key);
}

/**
* Enables an SSL certificate.
*
* @param string $uuid
* @param string $environment
* @param int $certificateId
*
* @command ssl:enable
*/
public function sslCertificateEnable(
SslCertificates $certificatesAdapter,
$uuid,
$environment,
$certificateId
) {
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if ($this->confirm('Are you sure you want to enable this SSL certificate?')) {
$this->say(sprintf('Enabling certificate on %s environment', $environment->label));
$response = $certificatesAdapter->enable($environment->uuid, $certificateId);
$this->waitForNotification($response);
}
}

/**
* Disables an SSL certificate.
*
* @param string $uuid
* @param string $environment
* @param int $certificateId
*
* @command ssl:disable
*/
public function sslCertificateDisable(
SslCertificates $certificatesAdapter,
$uuid,
$environment,
$certificateId
) {
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if ($this->confirm('Are you sure you want to disable this SSL certificate?')) {
$this->say(sprintf('Disabling certificate on %s environment', $environment->label));
$response = $certificatesAdapter->disable($environment->uuid, $certificateId);
$this->waitForNotification($response);
}
}
}
6 changes: 6 additions & 0 deletions tests/AcquiaCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ public static function getFixtureMap()
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234' => [
'get' => 'SslCertificates/getSslCertificate.json'
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234/actions/activate' => [
'post' => 'SslCertificates/activateSslCertificate.json'
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234/actions/deactivate' => [
'post' => 'SslCertificates/deactivateSslCertificate.json'
]
];
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Commands/SslCertificateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public function sslCertificateProvider()
[
['ssl:info', 'devcloud:devcloud2', 'dev', '1234'],
$infoResponse . PHP_EOL,
],
[
['ssl:enable', 'devcloud:devcloud2', 'dev', '1234'],
'> Enabling certificate on Dev environment' . PHP_EOL,
],
[
['ssl:disable', 'devcloud:devcloud2', 'dev', '1234'],
'> Disabling certificate on Dev environment' . PHP_EOL,
]
];
}
Expand Down

0 comments on commit 1da4c05

Please sign in to comment.