mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 20:41:47 -04:00
test: installing of private package from shrinkwrap
When resolution is saved in cache and the meta info is on a different path. Correct auth info should be used for downloading the tarball. Close #718
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import tape = require('tape')
|
||||
import promisifyTape from 'tape-promise'
|
||||
import path = require('path')
|
||||
import {
|
||||
prepare,
|
||||
testDefaults,
|
||||
} from '../utils'
|
||||
import {installPkgs} from '../../src'
|
||||
import {installPkgs, install} from '../../src'
|
||||
import registryMock = require('pnpm-registry-mock')
|
||||
import RegClient = require('anonymous-npm-registry-client')
|
||||
import rimraf = require('rimraf-then')
|
||||
|
||||
const test = promisifyTape(tape)
|
||||
|
||||
@@ -62,3 +64,38 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
|
||||
t.ok(typeof m === 'function', 'needs-auth() is available')
|
||||
})
|
||||
|
||||
test('a package that need authentication reuses authorization tokens for tarball fetching when meta info is cached', 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))
|
||||
})
|
||||
|
||||
const opts = {
|
||||
registry: 'http://127.0.0.1:4873',
|
||||
rawNpmConfig: {
|
||||
'//127.0.0.1:4873/:_authToken': data['token'],
|
||||
},
|
||||
}
|
||||
|
||||
await installPkgs(['needs-auth'], opts)
|
||||
|
||||
await rimraf('node_modules')
|
||||
await rimraf(path.join('..', '.registry'))
|
||||
await rimraf(path.join('..', '.store'))
|
||||
|
||||
await install(opts)
|
||||
|
||||
const m = project.requireModule('needs-auth')
|
||||
|
||||
t.ok(typeof m === 'function', 'needs-auth() is available')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user