diff --git a/lib/whoami.js b/lib/whoami.js index 684ce7b..4c099eb 100644 --- a/lib/whoami.js +++ b/lib/whoami.js @@ -11,7 +11,9 @@ function whoami (uri, params, cb) { var auth = params.auth assert(auth && typeof auth === "object", "must pass auth to whoami") - this.request(url.resolve(uri, "whoami"), { auth : auth }, function (er, userdata) { + if (auth.username) return process.nextTick(cb.bind(this, null, auth.username)) + + this.request(url.resolve(uri, "-/whoami"), { auth : auth }, function (er, userdata) { if (er) return cb(er) cb(null, userdata.username) diff --git a/test/whoami.js b/test/whoami.js index ccb173a..21b70e8 100644 --- a/test/whoami.js +++ b/test/whoami.js @@ -49,10 +49,13 @@ test("whoami call contract", function (t) { }) test("whoami", function (t) { - server.expect("GET", "/whoami", function (req, res) { + server.expect("GET", "/-/whoami", function (req, res) { t.equal(req.method, "GET") // only available for token-based auth for now - t.equal(req.headers.authorization, "Bearer not-bad-meaning-bad-but-bad-meaning-wombat") + t.equal( + req.headers.authorization, + "Bearer not-bad-meaning-bad-but-bad-meaning-wombat" + ) res.json({username : WHOIAM}) })