-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(certs-v5): move certs:auto:refresh to CLI & upgrade to oclif (…
…#2668) * Convert acm refresh command to oclif * Fix spacing lint issue * Remove v5 versions of certs auto refresh
- Loading branch information
Showing
4 changed files
with
50 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
packages/certs-v5/test/unit/commands/certs/auto/refresh.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,21 @@ | ||
import {Command, flags} from '@heroku-cli/command' | ||
import {ux} from '@oclif/core' | ||
|
||
export default class Refresh extends Command { | ||
static topic = 'certs'; | ||
static description = 'refresh ACM for an app'; | ||
static flags = { | ||
app: flags.app({required: true}), | ||
}; | ||
|
||
public async run(): Promise<void> { | ||
const {flags} = await this.parse(Refresh) | ||
|
||
ux.action.start('Refreshing Automatic Certificate Management') | ||
await this.heroku.patch(`/apps/${flags.app}/acm`, { | ||
headers: {Accept: 'application/vnd.heroku+json; version=3.cedar-acm'}, | ||
body: {acm_refresh: true}, | ||
}) | ||
ux.action.stop() | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/cli/test/unit/commands/certs/auto/refresh.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,29 @@ | ||
import {stdout, stderr} from 'stdout-stderr' | ||
import Cmd from '../../../../../src/commands/certs/auto/refresh' | ||
import runCommand from '../../../../helpers/runCommand' | ||
import expectOutput from '../../../../helpers/utils/expectOutput' | ||
import heredoc from 'tsheredoc' | ||
import * as nock from 'nock' | ||
|
||
describe('heroku certs:auto:enable', function () { | ||
beforeEach(function () { | ||
nock.cleanAll() | ||
}) | ||
|
||
it('refreshes acm', async function () { | ||
nock('https://api.heroku.com', { | ||
reqheaders: {Accept: 'application/vnd.heroku+json; version=3.cedar-acm'}, | ||
}) | ||
.patch('/apps/example/acm', {acm_refresh: true}) | ||
.reply(200, {acm: true, acm_refresh: true}) | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'example', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Refreshing Automatic Certificate Management... | ||
Refreshing Automatic Certificate Management... done | ||
`)) | ||
expectOutput((stdout.output), '') | ||
}) | ||
}) |