Skip to content

Commit

Permalink
fix: send options with grant/revoke requests (#6211)
Browse files Browse the repository at this point in the history
* fix(access): Send options with grant/revoke requests

* Added test to validate config
  • Loading branch information
DavidTanner authored Mar 8, 2023
1 parent 26cbe99 commit e455e3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ class Access extends BaseCommand {
}

async #grant (permissions, scope, pkg) {
await libnpmaccess.setPermissions(scope, pkg, permissions)
await libnpmaccess.setPermissions(scope, pkg, permissions, this.npm.flatOptions)
}

async #revoke (scope, pkg) {
await libnpmaccess.removePermissions(scope, pkg)
await libnpmaccess.removePermissions(scope, pkg, this.npm.flatOptions)
}

async #listPackages (owner, pkg) {
Expand Down
16 changes: 14 additions & 2 deletions test/lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ t.test('grant', t => {
})

t.test('read-only', async t => {
const { npm } = await loadMockNpm(t)
const authToken = 'abcd1234'
const { npm } = await loadMockNpm(t, {
config: {
'//registry.npmjs.org/:_authToken': authToken,
},
})
const registry = new MockRegistry({
tap: t,
registry: npm.config.get('registry'),
authorization: authToken,
})
const permissions = 'read-only'
registry.setPermissions({ spec: '@npmcli/test-package', team: '@npm:test-team', permissions })
Expand All @@ -85,10 +91,16 @@ t.test('grant', t => {

t.test('revoke', t => {
t.test('success', async t => {
const { npm } = await loadMockNpm(t)
const authToken = 'abcd1234'
const { npm } = await loadMockNpm(t, {
config: {
'//registry.npmjs.org/:_authToken': authToken,
},
})
const registry = new MockRegistry({
tap: t,
registry: npm.config.get('registry'),
authorization: authToken,
})
registry.removePermissions({ spec: '@npmcli/test-package', team: '@npm:test-team' })
await npm.exec('access', ['revoke', '@npm:test-team', '@npmcli/test-package'])
Expand Down

0 comments on commit e455e3f

Please sign in to comment.