Skip to content

Commit

Permalink
feat: show acm failure reason on certs:auto
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jun 19, 2018
1 parent 716234c commit cf36840
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 48 deletions.
18 changes: 14 additions & 4 deletions packages/heroku-cli-plugin-certs-v5/commands/certs/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ let co = require('co')
let cli = require('heroku-cli-util')
let certificateDetails = require('../../lib/certificate_details.js')
let _ = require('lodash')
const {default: color} = require('@heroku-cli/color')

function humanize (value) {
if (!value) {
return 'Waiting'
return color.yellow('Waiting')
}
if (value === 'ok') {
return 'OK'
return color.green('OK')
}
if (value === 'failed') {
return color.red('Failed')
}
// Remove the following lines once we address this in cedar-acm
if (value === 'verified') {
return 'In Progress'
return color.yellow('In Progress')
}
if (value === 'dns-verified') {
return 'DNS Verified'
return color.yellow('DNS Verified')
}
return value.split('-').map((word) => _.capitalize(word)).join(' ')
}
Expand Down Expand Up @@ -54,6 +58,12 @@ function * run (context, heroku) {
{label: 'Domain', key: 'hostname'},
{label: 'Status', key: 'acm_status', format: humanize}
]
if (domains.find(d => d.acm_status_reason)) {
columns.push({
label: 'Reason',
key: 'acm_status_reason'
})
}

cli.log('')
cli.table(domains, {columns})
Expand Down
4 changes: 2 additions & 2 deletions packages/heroku-cli-plugin-certs-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"psl": "^1.1.25"
},
"devDependencies": {
"@oclif/dev-cli": "^1.13.7",
"@oclif/plugin-legacy": "^1.0.11",
"@oclif/dev-cli": "^1.13.15",
"@oclif/plugin-legacy": "^1.0.14",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"lolex": "^1.6.0",
Expand Down
40 changes: 40 additions & 0 deletions packages/heroku-cli-plugin-certs-v5/test/commands/certs/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,44 @@ heroku-failing.heroku-cli-sni-test.com Failing
apiCerts.done()
})
})

it('shows acm_status_reason', function () {
let api = nock('https://api.heroku.com', {
reqheaders: {'Accept': 'application/vnd.heroku+json; version=3.cedar-acm'}
})

let apiCerts = nock('https://api.heroku.com')

api.get('/apps/example').reply(200, {acm: true})
apiCerts.get('/apps/example/sni-endpoints').reply(200, [letsEncrypt])
api.get('/apps/example/domains').reply(200, [
{'kind': 'custom', 'hostname': 'heroku-acm.heroku-cli-sni-test.com', 'cname': 'heroku-acm.heroku-cli-sni-test.com.herokudns.com', 'acm_status': 'ok'},
{'kind': 'custom', 'hostname': 'heroku-failed.heroku-cli-sni-test.com', 'cname': 'heroku-failed.heroku-cli-sni-test.com.herokudns.com', 'acm_status': 'failed', 'acm_status_reason': 'uh oh something failed'}
])

return certs.run({app: 'example'}).then(function () {
expect(cli.stderr).to.equal('')
expect(cli.stdout).to.equal(
`=== Automatic Certificate Management is enabled on example
Certificate details:
Common Name(s): heroku-acm.heroku-cli-sni-test.com
heroku-san-test.heroku-cli-sni-test.com
Expires At: 2012-08-01 21:34 UTC
Issuer: /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
Starts At: 2013-08-01 21:34 UTC
Subject: /CN=heroku-acm.heroku-cli-sni-test.com
SSL certificate is not trusted.
Domain Status Reason
───────────────────────────────────── ────── ──────────────────────
heroku-acm.heroku-cli-sni-test.com OK
heroku-failed.heroku-cli-sni-test.com Failed uh oh something failed
=== Some domains failed validation after multiple attempts, retry by running: heroku certs:auto:refresh
`)
api.done()
apiCerts.done()
})
})
})
110 changes: 68 additions & 42 deletions packages/heroku-cli-plugin-certs-v5/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
strip-ansi "^4.0.0"
supports-color "^5.1.0"

"@heroku-cli/command@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@heroku-cli/command/-/command-8.0.5.tgz#eb7e596c5a17557339f227e058fa700d4c0821e6"
"@heroku-cli/command@^8.0.7":
version "8.0.7"
resolved "https://registry.yarnpkg.com/@heroku-cli/command/-/command-8.0.7.tgz#c601e0d9f8ed8a8a98b1856b3b8e71c3c663bc44"
dependencies:
"@oclif/errors" "^1.0.4"
cli-ux "^3.3.30"
"@oclif/errors" "^1.0.6"
cli-ux "^3.4.1"
debug "^3.1.0"
heroku-client "3.0.6"
http-call "^5.1.0"
http-call "^5.1.1"
netrc-parser "^3.1.4"

"@mrmlnc/readdir-enhanced@^2.2.1":
Expand All @@ -29,39 +29,39 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@oclif/command@^1.4.13", "@oclif/command@^1.4.15":
version "1.4.15"
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.15.tgz#1886c7dd88a40fbc29427bbca04bdb0e1a538133"
"@oclif/command@^1.4.20":
version "1.4.20"
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.20.tgz#7368c9c9f7f596fc8efffd7ec89118feed5203d8"
dependencies:
"@oclif/errors" "^1.0.6"
"@oclif/errors" "^1.0.8"
"@oclif/parser" "^3.3.3"
debug "^3.1.0"
semver "^5.5.0"

"@oclif/config@^1.6.13":
version "1.6.13"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.6.13.tgz#fa4688a8a32afe49fd353a13aac6061b96eac1be"
"@oclif/config@^1.6.17":
version "1.6.17"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.6.17.tgz#e9608f56e5acd49fcaf3bbfcc3e8818d81b1ba12"
dependencies:
debug "^3.1.0"

"@oclif/dev-cli@^1.13.7":
version "1.13.7"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.7.tgz#de93aa07d960835a3ff1cad1a3e5f273d96ae926"
"@oclif/dev-cli@^1.13.15":
version "1.13.15"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.15.tgz#cc02e5b8c1fdb9b04973926e5b9f034c3f7ed64c"
dependencies:
"@oclif/command" "^1.4.15"
"@oclif/config" "^1.6.13"
"@oclif/errors" "^1.0.6"
"@oclif/plugin-help" "^1.2.5"
"@oclif/command" "^1.4.20"
"@oclif/config" "^1.6.17"
"@oclif/errors" "^1.0.8"
"@oclif/plugin-help" "^1.2.10"
cli-ux "^3.4.1"
debug "^3.1.0"
fs-extra "^5.0.0"
lodash "^4.17.5"
fs-extra "^6.0.0"
lodash "^4.17.10"
normalize-package-data "^2.4.0"
qqjs "^0.3.7"
qqjs "^0.3.8"
require-resolve "^0.0.2"
tslib "^1.9.0"

"@oclif/errors@^1.0.4", "@oclif/errors@^1.0.6":
"@oclif/errors@^1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.0.6.tgz#76b17906ac1beea252add52e8e8ed78229c33a7b"
dependencies:
Expand All @@ -71,6 +71,16 @@
strip-ansi "^4.0.0"
wrap-ansi "^3.0.1"

"@oclif/errors@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.0.8.tgz#2f8239267506bb7c3f5fd776144c2686e5b7fff7"
dependencies:
clean-stack "^1.3.0"
fs-extra "^6.0.0"
indent-string "^3.2.0"
strip-ansi "^4.0.0"
wrap-ansi "^3.0.1"

"@oclif/linewrap@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@oclif/linewrap/-/linewrap-1.0.0.tgz#aedcb64b479d4db7be24196384897b5000901d91"
Expand All @@ -82,25 +92,25 @@
"@oclif/linewrap" "^1.0.0"
chalk "^2.4.0"

"@oclif/plugin-help@^1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-1.2.5.tgz#5a184cdac3d0cf9c12b444e693e5102b288bde24"
"@oclif/plugin-help@^1.2.10":
version "1.2.10"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-1.2.10.tgz#c2bb2b8f09027bf5a55e96346b8525d4dcff8c3e"
dependencies:
"@oclif/command" "^1.4.13"
chalk "^2.4.0"
"@oclif/command" "^1.4.20"
chalk "^2.4.1"
indent-string "^3.2.0"
lodash.template "^4.4.0"
string-width "^2.1.1"
widest-line "^2.0.0"
wrap-ansi "^3.0.1"

"@oclif/plugin-legacy@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@oclif/plugin-legacy/-/plugin-legacy-1.0.11.tgz#023d00e8c0bcfcd4b838221b097a7659b4a6ecc8"
"@oclif/plugin-legacy@^1.0.14":
version "1.0.14"
resolved "https://registry.yarnpkg.com/@oclif/plugin-legacy/-/plugin-legacy-1.0.14.tgz#31202b4502641305608b4c101abfe3ca4ad4700f"
dependencies:
"@heroku-cli/color" "^1.1.3"
"@heroku-cli/command" "^8.0.5"
"@oclif/command" "^1.4.13"
"@heroku-cli/command" "^8.0.7"
"@oclif/command" "^1.4.20"
ansi-escapes "^3.1.0"
debug "^3.1.0"
semver "^5.5.0"
Expand Down Expand Up @@ -541,6 +551,14 @@ chalk@^2.3.0:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

chalk@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
Expand Down Expand Up @@ -582,7 +600,7 @@ cli-cursor@^2.1.0:
dependencies:
restore-cursor "^2.0.0"

cli-ux@^3.3.30, cli-ux@^3.4.1:
cli-ux@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-3.4.1.tgz#bfa17e75cd1a60547a11c515166117b05ea89cdd"
dependencies:
Expand Down Expand Up @@ -1303,6 +1321,14 @@ fs-extra@^5.0.0:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.0.tgz#0f0afb290bb3deb87978da816fcd3c7797f3a817"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -1569,7 +1595,7 @@ http-cache-semantics@3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2"

http-call@^5.1.0:
http-call@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/http-call/-/http-call-5.1.1.tgz#0110095d455b876c64cc9fe820b3f836cc552ea7"
dependencies:
Expand Down Expand Up @@ -2161,7 +2187,7 @@ lodash.templatesettings@^4.0.0:
dependencies:
lodash._reinterpolate "~3.0.0"

lodash@4.17.10:
lodash@4.17.10, lodash@^4.17.10:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

Expand Down Expand Up @@ -2781,18 +2807,18 @@ pump@^1.0.0:
end-of-stream "^1.1.0"
once "^1.3.1"

qqjs@^0.3.7:
version "0.3.7"
resolved "https://registry.yarnpkg.com/qqjs/-/qqjs-0.3.7.tgz#eb7d481d3cf3e8c9744da0d21d917d1a4b2080d9"
qqjs@^0.3.8:
version "0.3.8"
resolved "https://registry.yarnpkg.com/qqjs/-/qqjs-0.3.8.tgz#8374d5cb53a2fa51104a3abd2e7371708b7ad913"
dependencies:
chalk "^2.3.2"
chalk "^2.4.1"
debug "^3.1.0"
execa "^0.10.0"
fs-extra "^5.0.0"
get-stream "^3.0.0"
glob "^7.1.2"
globby "^8.0.1"
http-call "^5.1.0"
http-call "^5.1.1"
load-json-file "^4.0.0"
pkg-dir "^2.0.0"
tar-fs "^1.16.0"
Expand Down

0 comments on commit cf36840

Please sign in to comment.