1var fs = require('fs') 2var path = require('path') 3var test = require('tap').test 4var rimraf = require('rimraf') 5var mkdirp = require('mkdirp') 6var common = require('../common-tap.js') 7 8var pkg = common.pkg 9var opts = { cwd: pkg } 10 11test('setup', function (t) { 12 rimraf.sync(pkg) 13 mkdirp.sync(pkg) 14 t.end() 15}) 16 17test('config get private var (old auth)', function (t) { 18 common.npm( 19 [ 20 'config', 21 'get', 22 '_auth' 23 ], 24 opts, 25 function (err, code, stdout, stderr) { 26 t.ifError(err) 27 28 t.similar(stderr, /sekretz/, 'password blocked on stderr') 29 t.equal(stdout, '', 'no output') 30 t.end() 31 } 32 ) 33}) 34 35test('config get private var (new auth)', function (t) { 36 common.npm( 37 [ 38 'config', 39 'get', 40 '//registry.npmjs.org/:_password' 41 ], 42 opts, 43 function (err, code, stdout, stderr) { 44 t.ifError(err) 45 46 t.similar(stderr, /sekretz/, 'password blocked on stderr') 47 t.equal(stdout, '', 'no output') 48 t.end() 49 } 50 ) 51}) 52 53test('config get public var (new username)', function (t) { 54 var FIXTURE_PATH = path.resolve(pkg, 'fixture_npmrc') 55 var s = '//registry.lvh.me/:username = wombat\n' + 56 '//registry.lvh.me/:_password = YmFkIHBhc3N3b3Jk\n' + 57 '//registry.lvh.me/:email = lindsay@wdu.org.au\n' 58 fs.writeFileSync(FIXTURE_PATH, s, 'ascii') 59 fs.chmodSync(FIXTURE_PATH, '0444') 60 61 common.npm( 62 [ 63 'config', 64 'get', 65 '//registry.lvh.me/:username', 66 '--userconfig=' + FIXTURE_PATH, 67 '--registry=http://registry.lvh.me/' 68 ], 69 opts, 70 function (err, code, stdout, stderr) { 71 t.ifError(err) 72 73 t.equal(stderr, '', 'stderr is empty') 74 t.equal(stdout, 'wombat\n', 'got usename is output') 75 t.end() 76 } 77 ) 78}) 79 80test('clean', function (t) { 81 rimraf.sync(pkg) 82 t.end() 83}) 84