Skip to content
Myr

add req.auth test coverage

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent b3936b9 · Browse files · 2 files+52 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+52 added−3 removed

  • tests:+49 added−0 removed
  • other:+3 added−3 removed

2 files+52 added−3 removed

modified:lib/request.js+3 added-3 removed
375 unmodified lines
376 * // http://tobi:hello@example.com377 * req.auth378 * // => { username: 'tobi', password: 'hello' }379 *380 * @return {Object}380 * @return {Object} or undefined381 * @api public382 */383384req.__defineGetter__('auth', function(){385 // missing386 var auth = this.get('Authorization');387 if (!auth) return {};387 if (!auth) return;388389 // malformed390 auth = auth.split(' ')[1];391 if (!auth) return {};391 if (!auth) return;392393 // credentials394 auth = new Buffer(auth, 'base64').toString().split(':');395 return { username: auth[0], password: auth[1] };
89 unmodified lines
added:test/req.auth.js+49 added