Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds in ability to enable/diable SSL certificates. #83

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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