test: when pkg meta is not on the domain on which the tarball

This commit is contained in:
zkochan
2017-04-25 20:09:12 +03:00
parent c8036fc930
commit 33ada9f947
3 changed files with 31 additions and 4 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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')
})