From 33ada9f9470dd59fcdeb5bb2cc74819d07bd6f7c Mon Sep 17 00:00:00 2001 From: zkochan Date: Tue, 25 Apr 2017 20:09:12 +0300 Subject: [PATCH] test: when pkg meta is not on the domain on which the tarball --- package.json | 2 +- shrinkwrap.yaml | 6 +++--- test/install/auth.ts | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 72953df5e6..8f0d46ae4b 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "ncp": "^2.0.0", "npm-run-all": "^4.0.1", "npm-scripts-info": "^0.3.6", - "pnpm-registry-mock": "^0.6.0", + "pnpm-registry-mock": "^0.6.1", "rimraf": "^2.5.4", "sepia": "^2.0.2", "tape": "^4.6.3", diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index 6d1c19dbeb..6ac4f2e0c1 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -66,7 +66,7 @@ dependencies: pnpm-file-reporter@^0.0.1: 0.0.1 pnpm-install-checks@^1.1.0: 1.1.0 pnpm-logger@^0.3.0: 0.3.0 - pnpm-registry-mock@^0.6.0: 0.6.0 + pnpm-registry-mock@^0.6.1: 0.6.1 proper-lockfile@^2.0.0: 2.0.1 ramda@^0.23.0: 0.23.0 read-pkg@^2.0.0: 2.0.0 @@ -1551,12 +1551,12 @@ packages: dependencies: bole: 3.0.2 resolution: eaecea5a037f053a64c50bda7eda3cb87f5ed661 - /pnpm-registry-mock/0.6.0: + /pnpm-registry-mock/0.6.1: dependencies: cpr: 2.0.2 rimraf: 2.6.1 verdaccio: 2.1.5 - resolution: 6fabea29d7c59e2b9782dca27005cd9c03a06d1f + resolution: babaab1dbadc1662f43c0bab47f549db8c403b23 /prepend-http/1.0.4: d4f4562b0ce3696e41ac52d0e002e57a635dc6dc /preserve/0.2.0: 815ed1f6ebc65926f865b310c0713bcb3315ce4b /process-nextick-args/1.0.7: 150e20b756590ad3f91093f25a4f2ad8bff30ba3 diff --git a/test/install/auth.ts b/test/install/auth.ts index d61df9313e..a27ddeb9e6 100644 --- a/test/install/auth.ts +++ b/test/install/auth.ts @@ -35,3 +35,30 @@ test('a package that need authentication', async function (t: tape.Test) { t.ok(typeof m === 'function', 'needs-auth() is available') }) + +test('a package that need authentication reuses authorization tokens for tarball fetching', async function (t: tape.Test) { + const project = prepare(t) + + const client = new RegClient() + + const data = await new Promise((resolve, reject) => { + client.adduser('http://localhost:4873', { + auth: { + username: 'foo', + password: 'bar', + email: 'foo@bar.com', + } + }, (err: Error, data: Object) => err ? reject(err) : resolve(data)) + }) + + await installPkgs(['needs-auth'], testDefaults({ + registry: 'http://127.0.0.1:4873', + rawNpmConfig: { + '//127.0.0.1:4873/:_authToken': data['token'], + }, + })) + + const m = project.requireModule('needs-auth') + + t.ok(typeof m === 'function', 'needs-auth() is available') +})