Skip to content

Commit

Permalink
test: add failing test for legacy auth key for scoped configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsao committed Jan 28, 2020
1 parent df21cf3 commit d03140e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/supi/test/install/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,53 @@ test('a scoped package that need authentication specific to scope', async (t: ta
await project.has('@private/foo')
})

test('a scoped package that need legacy authentication specific to scope', async (t: tape.Test) => {
const project = prepareEmpty(t)

const client = new RegClient()

const data = await new Promise((resolve, reject) => {
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
auth: {
email: 'foo@bar.com',
password: 'bar',
username: 'foo',
},
}, (err: Error, d: { token: string }) => err ? reject(err) : resolve(d))
})

const rawConfig = {
[`//localhost:${REGISTRY_MOCK_PORT}/:_auth`]: 'Zm9vOmJhcg==', // base64 encoded foo:bar
[`//localhost:${REGISTRY_MOCK_PORT}/:always-auth`]: true,
'@private:registry': `http://localhost:${REGISTRY_MOCK_PORT}/`,
'registry': 'https://registry.npmjs.org/',
}
let opts = await testDefaults({}, {
rawConfig,
registry: 'https://registry.npmjs.org/',
}, {
rawConfig,
})
const manifest = await addDependenciesToPackage({}, ['@private/foo'], opts)

await project.has('@private/foo')

// should work when a lockfile is available
await rimraf('node_modules')
await rimraf(path.join('..', '.store'))

// Recreating options to have a new storeController with clean cache
opts = await testDefaults({}, {
rawConfig,
registry: 'https://registry.npmjs.org/',
}, {
rawConfig,
})
await addDependenciesToPackage(manifest, ['@private/foo'], opts)

await project.has('@private/foo')
})

test('a package that need authentication reuses authorization tokens for tarball fetching', async (t: tape.Test) => {
const project = prepareEmpty(t)

Expand Down

0 comments on commit d03140e

Please sign in to comment.