-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
packages/certs-v5/test/unit/commands/certs/auto/disable.unit.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import color from '@heroku-cli/color' | ||
import {Command, flags} from '@heroku-cli/command' | ||
import {ux} from '@oclif/core' | ||
import confirmApp from '../../../lib/apps/confirm-app' | ||
|
||
export default class Disable extends Command { | ||
static topic = 'certs'; | ||
static description = 'disable ACM for an app'; | ||
static flags = { | ||
confirm: flags.string({char: 'c'}), | ||
app: flags.app({required: true}), | ||
}; | ||
|
||
public async run(): Promise<void> { | ||
const {flags} = await this.parse(Disable) | ||
const {app, confirm} = flags | ||
|
||
const warning = `This command will disable Automatic Certificate Management from ${color.magenta(app)}.\nThis will cause the certificate to be removed from ${app} causing SSL\nvalidation errors. In order to avoid downtime, the recommended steps\nare preferred which will also disable Automatic Certificate Management.\n\n1) Request a new SSL certificate for your domains names from your certificate provider\n2) heroku certs:update CRT KEY\n` | ||
await confirmApp(warning, confirm) | ||
|
||
ux.action.start('Disabling Automatic Certificate Management') | ||
await this.heroku.delete(`/apps/${app}/acm`, { | ||
headers: {Accept: 'application/vnd.heroku+json; version=3.cedar-acm'}, | ||
}) | ||
ux.action.stop() | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/cli/test/unit/commands/certs/auto/disable.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {stdout, stderr} from 'stdout-stderr' | ||
import Cmd from '../../../../../src/commands/certs/auto/disable' | ||
import runCommand from '../../../../helpers/runCommand' | ||
import * as nock from 'nock' | ||
import expectOutput from '../../../../helpers/utils/expectOutput' | ||
import stripAnsi = require('strip-ansi') | ||
import {expect} from 'chai' | ||
|
||
describe('heroku certs:auto:disable', function () { | ||
beforeEach(function () { | ||
nock.cleanAll() | ||
}) | ||
it('disables acm', async function () { | ||
nock('https://api.heroku.com', { | ||
reqheaders: { | ||
Accept: 'application/vnd.heroku+json; version=3.cedar-acm', | ||
}, | ||
}) | ||
.delete('/apps/example/acm') | ||
.reply(200, {acm: true}) | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'example', | ||
'--confirm', | ||
'example', | ||
]) | ||
expectOutput(stderr.output, 'Disabling Automatic Certificate Management... done') | ||
expectOutput(stdout.output, '') | ||
}) | ||
it('confirms that they want to disable', async function () { | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'example', | ||
'--confirm', | ||
'notexample', | ||
]) | ||
.catch(error => { | ||
expect(stripAnsi(error.message)).to.equal('Confirmation notexample did not match example. Aborted.') | ||
}) | ||
}) | ||
}) |