From 224476d14fffe1543c47308c92eeef03d2f64fb6 Mon Sep 17 00:00:00 2001 From: David Tanner Date: Wed, 1 Mar 2023 12:49:51 -0700 Subject: [PATCH 1/2] fix(access): Send options with grant/revoke requests --- lib/commands/access.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/access.js b/lib/commands/access.js index 23e51f071b112..672e5c36ffb96 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -116,11 +116,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) { From 86741de4193c4b877c37e27a7441594daae9cda3 Mon Sep 17 00:00:00 2001 From: David Tanner Date: Wed, 1 Mar 2023 17:53:42 -0700 Subject: [PATCH 2/2] Added test to validate config --- test/lib/commands/access.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/lib/commands/access.js b/test/lib/commands/access.js index b0057545ba026..7ec2c4d38e27b 100644 --- a/test/lib/commands/access.js +++ b/test/lib/commands/access.js @@ -70,10 +70,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 }) @@ -84,10 +90,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'])