supertest-session
Advanced tools
Comparing version 3.1.0 to 3.1.1
21
index.js
@@ -5,2 +5,3 @@ var assign = require('object-assign'), | ||
util = require('util'), | ||
http = require('http'), | ||
CookieAccess = require('cookiejar').CookieAccessInfo, | ||
@@ -16,3 +17,14 @@ parse = require('url').parse; | ||
var url = app; | ||
this.agent = supertest.agent(this.app, this.options); | ||
if (typeof app === 'function') { | ||
app = http.createServer(app); | ||
url = supertest.Test.prototype.serverAddress(app, '/'); | ||
} | ||
this.app = app; | ||
this.url = parse(url); | ||
this.options = options || {}; | ||
@@ -34,3 +46,3 @@ this.reset(); | ||
var url, cookieAccessOptions, domain, path, secure, script; | ||
var cookieAccessOptions, domain, path, secure, script; | ||
@@ -47,7 +59,6 @@ // Unset supertest-session options before forwarding options to superagent. | ||
url = parse(this.agent.get('').url); | ||
cookieAccessOptions = this.options.cookieAccess || {}; | ||
domain = cookieAccessOptions.domain || url.hostname; | ||
path = cookieAccessOptions.path || url.path; | ||
secure = !!cookieAccessOptions.secure || 'https:' == url.protocol; | ||
domain = cookieAccessOptions.domain || this.url.hostname; | ||
path = cookieAccessOptions.path || this.url.path; | ||
secure = !!cookieAccessOptions.secure || 'https:' == this.url.protocol; | ||
script = !!cookieAccessOptions.script || false; | ||
@@ -54,0 +65,0 @@ this.cookieAccess = CookieAccess(domain, path, secure, script); |
{ | ||
"name": "supertest-session", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Cookie-based session persistence for Supertest", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var assert = require('assert'), | ||
http = require('http'), | ||
app = require('./app'), | ||
@@ -61,18 +62,21 @@ session = require('../index'); | ||
var serverUrl, test; | ||
var sess, | ||
server = http.createServer(app); | ||
beforeEach(function () { | ||
// use supertest to set up the app.js server, returning a `Test` instance | ||
test = session(app).request('get', ''); | ||
// obtain the running server's URL | ||
serverUrl = test.url; | ||
beforeEach(function (done) { | ||
server.listen(0, function (err) { | ||
if (err) { | ||
return done(err); | ||
} | ||
sess = session('http://127.0.0.1:' + server.address().port); | ||
done(); | ||
}); | ||
}); | ||
afterEach(function (done) { | ||
test.end(done); | ||
server.close(done); | ||
}); | ||
it('behaves correctly', function (done) { | ||
sess = session(serverUrl) | ||
sess | ||
.get('/') | ||
@@ -79,0 +83,0 @@ .expect(200) |
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
Network access
Supply chain riskThis module accesses the network.
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
213
12457
12
2