<fim-prefix><fim-middle> require('tap').test

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

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

test('getting scope with no credentials<fix-suffix> 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.doesNo<|endoftext|>