Skip to content
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
8 changes: 2 additions & 6 deletions lib/commands/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ class Token extends BaseCommand {
this.generateTokenIds(tokens, 6)
const chalk = this.npm.chalk
for (const token of tokens) {
const level = token.readonly ? 'Read only token' : 'Publish token'
const created = String(token.created).slice(0, 10)
output.standard(`${chalk.blue(level)} ${token.token}… with id ${chalk.cyan(token.id)} created ${created}`)
output.standard(`${chalk.blue('Token')} ${token.token}… with id ${chalk.cyan(token.id)} created ${created}`)
if (token.cidr_whitelist) {
output.standard(`with IP whitelist: ${chalk.green(token.cidr_whitelist.join(','))}`)
}
Expand Down Expand Up @@ -231,10 +230,7 @@ class Token extends BaseCommand {
Object.keys(result).forEach(k => output.standard(k + '\t' + result[k]))
} else {
const chalk = this.npm.chalk
// Display based on access level
// Identical to list? XXX
const level = result.access === 'read-only' || result.readonly ? 'read only' : 'publish'
output.standard(`Created ${chalk.blue(level)} token ${result.token}`, { [META]: true, redact: false })
output.standard(`Created token ${result.token}`, { [META]: true, redact: false })
if (result.cidr_whitelist?.length) {
output.standard(`with IP whitelist: ${chalk.green(result.cidr_whitelist.join(','))}`)
}
Expand Down
12 changes: 6 additions & 6 deletions test/lib/commands/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ t.test('token list', async t => {
registry.getTokens(tokens)
await npm.exec('token', [])
t.strictSame(outputs, [
`Publish token efgh5678efgh5678… with id abcd123 created ${now.slice(0, 10)}`,
`Token efgh5678efgh5678… with id abcd123 created ${now.slice(0, 10)}`,
'',
`Read only token hgfe8765… with id abcd125 created ${now.slice(0, 10)}`,
`Token hgfe8765… with id abcd125 created ${now.slice(0, 10)}`,
'with IP whitelist: 192.168.1.1/32',
'',
])
Expand Down Expand Up @@ -263,7 +263,7 @@ t.test('token create defaults', async t => {
})

await npm.exec('token', ['create'])
t.match(outputs, ['Created publish token n3wt0k3n'])
t.match(outputs, ['Created token n3wt0k3n'])
})

t.test('token create extra token attributes', async t => {
Expand Down Expand Up @@ -311,7 +311,7 @@ t.test('token create extra token attributes', async t => {

await npm.exec('token', ['create'])
t.match(outputs, [
'Created read only token n3wt0k3n',
'Created token n3wt0k3n',
'with IP whitelist: 10.0.0.0/8,192.168.1.0/24',
`expires: ${expires.toISOString()}`,
])
Expand Down Expand Up @@ -340,7 +340,7 @@ t.test('token create access.read-only', async t => {
})

await npm.exec('token', ['create'])
t.match(outputs, ['Created read only token n3wt0k3n'])
t.match(outputs, ['Created token n3wt0k3n'])
})

t.test('token create readonly', async t => {
Expand Down Expand Up @@ -368,7 +368,7 @@ t.test('token create readonly', async t => {
})

await npm.exec('token', ['create'])
t.match(outputs, ['Created read only token n3wt0k3n'])
t.match(outputs, ['Created token n3wt0k3n'])
})

t.test('token create json output', async t => {
Expand Down
Loading