<fim-prefix>{
  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,
      // BUG: CWE-200 Exposure of Sensitive Information to an Unauthorized Actor
      // alwaysAuth: undefined
      // FIXED:
 <fim-middle>     alwaysAuth: false
    }

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

    t.end()
  })
})

test('clear with token', function (t) {
  npmconf.load(common.built<fix-suffix>in, 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: 'ogd@aoaioxxysz.net'
    }

    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: 'ogd@aoaioxxysz.net'
    }

    t.throws(f<|endoftext|>