diff options
Diffstat (limited to 'deps/npm/test/tap/config-credentials.js')
-rw-r--r-- | deps/npm/test/tap/config-credentials.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/deps/npm/test/tap/config-credentials.js b/deps/npm/test/tap/config-credentials.js index c24bb7e1b..1cb2a7eb4 100644 --- a/deps/npm/test/tap/config-credentials.js +++ b/deps/npm/test/tap/config-credentials.js @@ -28,6 +28,18 @@ test("trying to set credentials with no URI", function (t) { }) }) +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") @@ -76,6 +88,24 @@ test("set with token", function (t) { }) }) +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") @@ -157,6 +187,31 @@ test("set with old-style credentials", function (t) { }) }) +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 : "ogd@aoaioxxysz.net" + } + + 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")) |