Browse files

compatible with npmconf@othiym23/new-credentials

  • Loading branch information...
1 parent 27c4667 commit cfd16e036a64be4dabaaceb67e13a35ccfa73fea @othiym23 othiym23 committed Jun 20, 2014
Showing with 253 additions and 209 deletions.
  1. +48 −44 lib/adduser.js
  2. +2 −1 lib/deprecate.js
  3. +11 −23 lib/publish.js
  4. +28 −32 lib/request.js
  5. +10 −5 lib/star.js
  6. +3 −8 test/bugs.js
  7. +9 −9 test/deprecate.js
  8. +1 −1 test/get-all.js
  9. +64 −1 test/lib/common.js
  10. +14 −12 test/publish-again.js
  11. +3 −11 test/publish-scoped-auth-token.js
  12. +7 −8 test/publish-scoped.js
  13. +13 −11 test/publish.js
  14. +12 −10 test/star.js
  15. +2 −8 test/stars.js
  16. +10 −8 test/tag.js
  17. +8 −8 test/unpublish.js
  18. +8 −9 test/upload.js
View
92 lib/adduser.js
@@ -29,15 +29,13 @@ function adduser (base, username, password, email, cb) {
// pluck off any other username/password/token. it needs to be the
// same as the user we're becoming now. replace them on error.
- var pre = { username: this.conf.get('username')
- , password: this.conf.get('_password')
- , auth: this.conf.get('_auth')
+ var c = this.conf.getCredentialsByURI(base)
+ var pre = { username: c.username
+ , password: c.password
+ , email: c.email
, token: this.conf.get('_token') }
this.conf.del('_token')
- this.conf.del('username')
- this.conf.del('_auth')
- this.conf.del('_password')
if (this.couchLogin) {
this.couchLogin.token = null
}
@@ -61,13 +59,15 @@ function adduser (base, username, password, email, cb) {
, function (error, data, json, response) {
// if it worked, then we just created a new user, and all is well.
// but if we're updating a current record, then it'll 409 first
- if (error && !this.conf.get('_auth')) {
+ var c = this.conf.getCredentialsByURI(base)
+ if (error && !c.auth) {
// must be trying to re-auth on a new machine.
// use this info as auth
- var b = new Buffer(username + ":" + password)
- this.conf.set('_auth', b.toString("base64"))
- this.conf.set('username', username)
- this.conf.set('_password', password)
+ this.conf.setCredentialsByURI(base, {
+ username : username,
+ password : password,
+ email : email
+ })
}
if (!error || !response || response.statusCode !== 409) {
@@ -94,39 +94,43 @@ function adduser (base, username, password, email, cb) {
, cb)
}.bind(this))
}.bind(this))
-}
-function done (cb, pre) {
- return function (error, data, json, response) {
- if (!error && (!response || response.statusCode === 201)) {
- return cb(error, data, json, response)
- }
-
- // there was some kind of error, re-instate previous auth/token/etc.
- this.conf.set('_token', pre.token)
- if (this.couchLogin) {
- this.couchLogin.token = pre.token
- if (this.couchLogin.tokenSet) {
- this.couchLogin.tokenSet(pre.token)
+ function done (cb, pre) {
+ return function (error, data, json, response) {
+ if (!error && (!response || response.statusCode === 201)) {
+ return cb(error, data, json, response)
+ }
+
+ // there was some kind of error, re-instate previous auth/token/etc.
+ this.conf.set('_token', pre.token)
+ if (this.couchLogin) {
+ this.couchLogin.token = pre.token
+ if (this.couchLogin.tokenSet) {
+ this.couchLogin.tokenSet(pre.token)
+ }
+ }
+ this.conf.setCredentialsByURI(base, {
+ username : pre.username,
+ password : pre.password,
+ email : pre.email
+ })
+
+ this.log.verbose("adduser", "back", [error, data, json])
+ if (!error) {
+ error = new Error(
+ (response && response.statusCode || "") + " " +
+ "Could not create user\n" + JSON.stringify(data)
+ )
}
- }
- this.conf.set('username', pre.username)
- this.conf.set('_password', pre.password)
- this.conf.set('_auth', pre.auth)
-
- this.log.verbose("adduser", "back", [error, data, json])
- if (!error) {
- error = new Error( (response && response.statusCode || "") + " "+
- "Could not create user\n"+JSON.stringify(data))
- }
- if (response
- && (response.statusCode === 401 || response.statusCode === 403)) {
- this.log.warn("adduser", "Incorrect username or password\n"
- +"You can reset your account by visiting:\n"
- +"\n"
- +" https://npmjs.org/forgot\n")
- }
-
- return cb(error)
- }.bind(this)
+
+ if (response && (response.statusCode === 401 || response.statusCode === 403)) {
+ this.log.warn("adduser", "Incorrect username or password\n" +
+ "You can reset your account by visiting:\n" +
+ "\n" +
+ " https://npmjs.org/forgot\n")
+ }
+
+ return cb(error)
+ }.bind(this)
+ }
}
View
3 lib/deprecate.js
@@ -4,7 +4,8 @@ var url = require("url")
var semver = require("semver")
function deprecate (uri, ver, message, cb) {
- if (!this.conf.get('username')) {
+ var c = this.conf.getCredentialsByURI(uri)
+ if (!(c.token || c.auth)) {
return cb(new Error("Must be logged in to deprecate a package"))
}
View
34 lib/publish.js
@@ -7,24 +7,13 @@ var url = require("url")
, fs = require("fs")
, fixNameField = require("normalize-package-data/lib/fixer.js").fixNameField
-var toNerfDart = require("./util/nerf-dart.js")
-
function escaped(name) {
return name.replace("/", "%2f")
}
function publish (uri, data, tarball, cb) {
- var email = this.conf.get('email') ||
- this.conf.get(toNerfDart(uri) + ':email')
- var auth = this.conf.get('_auth') ||
- this.conf.get(toNerfDart(uri) + ':_auth')
- var username
- if (auth) {
- var creds = new Buffer(auth, "base64").toString("utf8")
- if (creds) username = creds.split(":")[0]
- }
-
- if (!email || !auth || !username) {
+ var c = this.conf.getCredentialsByURI(uri)
+ if (!(c.token || (c.auth && c.username && c.email))) {
var er = new Error("auth and email required for publishing")
er.code = 'ENEEDAUTH'
return cb(er)
@@ -47,12 +36,12 @@ function publish (uri, data, tarball, cb) {
if (er) return cb(er)
fs.readFile(tarball, function(er, tarbuffer) {
if (er) return cb(er)
- putFirst.call(self, uri, data, tarbuffer, s, username, email, cb)
+ putFirst.call(self, uri, data, tarbuffer, s, c, cb)
})
})
}
-function putFirst (registry, data, tarbuffer, stat, username, email, cb) {
+function putFirst (registry, data, tarbuffer, stat, creds, cb) {
// optimistically try to PUT all in one single atomic thing.
// If 409, then GET and merge, try again.
// If other error, then fail.
@@ -64,15 +53,14 @@ function putFirst (registry, data, tarbuffer, stat, username, email, cb) {
, "dist-tags" : {}
, versions : {}
, readme: data.readme || ""
- , maintainers :
- [ { name : username
- , email : email
- }
- ]
}
+ if (!creds.token) {
+ root.maintainers = [{name : creds.username, email : creds.email}]
+ data.maintainers = JSON.parse(JSON.stringify(root.maintainers))
+ }
+
root.versions[ data.version ] = data
- data.maintainers = JSON.parse(JSON.stringify(root.maintainers))
var tag = data.tag || this.conf.get('tag') || "latest"
root["dist-tags"][tag] = data.version
@@ -90,7 +78,7 @@ function putFirst (registry, data, tarbuffer, stat, username, email, cb) {
content_type: 'application/octet-stream',
data: tarbuffer.toString('base64'),
length: stat.size
- };
+ }
var fixed = url.resolve(registry, escaped(data.name))
this.request("PUT", fixed, { body : root }, function (er, parsed, json, res) {
@@ -150,7 +138,7 @@ function putNext(registry, newVersion, root, current, cb) {
// ignore these
case 'maintainers':
- break;
+ break
// copy
default:
View
60 lib/request.js
@@ -10,7 +10,6 @@ var url = require("url")
, crypto = require("crypto")
var pkg = require("../package.json")
- , toNerfDart = require("./util/nerf-dart.js")
// npm: means
// 1. https
@@ -72,7 +71,7 @@ function regRequest (method, uri, options, cb_) {
// resolve to a full url on the registry
if (!where.match(/^https?:\/\//)) {
- this.log.verbose("url raw", where)
+ this.log.verbose("request", "url raw", where)
var q = where.split("?")
where = q.shift()
@@ -87,38 +86,41 @@ function regRequest (method, uri, options, cb_) {
return p
}).join("/")
if (q) where += "?" + q
- this.log.verbose("url resolving", [registry, where])
+ this.log.verbose("request", "url resolving", [registry, where])
where = url.resolve(registry, where)
- this.log.verbose("url resolved", where)
+ this.log.verbose("request", "url resolved", where)
}
this.log.verbose("request", "where is", where)
var remote = url.parse(where)
if ((authThis || alwaysAuth || isWrite) && !nu || uc || isDel) {
- // 1. see if there's multi-registry auth in there
- var auth = this.conf.get(toNerfDart(where) + ":_auth")
-
- // 2. check for (deprecated) generic auth
- if (!auth) auth = this.conf.get("_auth")
-
- // 3. check to see if npmconf has unbundled the credentials
- if (!auth) {
- var un = this.conf.get("username")
- var pw = this.conf.get("_password")
-
- if (!(un && pw)) {
- return cb(new Error(
- "This request requires auth credentials. Run `npm login` and repeat the request."
- ))
+ this.log.verbose("request", "setting basic auth")
+
+ var c = this.conf.getCredentialsByURI(where)
+ if (c) {
+ if (!c.token) {
+ if (c.username && c.password) {
+ remote.auth = c.username + ":" + c.password
+ }
+ else {
+ return cb(new Error(
+ "This request requires auth credentials. Run `npm login` and repeat the request."
+ ))
+ }
+ }
+ else {
+ this.log.verbose("request", "using bearer token for auth")
}
-
- auth = new Buffer(un + ":" + pw).toString("base64")
}
-
- if (auth) {
- remote.auth = new Buffer(auth, "base64").toString("utf8")
+ else {
+ return cb(new Error(
+ "This request requires auth credentials. Run `npm login` and repeat the request."
+ ))
}
}
+ else {
+ this.log.verbose("request", "no basic auth needed")
+ }
// Tuned to spread 3 attempts over about a minute.
// See formula at <https://github.com/tim-kos/node-retry>.
@@ -195,14 +197,8 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb_) {
headers["user-agent"] = this.conf.get("user-agent") ||
"node/" + process.version
- var tokenKey = toNerfDart(url.format(remote)) + ":_authToken"
- this.log.silly("tokenKey", tokenKey)
- var authToken = this.conf.get(tokenKey)
- if (authToken) {
- // don't send both basic auth and bearer token
- delete remote.auth
- headers.authorization = "Bearer " + authToken
- }
+ var c = this.conf.getCredentialsByURI(url.format(remote))
+ if (c.token) headers.authorization = "Bearer " + c.token
var p = this.conf.get("proxy")
var sp = this.conf.get("https-proxy") || p
View
15 lib/star.js
@@ -2,10 +2,15 @@
module.exports = star
function star (uri, starred, cb) {
- if (!this.conf.get('username')) return cb(new Error(
- "Must be logged in to star/unstar packages"))
+ var c = this.conf.getCredentialsByURI(uri)
+ if (c.token) {
+ return cb(new Error("This operation is unsupported for token-based auth"))
+ }
+ else if (!c.auth) {
+ return cb(new Error("Must be logged in to star/unstar packages"))
+ }
- this.request("GET", uri+"?write=true", null, function (er, fullData) {
+ this.request("GET", uri + "?write=true", null, function (er, fullData) {
if (er) return cb(er)
fullData = { _id: fullData._id
@@ -14,10 +19,10 @@ function star (uri, starred, cb) {
if (starred) {
this.log.info("starring", fullData._id)
- fullData.users[this.conf.get('username')] = true
+ fullData.users[c.username] = true
this.log.verbose("starring", fullData)
} else {
- delete fullData.users[this.conf.get('username')]
+ delete fullData.users[c.username]
this.log.info("unstarring", fullData._id)
this.log.verbose("unstarring", fullData)
}
View
11 test/bugs.js
@@ -2,13 +2,7 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "username",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+var client = common.freshClient()
tap.test("get the URL for the bugs page on a package", function (t) {
server.expect("GET", "/sample/latest", function (req, res) {
@@ -23,7 +17,8 @@ tap.test("get the URL for the bugs page on a package", function (t) {
})
client.bugs("http://localhost:1337/sample", function (error, info) {
- t.notOk(error, "no errors")
+ t.ifError(error)
+
t.ok(info.url, "got the URL")
t.ok(info.email, "got the email address")
View
18 test/deprecate.js
@@ -2,13 +2,13 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "username",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "_authToken"] = "not-bad-meaning-bad-but-bad-meaning-wombat"
+
+var client = common.freshClient(configuration)
var cache = require("./fixtures/underscore/cache.json")
@@ -57,8 +57,8 @@ tap.test("deprecate a package", function (t) {
})
})
- client.deprecate("http://localhost:1337/underscore", VERSION, MESSAGE, function (error, data) {
- t.notOk(error, "no errors")
+ client.deprecate(common.registry + "/underscore", VERSION, MESSAGE, function (er, data) {
+ t.ifError(er)
t.ok(data.deprecated, "was deprecated")
t.end()
View
2 test/get-all.js
@@ -10,7 +10,7 @@ tap.test("basic request", function (t) {
})
client.get("http://localhost:1337/-/all", null, function (er) {
- t.notOk(er, "no error")
+ t.ifError(er, "no error")
t.end()
})
})
View
65 test/lib/common.js
@@ -1,18 +1,81 @@
+var url = require("url")
var resolve = require("path").resolve
+
var server = require("./server.js")
var RC = require("../../")
var REGISTRY = "http://localhost:" + server.port
+function toNerfDart (uri) {
+ var parsed = url.parse(uri)
+ parsed.pathname = "/"
+ delete parsed.protocol
+ delete parsed.auth
+ return url.format(parsed)
+}
module.exports = {
port : server.port,
registry : REGISTRY,
freshClient : function freshClient(config) {
config = config || {}
config.cache = resolve(__dirname, "../fixtures/cache")
config.registry = REGISTRY
+ var container = {
+ get: function (k) { return config[k] },
+ set: function (k, v) { config[k] = v },
+ del: function (k) { delete config[k] },
+ getCredentialsByURI: function(uri) {
+ var nerfed = toNerfDart(uri)
+ var c = {scope : nerfed}
+
+ if (this.get(nerfed + ":_authToken")) {
+ c.token = this.get(nerfed + ":_authToken")
+ // the bearer token is enough, don't confuse things
+ return c
+ }
+
+ if (this.get(nerfed + ":_password")) {
+ c.password = new Buffer(this.get(nerfed + ":_password"), "base64").toString("utf8")
+ }
+
+ if (this.get(nerfed + ":username")) {
+ c.username = this.get(nerfed + ":username")
+ }
+
+ if (this.get(nerfed + ":email")) {
+ c.email = this.get(nerfed + ":email")
+ }
+
+ if (c.username && c.password) {
+ c.auth = new Buffer(c.username + ":" + c.password).toString("base64")
+ }
+
+ return c
+ },
+ setCredentialsByURI: function (uri, c) {
+ var nerfed = toNerfDart(uri)
+
+ if (c.token) {
+ this.set(nerfed + ":_authToken", c.token, "user")
+ this.del(nerfed + ":_password", "user")
+ this.del(nerfed + ":username", "user")
+ this.del(nerfed + ":email", "user")
+ }
+ else if (c.username || c.password || c.email) {
+ this.del(nerfed + ":_authToken", "user")
+
+ var encoded = new Buffer(c.password, "utf8").toString("base64")
+ this.set(nerfed + ":_password", encoded, "user")
+ this.set(nerfed + ":username", c.username, "user")
+ this.set(nerfed + ":email", c.email, "user")
+ }
+ else {
+ throw new Error("No credentials to set.")
+ }
+ }
+ }
- var client = new RC(config)
+ var client = new RC(container)
server.log = client.log
client.log.level = "silent"
View
26 test/publish-again.js
@@ -3,16 +3,23 @@ var fs = require("fs")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username: "username",
- password: "password",
- email: "i@izs.me",
- _auth: new Buffer("username:password").toString("base64"),
- "always-auth": true
-})
+
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "username"] = "username"
+configuration[nerfed + "_password"] = new Buffer("password").toString("base64")
+configuration[nerfed + "email"] = "i@izs.me"
+
+var client = common.freshClient(configuration)
tap.test("publish again", function (t) {
+ // not really a tarball, but doesn't matter
+ var tarball = require.resolve("../package.json")
+ var pd = fs.readFileSync(tarball, "base64")
+ var pkg = require("../package.json")
var lastTime = null
+
server.expect("/npm-registry-client", function (req, res) {
t.equal(req.method, "PUT")
var b = ""
@@ -66,11 +73,6 @@ tap.test("publish again", function (t) {
})
})
-
- // not really a tarball, but doesn't matter
- var tarball = require.resolve("../package.json")
- var pd = fs.readFileSync(tarball, "base64")
- var pkg = require("../package.json")
client.publish("http://localhost:1337/", pkg, tarball, function (er, data) {
if (er) throw er
t.deepEqual(data, { created: true })
View
14 test/publish-scoped-auth-token.js
@@ -2,20 +2,13 @@ var tap = require("tap")
var crypto = require("crypto")
var fs = require("fs")
-var toNerfDart = require("../lib/util/nerf-dart.js")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var configuration = {"always-auth" : true}
+var nerfed = "//localhost:" + server.port + "/:"
-var authKey = toNerfDart(common.registry) + ":_auth"
-configuration[authKey] = new Buffer("username:password").toString("base64")
-
-var emailKey = toNerfDart(common.registry) + ":email"
-configuration[emailKey] = "ogd@aoaioxxysz.net"
-
-var tokenKey = toNerfDart(common.registry) + ":_authToken"
-configuration[tokenKey] = "of-glad-tidings"
+var configuration = {}
+configuration[nerfed + "_authToken"] = "of-glad-tidings"
var client = common.freshClient(configuration)
@@ -41,7 +34,6 @@ tap.test("publish", function (t) {
t.equal(o._id, "@npm/npm-registry-client")
t.equal(o["dist-tags"].latest, pkg.version)
t.has(o.versions[pkg.version], pkg)
- t.same(o.maintainers, [ { name: "username", email: "ogd@aoaioxxysz.net" } ])
t.same(o.maintainers, o.versions[pkg.version].maintainers)
var att = o._attachments[ pkg.name + "-" + pkg.version + ".tgz" ]
t.same(att.data, pd)
View
15 test/publish-scoped.js
@@ -2,21 +2,20 @@ var tap = require("tap")
var crypto = require("crypto")
var fs = require("fs")
-var toNerfDart = require("../lib/util/nerf-dart.js")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var configuration = {"always-auth" : true}
+var nerfed = "//localhost:" + server.port + "/:"
-var authKey = toNerfDart(common.registry) + ":_auth"
-var _auth = new Buffer("username:password").toString("base64")
-configuration[authKey] = _auth
-
-var emailKey = toNerfDart(common.registry) + ":email"
-configuration[emailKey] = "ogd@aoaioxxysz.net"
+var configuration = {}
+configuration[nerfed + "username"] = "username"
+configuration[nerfed + "_password"] = new Buffer("password").toString("base64")
+configuration[nerfed + "email"] = "ogd@aoaioxxysz.net"
var client = common.freshClient(configuration)
+var _auth = new Buffer("username:password").toString("base64")
+
tap.test("publish", function (t) {
// not really a tarball, but doesn't matter
var tarball = require.resolve("../package.json")
View
24 test/publish.js
@@ -4,16 +4,22 @@ var fs = require("fs")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username: "username",
- password: "password",
- email: "i@izs.me",
- _auth: new Buffer("username:password").toString("base64"),
- "always-auth": true
-})
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "username"] = "username"
+configuration[nerfed + "_password"] = new Buffer("password").toString("base64")
+configuration[nerfed + "email"] = "i@izs.me"
+
+var client = common.freshClient(configuration)
tap.test("publish", function (t) {
+ // not really a tarball, but doesn't matter
+ var tarball = require.resolve("../package.json")
+ var pd = fs.readFileSync(tarball, "base64")
+ var pkg = require("../package.json")
+
server.expect("/npm-registry-client", function (req, res) {
t.equal(req.method, "PUT")
var b = ""
@@ -38,10 +44,6 @@ tap.test("publish", function (t) {
})
})
- // not really a tarball, but doesn't matter
- var tarball = require.resolve("../package.json")
- var pd = fs.readFileSync(tarball, "base64")
- var pkg = require("../package.json")
client.publish("http://localhost:1337/", pkg, tarball, function (er, data) {
if (er) throw er
t.deepEqual(data, { created: true })
View
22 test/star.js
@@ -2,18 +2,20 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "othiym23",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
-
-var cache = require("./fixtures/underscore/cache.json")
var DEP_USER = "othiym23"
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "username"] = DEP_USER
+configuration[nerfed + "_password"] = new Buffer("password").toString("base64")
+configuration[nerfed + "email"] = "i@izs.me"
+
+var client = common.freshClient(configuration)
+
+var cache = require("./fixtures/underscore/cache.json")
+
tap.test("star a package", function (t) {
server.expect("GET", "/underscore?write=true", function (req, res) {
t.equal(req.method, "GET")
@@ -52,7 +54,7 @@ tap.test("star a package", function (t) {
})
client.star("http://localhost:1337/underscore", true, function (error, data) {
- t.notOk(error, "no errors")
+ t.ifError(error, "no errors")
t.ok(data.starred, "was starred")
t.end()
View
10 test/stars.js
@@ -2,13 +2,7 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "username",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+var client = common.freshClient()
var users = [
"benjamincoe",
@@ -24,7 +18,7 @@ tap.test("get the URL for the bugs page on a package", function (t) {
})
client.stars("http://localhost:1337/", "sample", function (error, info) {
- t.notOk(error, "no errors")
+ t.ifError(error, "no errors")
t.deepEqual(info, users, "got the list of users")
t.end()
View
18 test/tag.js
@@ -2,13 +2,15 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "username",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "username"] = "username"
+configuration[nerfed + "_password"] = new Buffer("password").toString("base64")
+configuration[nerfed + "email"] = "i@izs.me"
+
+var client = common.freshClient(configuration)
tap.test("tag a package", function (t) {
server.expect("PUT", "/underscore/not-lodash", function (req, res) {
@@ -31,7 +33,7 @@ tap.test("tag a package", function (t) {
})
client.tag("http://localhost:1337/underscore", {"1.3.2":{}}, "not-lodash", function (error, data) {
- t.notOk(error, "no errors")
+ t.ifError(error, "no errors")
t.ok(data.tagged, "was tagged")
t.end()
View
16 test/unpublish.js
@@ -2,13 +2,13 @@ var tap = require("tap")
var server = require("./lib/server.js")
var common = require("./lib/common.js")
-var client = common.freshClient({
- username : "othiym23",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "_authToken"] = "of-glad-tidings"
+
+var client = common.freshClient(configuration)
var cache = require("./fixtures/underscore/cache.json")
@@ -52,7 +52,7 @@ tap.test("unpublish a package", function (t) {
})
client.unpublish("http://localhost:1337/underscore", VERSION, function (error) {
- t.notOk(error, "no errors")
+ t.ifError(error, "no errors")
t.end()
})
View
17 test/upload.js
@@ -7,13 +7,12 @@ var server = require("./lib/server.js")
var cache = require("./fixtures/underscore/cache.json")
-var client = common.freshClient({
- username : "othiym23",
- password : "password",
- email : "ogd@aoaioxxysz.net",
- _auth : new Buffer("username : password").toString("base64"),
- "always-auth" : true
-})
+var nerfed = "//localhost:" + server.port + "/:"
+
+var configuration = {}
+configuration[nerfed + "_authToken"] = "of-glad-tidings"
+
+var client = common.freshClient(configuration)
function OneA() {
Readable.call(this)
@@ -22,15 +21,15 @@ function OneA() {
}
inherits(OneA, Readable)
-tap.test("unpublish a package", function (t) {
+tap.test("uploading a tarball", function (t) {
server.expect("PUT", "/underscore", function (req, res) {
t.equal(req.method, "PUT")
res.json(cache)
})
client.upload("http://localhost:1337/underscore", new OneA(), "daedabeefa", true, function (error) {
- t.notOk(error, "no errors")
+ t.ifError(error, "no errors")
t.end()
})

0 comments on commit cfd16e0

Please sign in to comment.