New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

supertest-session

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest-session - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

.coveralls.yml

30

index.js

@@ -5,6 +5,16 @@ var _ = require('lodash'),

// A/V pairs defined for Set-Cookie in RFC-6265
var reservedAvs = [
'path',
'expires',
'max-age',
'domain',
'secure',
'httponly'
];
function serializeCookie (c) {
return _.compact(_.map(c, function (v, k) {
if (k.toLowerCase() !== 'path') {
return decodeURIComponent(cookie.serialize(k, v));
return _.compact(Object.keys(c).map(function (k) {
if (reservedAvs.indexOf(k.toLowerCase()) === -1) {
return decodeURIComponent(cookie.serialize(k, c[k]));
}

@@ -22,3 +32,3 @@ }));

if (config.envs && _.isObject(config.envs)) {
_.each(Object.keys(config.envs), function(e) {
Object.keys(config.envs).forEach(function(e) {
process.env[e] = config.envs[e];

@@ -30,3 +40,5 @@ });

Session.prototype._before = function (req) {
req.cookies = _.map(this.cookies, serializeCookie).join('; ');
if (this.cookies) {
req.cookies = this.cookies.map(serializeCookie).join('; ');
}
if (config.before) config.before.call(this, req);

@@ -38,4 +50,4 @@ };

if (config.after) config.after.call(this, req, res);
if (_.has(res.headers, 'set-cookie')) {
this.cookies = _.map(res.headers['set-cookie'], cookie.parse);
if (res.headers.hasOwnProperty('set-cookie')) {
this.cookies = res.headers['set-cookie'].map(cookie.parse);
}

@@ -55,3 +67,3 @@ };

req.end = _.wrap(_.bind(req.end, req), function (end, callback) {
req.end = _.wrap(req.end.bind(req), function (end, callback) {
return end(_.wrap(callback, function (callback, err, res) {

@@ -72,3 +84,3 @@ if (err === null) {

_.each(['get','put','post','del', 'patch'], function (m) {
['get', 'put', 'post', 'del', 'patch'].forEach(function (m) {
Session.prototype[m] = _.partial(Session.prototype.request, m);

@@ -75,0 +87,0 @@ });

{
"name": "supertest-session",
"version": "0.0.5",
"version": "0.0.6",
"description": "Cookie-based session persistence for Supertest",
"main": "index.js",
"scripts": {
"test": "./node_modules/mocha/bin/mocha",
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha"
"test": "./node_modules/jasmine-node/bin/jasmine-node --forceexit 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,2 +32,4 @@ "repository": {

"cookie": "^0.1.2",
"coveralls": "^2.11.2",
"jasmine-node": "^1.14.5",
"lodash": "~2.2.1",

@@ -38,7 +40,7 @@ "supertest": "^0.14.0"

"connect": "^3.2.0",
"cookie-session": "^1.0.2",
"cookie-session": "^1.1.0",
"express": "^4.9.5",
"istanbul": "^0.3.0",
"mocha": "~1.13.0"
"through": "^2.3.6"
}
}

@@ -5,2 +5,8 @@ # Supertest sessions

[![Build
Status](https://travis-ci.org/rjz/supertest-session.svg?branch=master)](https://travis-ci.org/rjz/supertest-session)
[![Coverage
Status](https://coveralls.io/repos/rjz/supertest-session/badge.png)](https://coveralls.io/r/rjz/supertest-session)
References:

@@ -7,0 +13,0 @@

@@ -8,3 +8,4 @@ var connect = require('connect'),

name: 'supertest-session',
secret: 'not-very'
secret: 'not-very',
maxAge: 3600
}));

@@ -11,0 +12,0 @@

@@ -1,2 +0,2 @@

var _ = require('lodash'),
var tr = require('through'),
assert = require('assert'),

@@ -8,2 +8,4 @@ app = require('./app'),

var sess = null;
var Session = session({

@@ -14,5 +16,5 @@ app: app,

before(function (done) {
this.sess = new Session();
this.sess.request('get', '/')
beforeEach(function (done) {
sess = new Session();
sess.request('get', '/')
.expect(200)

@@ -24,3 +26,3 @@ .expect('GET,,1')

it('should increment session counter', function (done) {
this.sess.request('get', '/')
sess.request('get', '/')
.expect(200)

@@ -32,3 +34,3 @@ .expect('GET,,2')

it('should set enviromental variables', function(done) {
this.sess.request('get', '/env')
sess.request('get', '/env')
.expect(200)

@@ -43,4 +45,4 @@ .end(function(err, res) {

it('should destroy session', function (done) {
this.sess.destroy();
this.sess.get('/')
sess.destroy();
sess.get('/')
.expect(200)

@@ -51,5 +53,12 @@ .expect('GET,,1')

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 count = 1,
methods = {
var methods = {
'del' : 'DELETE',

@@ -62,7 +71,7 @@ 'get' : 'GET',

_.each(methods, function (v, m) {
it('should support ' + m, function (done) {
this.sess[m]('/')
Object.keys(methods).forEach(function (key) {
it('should support ' + key, function (done) {
sess[key]('/')
.expect(200)
.expect([v, '', ++count].join(','))
.expect(methods[key] + ',,2')
.end(done);

@@ -76,2 +85,4 @@ });

var sess = null;
var Session = session({

@@ -84,5 +95,5 @@ app: app,

before(function (done) {
this.sess = new Session();
this.sess.request('get', '/token')
beforeEach(function (done) {
sess = new Session();
sess.request('get', '/token')
.expect(200)

@@ -94,3 +105,3 @@ .expect('GET,token,1')

it('should increment session counter', function (done) {
this.sess.request('get', '/token')
sess.request('get', '/token')
.expect(200)

@@ -97,0 +108,0 @@ .expect('GET,token,2')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc