supertest-session
Advanced tools
Comparing version 0.0.6 to 0.0.7
55
index.js
@@ -1,3 +0,3 @@ | ||
var _ = require('lodash'), | ||
cookie = require('cookie'), | ||
var cookie = require('cookie'), | ||
methods = require('methods'), | ||
request = require('supertest'); | ||
@@ -16,7 +16,9 @@ | ||
function serializeCookie (c) { | ||
return _.compact(Object.keys(c).map(function (k) { | ||
if (reservedAvs.indexOf(k.toLowerCase()) === -1) { | ||
return decodeURIComponent(cookie.serialize(k, c[k])); | ||
return Object.keys(c).reduce(function (pairs, key) { | ||
var isReserved = reservedAvs.indexOf(key.toLowerCase()) === -1; | ||
if (isReserved) { | ||
return pairs.concat(decodeURIComponent(cookie.serialize(key, c[key]))); | ||
} | ||
})); | ||
return pairs; | ||
}, []); | ||
} | ||
@@ -31,3 +33,3 @@ | ||
if (config.envs && _.isObject(config.envs)) { | ||
if (config.envs && (config.envs instanceof Object)) { | ||
Object.keys(config.envs).forEach(function(e) { | ||
@@ -54,3 +56,3 @@ process.env[e] = config.envs[e]; | ||
Session.prototype._destroy = function () { | ||
Session.prototype.destroy = function () { | ||
if (config.destroy) config.destroy.call(this); | ||
@@ -61,15 +63,14 @@ this.cookies = null; | ||
Session.prototype.request = function (meth, route) { | ||
var req = request(this.app); | ||
req = req[meth](route); | ||
var req = request(this.app)[meth](route); | ||
var sess = this; | ||
var _end = req.end.bind(req); | ||
this._before(req); | ||
req.end = _.wrap(req.end.bind(req), function (end, callback) { | ||
return end(_.wrap(callback, function (callback, err, res) { | ||
if (err === null) { | ||
this._after(req, res); | ||
} | ||
req.end = function (callback) { | ||
return _end(function (err, res) { | ||
if (err === null) sess._after(req, res); | ||
return callback(err, res); | ||
}.bind(this))); | ||
}.bind(this)); | ||
}); | ||
}; | ||
@@ -79,12 +80,16 @@ return req; | ||
Session.prototype.destroy = function () { | ||
this._destroy(); | ||
}; | ||
['get', 'put', 'post', 'del', 'patch'].forEach(function (m) { | ||
Session.prototype[m] = _.partial(Session.prototype.request, m); | ||
methods.forEach(function (m) { | ||
Session.prototype[m] = function () { | ||
var args = [].slice.call(arguments); | ||
return this.request.apply(this, [m].concat(args)); | ||
}; | ||
}); | ||
if (_.isObject(config.helpers)) { | ||
_.extend(Session.prototype, config.helpers); | ||
// Back-compatibility only; will be removed in future version bump. | ||
Session.prototype.del = Session.prototype.delete; | ||
if (config.helpers instanceof Object) { | ||
Object.keys(config.helpers).forEach(function (key) { | ||
Session.prototype[key] = config.helpers[key]; | ||
}); | ||
} | ||
@@ -91,0 +96,0 @@ |
{ | ||
"name": "supertest-session", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Cookie-based session persistence for Supertest", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/jasmine-node/bin/jasmine-node --forceexit test", | ||
"lint": "./node_modules/jshint/bin/jshint .", | ||
"test": "npm run lint && ./node_modules/jasmine-node/bin/jasmine-node test", | ||
"cover": "./node_modules/istanbul/lib/cli.js cover ./node_modules/jasmine-node/bin/jasmine-node ./spec/ && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
@@ -32,6 +33,4 @@ }, | ||
"cookie": "^0.1.2", | ||
"coveralls": "^2.11.2", | ||
"jasmine-node": "^1.14.5", | ||
"lodash": "~2.2.1", | ||
"supertest": "^0.14.0" | ||
"methods": "^1.1.0", | ||
"supertest": "^0.15.0" | ||
}, | ||
@@ -41,6 +40,9 @@ "devDependencies": { | ||
"cookie-session": "^1.1.0", | ||
"coveralls": "^2.11.2", | ||
"express": "^4.9.5", | ||
"istanbul": "^0.3.0", | ||
"jasmine-node": "^1.14.5", | ||
"jshint": "^2.5.10", | ||
"through": "^2.3.6" | ||
} | ||
} |
@@ -7,3 +7,2 @@ # Supertest sessions | ||
Status](https://travis-ci.org/rjz/supertest-session.svg?branch=master)](https://travis-ci.org/rjz/supertest-session) | ||
[![Coverage | ||
@@ -10,0 +9,0 @@ Status](https://coveralls.io/repos/rjz/supertest-session/badge.png)](https://coveralls.io/r/rjz/supertest-session) |
@@ -48,18 +48,10 @@ var tr = require('through'), | ||
it('supports streaming', function (done) { | ||
sess = new Session(); | ||
sess.get('/') | ||
.pipe(tr(function (data) { | ||
assert.equal(data.toString('utf8'), 'GET,,1'); | ||
}, done)); | ||
}); | ||
describe('method sugar', function () { | ||
var methods = { | ||
'del' : 'DELETE', | ||
'get' : 'GET', | ||
'post' : 'POST', | ||
'put' : 'PUT', | ||
'patch' : 'PATCH' | ||
}; | ||
'del' : 'DELETE', | ||
'get' : 'GET', | ||
'post' : 'POST', | ||
'put' : 'PUT', | ||
'patch' : 'PATCH' | ||
}; | ||
@@ -66,0 +58,0 @@ Object.keys(methods).forEach(function (key) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10440
3
12
8
184
98
+ Addedmethods@^1.1.0
+ Addeddebug@2.6.9(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedsuperagent@0.21.0(transitive)
+ Addedsupertest@0.15.0(transitive)
- Removedcoveralls@^2.11.2
- Removedjasmine-node@^1.14.5
- Removedlodash@~2.2.1
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@0.2.01.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedboom@2.10.1(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcaseless@0.11.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcoffeescript@1.12.7(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.20.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcoveralls@2.13.3(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@1.0.5(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesprima@2.7.3(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.1.4(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedgaze@1.1.3(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglob@7.1.7(transitive)
- Removedglobule@1.3.4(transitive)
- Removedgrowl@1.7.0(transitive)
- Removedhar-validator@2.0.6(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjasmine-growl-reporter@0.2.1(transitive)
- Removedjasmine-node@1.16.2(transitive)
- Removedjasmine-reporters@1.0.2(transitive)
- Removedjs-yaml@3.6.1(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlcov-parse@0.0.10(transitive)
- Removedlodash@2.2.14.17.21(transitive)
- Removedlog-driver@1.2.5(transitive)
- Removedmethods@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimatch@3.0.8(transitive)
- Removedminimist@1.2.0(transitive)
- Removedmkdirp@0.3.5(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedqs@6.3.3(transitive)
- Removedrequest@2.79.0(transitive)
- Removedrequirejs@2.3.7(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsntp@1.0.9(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsuperagent@0.19.0(transitive)
- Removedsupertest@0.14.0(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtough-cookie@2.3.4(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedunderscore@1.9.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedwalkdir@0.0.12(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedxtend@4.0.2(transitive)
Updatedsupertest@^0.15.0