feat: Add show option to the certs plugin

The 'server.key' and 'server.crt' can printed to stdin.
The two options are:
    `dokku certs:show <app> key > server.key`
    `dokku certs:show <app> crt > server.crt`
This will create two files, `server.key` and `server.crt`.
Those files contain the private key and the certificate.

Includes tests.
This commit is contained in:
Roland van Laar
2020-07-01 15:22:51 +02:00
parent dbd86ad7a2
commit be0ba28570
4 changed files with 66 additions and 0 deletions

View File

@@ -75,3 +75,29 @@ teardown() {
echo "status: $status"
assert_success
}
@test "(certs) certs:show" {
run /bin/bash -c "dokku certs:show fake-app-name 2>&1"
echo "output: $output"
echo "status: $status"
assert_output_contains "App fake-app-name does not exist"
assert_failure
run /bin/bash -c "dokku certs:show $TEST_APP fake-var-name"
echo "output: $output"
echo "status: $status"
assert_output_contains "specify either 'key' or 'crt'"
assert_failure
run /bin/bash -c "dokku certs:add $TEST_APP < $BATS_TEST_DIRNAME/server_ssl.tar && dokku certs:show $TEST_APP crt"
echo "output: $output"
echo "status: $status"
assert_output_contains "-----END CERTIFICATE-----"
assert_success
run /bin/bash -c "dokku certs:add $TEST_APP < $BATS_TEST_DIRNAME/server_ssl.tar && dokku certs:show $TEST_APP key"
echo "output: $output"
echo "status: $status"
assert_output_contains "-----END RSA PRIVATE KEY-----"
assert_success
}