Huge News!Announcing our $40M Series B led by Abstract Ventures.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 3.0.0 to 3.1.0

11

index.js

@@ -32,3 +32,3 @@ var assign = require('object-assign'),

var url, isSecure;
var url, cookieAccessOptions, domain, path, secure, script;

@@ -38,2 +38,3 @@ // Unset supertest-session options before forwarding options to superagent.

before: undefined,
cookieAccess: undefined,
destroy: undefined,

@@ -46,4 +47,8 @@ helpers: undefined

url = parse(this.agent.get('').url);
isSecure = 'https:' == url.protocol;
this.cookieAccess = CookieAccess(url.hostname, url.pathname, isSecure);
cookieAccessOptions = this.options.cookieAccess || {};
domain = cookieAccessOptions.domain || url.hostname;
path = cookieAccessOptions.path || url.path;
secure = !!cookieAccessOptions.secure || 'https:' == url.protocol;
script = !!cookieAccessOptions.script || false;
this.cookieAccess = CookieAccess(domain, path, secure, script);
};

@@ -50,0 +55,0 @@

{
"name": "supertest-session",
"version": "3.0.0",
"version": "3.1.0",
"description": "Cookie-based session persistence for Supertest",

@@ -26,2 +26,6 @@ "main": "index.js",

"email": "cyoung@mobiquityinc.com"
},
{
"name": "Christoph Tavan",
"email": "dev@tavan.de"
}

@@ -28,0 +32,0 @@ ],

@@ -80,21 +80,14 @@ # Supertest sessions

### Accessing session data
### Accessing cookies
The cookies attached to the session may be retrieved from `session.cookies` at
any time, for instance to inspect the contents of the current session in an
external store.
The cookies attached to the session may be retrieved from `session.cookies`:
```js
it('should set session details correctly', function (done) {
var sessionCookie = _.find(testSession.cookies, function (cookie) {
return cookie.name === connect.sid;
});
memcached.get(sessionCookie.value, function (err, session) {
session.user.name.should.eq('Foobar');
done();
});
var sessionCookie = testSession.cookies.find(function (cookie) {
return cookie.name === connect.sid;
});
```
If you're using
### Request hooks

@@ -114,2 +107,22 @@

### Cookie Jar Access Options
By default supertest-session will derive the CookieAccessInfo config of the cookie jar from the
agent configuration. There might be cases where you want to override this, e.g. if you're testing
a service which is configured to run behind a proxy but which [sets secure
cookies](https://expressjs.com/en/api.html#req.secure). To have supertest-session expose these
secure cookies you can provide an override config to the internal call to
[CookieAccessInfo](https://github.com/bmeck/node-cookiejar#cookieaccessinfodomainpathsecurescript):
```js
var cookieAccess = {
domain: 'example.com',
path: '/testpath',
secure: true,
script: true,
};
var testSession = session(myApp, { cookieAccess: cookieAccess });
```
## License

@@ -116,0 +129,0 @@

@@ -110,1 +110,30 @@ var assert = require('assert'),

describe('Session with a cookieConfig', function () {
it('should configure default cookieAccess', function (done) {
var sess = session(app);
assert.strictEqual(sess.cookieAccess.domain, '127.0.0.1');
assert.strictEqual(sess.cookieAccess.path, '/');
assert.strictEqual(sess.cookieAccess.secure, false);
assert.strictEqual(sess.cookieAccess.script, false);
done();
});
it('should allow to specify cookieAccess', function (done) {
var cookieAccess = {
domain: 'example.com',
path: '/testpath',
secure: true,
script: true,
};
var sess = session(app, { cookieAccess: cookieAccess });
assert.strictEqual(sess.cookieAccess.domain, cookieAccess.domain);
assert.strictEqual(sess.cookieAccess.path, cookieAccess.path);
assert.strictEqual(sess.cookieAccess.secure, cookieAccess.secure);
assert.strictEqual(sess.cookieAccess.script, cookieAccess.script);
done();
});
});
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