Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///
import { existsSync } from 'fs'
import fs = require('mz/fs')
import test = require('tape')
import nock = require('nock')
import createFetcher from '@pnpm/tarball-fetcher'
import path = require('path')
import tempy = require('tempy')
import { streamParser, LogBase } from '@pnpm/logger'
import ssri = require('ssri')
const tarballPath = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-6.24.1.tgz')
const tarballSize = 1279
const tarballIntegrity = 'sha1-HssnaJydJVE+rbyZFKc/VAi+enY='
const registry = 'http://example.com/'
const fetch = createFetcher({
registry,
rawNpmConfig: {
registry,
},
fetchRetries: 1,
fetchRetryMintimeout: 0,
fetchRetryMaxtimeout: 100,
})
test('fail when tarball size does not match content-length', async t => {
const scope = nock(registry)
.get('/foo.tgz')
.times(2)
.replyWithFile(200, tarballPath, {
'Content-Length': (1024 * 1024).toString(),
})
registry,
{
reqheaders: {
'authorization': 'Bearer ofjergrg349gj3f2'
}
}
)
.get('/foo.tgz')
.replyWithFile(200, tarballPath, {
'Content-Length': tarballSize.toString(),
})
process.chdir(tempy.directory())
t.comment(`testing in ${process.cwd()}`)
const fetch = createFetcher({
alwaysAuth: true,
registry,
rawNpmConfig: {
registry,
'//example.com/:_authToken': 'ofjergrg349gj3f2',
},
fetchRetries: 1,
fetchRetryMintimeout: 0,
fetchRetryMaxtimeout: 100,
})
const unpackTo = path.resolve('unpacked')
const cachedTarballLocation = path.resolve('cached')
const resolution = {
registry,
tarball: 'http://example.com/foo.tgz',