Skip to content

Commit 8eae4b3

Browse files
authored
fix(token): properly await registry request (#7385)
1 parent 140b9c9 commit 8eae4b3

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

lib/commands/token.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Token extends BaseCommand {
4949
async list () {
5050
const conf = this.config()
5151
log.info('token', 'getting list')
52-
const tokens = profile.listTokens(conf)
52+
const tokens = await profile.listTokens(conf)
5353
if (conf.json) {
5454
output.standard(JSON.stringify(tokens, null, 2))
5555
return

test/lib/commands/token.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ t.test('token list', async t => {
7777
return { token: 'thisisnotarealtoken' }
7878
},
7979
profile: {
80-
listTokens: conf => {
80+
listTokens: async conf => {
8181
t.same(conf.auth, { token: 'thisisnotarealtoken', otp: '123456' })
8282
return tokens
8383
},
@@ -118,7 +118,7 @@ t.test('token list json output', async t => {
118118
return { username: 'foo', password: 'bar' }
119119
},
120120
profile: {
121-
listTokens: conf => {
121+
listTokens: async conf => {
122122
t.same(
123123
conf.auth,
124124
{ basic: { username: 'foo', password: 'bar' } },
@@ -164,7 +164,7 @@ t.test('token list parseable output', async t => {
164164
return { auth: Buffer.from('foo:bar').toString('base64') }
165165
},
166166
profile: {
167-
listTokens: conf => {
167+
listTokens: async conf => {
168168
t.same(
169169
conf.auth,
170170
{ basic: { username: 'foo', password: 'bar' } },
@@ -212,11 +212,11 @@ t.test('token revoke', async t => {
212212
return {}
213213
},
214214
profile: {
215-
listTokens: conf => {
215+
listTokens: async conf => {
216216
t.same(conf.auth, {}, 'passes the correct empty auth')
217217
return Promise.resolve([{ key: 'abcd1234' }])
218218
},
219-
removeToken: key => {
219+
removeToken: async key => {
220220
t.equal(key, 'abcd1234', 'deletes the correct token')
221221
},
222222
},
@@ -235,8 +235,8 @@ t.test('token revoke multiple tokens', async t => {
235235
return { token: 'thisisnotarealtoken' }
236236
},
237237
profile: {
238-
listTokens: () => Promise.resolve([{ key: 'abcd1234' }, { key: 'efgh5678' }]),
239-
removeToken: key => {
238+
listTokens: async () => ([{ key: 'abcd1234' }, { key: 'efgh5678' }]),
239+
removeToken: async key => {
240240
// this will run twice
241241
t.ok(['abcd1234', 'efgh5678'].includes(key), 'deletes the correct token')
242242
},
@@ -256,8 +256,8 @@ t.test('token revoke json output', async t => {
256256
return { token: 'thisisnotarealtoken' }
257257
},
258258
profile: {
259-
listTokens: () => Promise.resolve([{ key: 'abcd1234' }]),
260-
removeToken: key => {
259+
listTokens: async () => ([{ key: 'abcd1234' }]),
260+
removeToken: async key => {
261261
t.equal(key, 'abcd1234', 'deletes the correct token')
262262
},
263263
},
@@ -278,8 +278,8 @@ t.test('token revoke parseable output', async t => {
278278
return { token: 'thisisnotarealtoken' }
279279
},
280280
profile: {
281-
listTokens: () => Promise.resolve([{ key: 'abcd1234' }]),
282-
removeToken: key => {
281+
listTokens: async () => ([{ key: 'abcd1234' }]),
282+
removeToken: async key => {
283283
t.equal(key, 'abcd1234', 'deletes the correct token')
284284
},
285285
},
@@ -298,8 +298,8 @@ t.test('token revoke by token', async t => {
298298
return { token: 'thisisnotarealtoken' }
299299
},
300300
profile: {
301-
listTokens: () => Promise.resolve([{ key: 'abcd1234', token: 'efgh5678' }]),
302-
removeToken: key => {
301+
listTokens: async () => ([{ key: 'abcd1234', token: 'efgh5678' }]),
302+
removeToken: async key => {
303303
t.equal(key, 'efgh5678', 'passes through user input')
304304
},
305305
},
@@ -323,7 +323,7 @@ t.test('token revoke ambiguous id errors', async t => {
323323
return { token: 'thisisnotarealtoken' }
324324
},
325325
profile: {
326-
listTokens: () => Promise.resolve([{ key: 'abcd1234' }, { key: 'abcd5678' }]),
326+
listTokens: async () => ([{ key: 'abcd1234' }, { key: 'abcd5678' }]),
327327
},
328328
})
329329

@@ -338,7 +338,7 @@ t.test('token revoke unknown id errors', async t => {
338338
return { token: 'thisisnotarealtoken' }
339339
},
340340
profile: {
341-
listTokens: () => Promise.resolve([{ key: 'abcd1234' }]),
341+
listTokens: async () => ([{ key: 'abcd1234' }]),
342342
},
343343
})
344344

@@ -362,7 +362,7 @@ t.test('token create', async t => {
362362
password: () => Promise.resolve(password),
363363
},
364364
profile: {
365-
createToken: (pw, readonly, cidr) => {
365+
createToken: async (pw, readonly, cidr) => {
366366
t.equal(pw, password)
367367
t.equal(readonly, false)
368368
t.same(cidr, ['10.0.0.0/8', '192.168.1.0/24'], 'defaults to empty array')
@@ -405,7 +405,7 @@ t.test('token create json output', async t => {
405405
password: () => Promise.resolve(password),
406406
},
407407
profile: {
408-
createToken: (pw, readonly, cidr) => {
408+
createToken: async (pw, readonly, cidr) => {
409409
t.equal(pw, password)
410410
t.equal(readonly, false)
411411
t.same(cidr, [], 'defaults to empty array')
@@ -447,7 +447,7 @@ t.test('token create parseable output', async t => {
447447
password: () => Promise.resolve(password),
448448
},
449449
profile: {
450-
createToken: (pw, readonly, cidr) => {
450+
createToken: async (pw, readonly, cidr) => {
451451
t.equal(pw, password)
452452
t.equal(readonly, false)
453453
t.same(cidr, [], 'defaults to empty array')

0 commit comments

Comments
 (0)