summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/map-to-registry.js
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2016-03-29 23:30:51 -0700
committerMyles Borins <mborins@us.ibm.com>2016-04-01 14:47:39 -0700
commit0928584444ac6edf1ead0b93c9d05b1124183702 (patch)
treef64c5646b8e2817009e7afe97c2670c73d38a7eb /deps/npm/test/tap/map-to-registry.js
parent39de601e1c3eda92eb2e37eca4e6aa960f206f39 (diff)
downloadandroid-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.tar.gz
android-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.tar.bz2
android-node-v8-0928584444ac6edf1ead0b93c9d05b1124183702.zip
deps: upgrade npm to 3.8.3
PR-URL: https://github.com/npm/node/pull/6 Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'deps/npm/test/tap/map-to-registry.js')
-rw-r--r--deps/npm/test/tap/map-to-registry.js81
1 files changed, 78 insertions, 3 deletions
diff --git a/deps/npm/test/tap/map-to-registry.js b/deps/npm/test/tap/map-to-registry.js
index 9f6673b92c..d9677bd7e0 100644
--- a/deps/npm/test/tap/map-to-registry.js
+++ b/deps/npm/test/tap/map-to-registry.js
@@ -48,7 +48,7 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/design/-/rewrite/')
})
@@ -66,7 +66,7 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/-/rewrite/')
})
@@ -84,8 +84,83 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/design/-/rewrite/relative/')
})
})
+
+test('mapToRegistry token scoping', function (t) {
+ npm.config.set('scope', '')
+ npm.config.set('registry', 'https://reg.npm/')
+ npm.config.set('//reg.npm/:_authToken', 'r-token')
+
+ t.test('pass token to registry host', function (t) {
+ mapRegistry(
+ 'https://reg.npm/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://reg.npm/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: 'r-token',
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: false
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.test("don't pass token to non-registry host", function (t) {
+ mapRegistry(
+ 'https://butts.lol/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://butts.lol/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: undefined,
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: false
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.test('pass token to non-registry host with always-auth', function (t) {
+ npm.config.set('always-auth', true)
+ mapRegistry(
+ 'https://butts.lol/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://butts.lol/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: 'r-token',
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: true
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.end()
+})