diff --git a/lib/commands/access.js b/lib/commands/access.js index c8ac83529e58d..318151fc81e2c 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -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) { diff --git a/test/lib/commands/access.js b/test/lib/commands/access.js index f0117098a5b55..d1839aaaef219 100644 --- a/test/lib/commands/access.js +++ b/test/lib/commands/access.js @@ -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 }) @@ -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'])