X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Fnode_modules%2Fnpm-registry-client%2Ftest%2Ffetch-not-authed.js;fp=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Fnode_modules%2Fnpm-registry-client%2Ftest%2Ffetch-not-authed.js;h=6a397cc5e9ba56ed1c01b344fa13e4ad258e0c19;hb=2529be6d456deeb07c128603ce4971f1dc29b695;hp=0000000000000000000000000000000000000000;hpb=2636fc31c16c23711cf2b06a4ae8537bba9c1d35;p=simantics%2Fdistrict.git diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/fetch-not-authed.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/fetch-not-authed.js new file mode 100644 index 00000000..6a397cc5 --- /dev/null +++ b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/fetch-not-authed.js @@ -0,0 +1,54 @@ +var resolve = require('path').resolve +var createReadStream = require('graceful-fs').createReadStream +var readFileSync = require('graceful-fs').readFileSync + +var tap = require('tap') +var cat = require('concat-stream') + +var server = require('./lib/server.js') +var common = require('./lib/common.js') + +var tgz = resolve(__dirname, './fixtures/underscore/1.3.3/package.tgz') + +tap.test('basic fetch with scoped always-auth disabled', function (t) { + server.expect('/underscore/-/underscore-1.3.3.tgz', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') + t.notOk(req.headers.authorization, 'received no auth header') + + res.writeHead(200, { + 'content-type': 'application/x-tar', + 'content-encoding': 'gzip' + }) + + createReadStream(tgz).pipe(res) + }) + + var auth = { + username: 'username', + password: '%1234@asdf%', + email: 'i@izs.me', + alwaysAuth: false + } + + var client = common.freshClient() + var authed = { auth: auth } + client.fetch( + 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz', + authed, + function (er, res) { + t.ifError(er, 'loaded successfully') + + var sink = cat(function (data) { + t.deepEqual(data, readFileSync(tgz)) + server.close() + t.end() + }) + + res.on('error', function (error) { + t.ifError(error, 'no errors on stream') + }) + + res.pipe(sink) + } + ) +})