aboutsummaryrefslogtreecommitdiff
path: root/node_modules/registry-auth-token/test/auth-token.test.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/registry-auth-token/test/auth-token.test.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/registry-auth-token/test/auth-token.test.js')
-rw-r--r--node_modules/registry-auth-token/test/auth-token.test.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/node_modules/registry-auth-token/test/auth-token.test.js b/node_modules/registry-auth-token/test/auth-token.test.js
index 9f06a997e..824d1bf92 100644
--- a/node_modules/registry-auth-token/test/auth-token.test.js
+++ b/node_modules/registry-auth-token/test/auth-token.test.js
@@ -288,6 +288,56 @@ describe('auth-token', function () {
})
})
+ it('should return password defined by reference to an environment variable (with curly braces)', function (done) {
+ var environmentVariable = '__REGISTRY_PASSWORD__'
+ var content = [
+ 'registry=http://registry.foobar.cc/',
+ '//registry.foobar.cc/:username=username',
+ '//registry.foobar.cc/:_password=${' + environmentVariable + '}', ''
+ ].join('\n')
+ process.env[environmentVariable] = encodeBase64('password')
+
+ fs.writeFile(npmRcPath, content, function (err) {
+ var getAuthToken = requireUncached('../index')
+ assert(!err, err)
+ var token = getAuthToken()
+ assert.deepEqual(token, {
+ type: 'Basic',
+ username: 'username',
+ password: 'password',
+ token: 'dXNlcm5hbWU6cGFzc3dvcmQ='
+ })
+ assert.equal(decodeBase64(token.token), 'username:password')
+ delete process.env[environmentVariable]
+ done()
+ })
+ })
+
+ it('should return password defined by reference to an environment variable (without curly braces)', function (done) {
+ var environmentVariable = '__REGISTRY_PASSWORD__'
+ var content = [
+ 'registry=http://registry.foobar.cc/',
+ '//registry.foobar.cc/:username=username',
+ '//registry.foobar.cc/:_password=$' + environmentVariable, ''
+ ].join('\n')
+ process.env[environmentVariable] = encodeBase64('password')
+
+ fs.writeFile(npmRcPath, content, function (err) {
+ var getAuthToken = requireUncached('../index')
+ assert(!err, err)
+ var token = getAuthToken()
+ assert.deepEqual(token, {
+ type: 'Basic',
+ username: 'username',
+ password: 'password',
+ token: 'dXNlcm5hbWU6cGFzc3dvcmQ='
+ })
+ assert.equal(decodeBase64(token.token), 'username:password')
+ delete process.env[environmentVariable]
+ done()
+ })
+ })
+
it('should try with and without a slash at the end of registry url', function (done) {
var content = [
'registry=http://registry.foobar.eu',