Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: legacy auth tokens #2153

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const defaults = {
'always-auth': false,
audit: true,
'audit-level': null,
_auth: null,
'auth-type': 'legacy',
before: null,
'bin-links': true,
Expand Down Expand Up @@ -191,6 +192,7 @@ const types = {
all: Boolean,
'allow-same-version': Boolean,
also: [null, 'dev', 'development'],
_auth: [null, String],
'always-auth': Boolean,
audit: Boolean,
'audit-level': ['low', 'moderate', 'high', 'critical', 'none', null],
Expand Down
1 change: 1 addition & 0 deletions lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const flatten = obj => ({
alwaysAuth: obj['always-auth'],
audit: obj.audit,
auditLevel: obj['audit-level'],
_auth: obj._auth,
authType: obj['auth-type'],
ssoType: obj['sso-type'],
ssoPollFrequency: obj['sso-poll-frequency'],
Expand Down
15 changes: 15 additions & 0 deletions tap-snapshots/test-lib-utils-config.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
exports[`test/lib/utils/config.js TAP no process.umask() method > must match snapshot 1`] = `
Object {
"defaults": Object {
"_auth": null,
"access": null,
"all": false,
"allow-same-version": false,
Expand Down Expand Up @@ -267,6 +268,10 @@ Object {
],
},
"types": Object {
"_auth": Array [
null,
"{String TYPE}",
],
"access": Array [
null,
"restricted",
Expand Down Expand Up @@ -537,6 +542,7 @@ Object {
exports[`test/lib/utils/config.js TAP no working network interfaces, on windows > must match snapshot 1`] = `
Object {
"defaults": Object {
"_auth": null,
"access": null,
"all": false,
"allow-same-version": false,
Expand Down Expand Up @@ -796,6 +802,10 @@ Object {
],
},
"types": Object {
"_auth": Array [
null,
"{String TYPE}",
],
"access": Array [
null,
"restricted",
Expand Down Expand Up @@ -1066,6 +1076,7 @@ Object {
exports[`test/lib/utils/config.js TAP working network interfaces, not windows > must match snapshot 1`] = `
Object {
"defaults": Object {
"_auth": null,
"access": null,
"all": false,
"allow-same-version": false,
Expand Down Expand Up @@ -1325,6 +1336,10 @@ Object {
],
},
"types": Object {
"_auth": Array [
null,
"{String TYPE}",
],
"access": Array [
null,
"restricted",
Expand Down
1 change: 1 addition & 0 deletions tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict'
exports[`test/lib/utils/flat-options.js TAP basic > flat options 1`] = `
Object {
"_auth": undefined,
"@scope:registry": "@scope:registry",
"//nerf.dart:_authToken": "//nerf.dart:_authToken",
"access": "access",
Expand Down
12 changes: 12 additions & 0 deletions test/lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ t.test('various default values and falsey fallbacks', t => {
t.end()
})

t.test('legacy _auth token', t => {
const npm = new Mocknpm({
_auth: 'asdfasdf',
})
t.strictSame(
flatOptions(npm)._auth,
'asdfasdf',
'should set legacy _auth token',
)
t.end()
})

t.test('save-type', t => {
const base = {
'save-optional': false,
Expand Down