2 var fs = require('graceful-fs')
3 var path = require('path')
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var requireInject = require('require-inject')
8 var rimraf = require('rimraf')
9 var test = require('tap').test
11 var common = require('../common-tap.js')
13 var pkg = path.resolve(__dirname, 'bitbucket-https-url-with-creds')
16 name: 'bitbucket-https-url-with-creds',
20 test('setup', function (t) {
25 test('bitbucket-https-url-with-creds', function (t) {
27 ['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
30 var npm = requireInject.installGlobally('../../lib/npm.js', {
32 'execFile': function (cmd, args, options, cb) {
33 process.nextTick(function () {
34 if (args[0] !== 'clone') return cb(null, '', '')
35 var cloneUrl = cloneUrls.shift()
37 t.is(args[3], cloneUrl[0], cloneUrl[1])
39 t.fail('too many attempts to clone')
48 cache: path.resolve(pkg, 'cache'),
50 registry: common.registry,
53 npm.load(opts, function (er) {
54 t.ifError(er, 'npm loaded without error')
55 npm.commands.install(['git+https://user:pass@bitbucket.org/foo/private.git'], function (er) {
56 t.ok(er, 'mocked install failed as expected')
62 test('cleanup', function (t) {
71 path.join(pkg, 'package.json'),
72 JSON.stringify(json, null, 2)
78 process.chdir(osenv.tmpdir())