Skip to content

Commit

Permalink
Allow TestAgent pass a cert and key to request (ladjs#373)
Browse files Browse the repository at this point in the history
* Update agent.js with superagent options

Superagent added the ability to set the SSL certificate and key parameters for requests, so they need to be added to supertest in order to pass them through to superagent.

* Cleaning up slightly
  • Loading branch information
toefraz authored and mikelax committed Jan 30, 2017
1 parent 188f8f2 commit 1d82e5b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ module.exports = TestAgent;
function TestAgent(app, options) {
if (!(this instanceof TestAgent)) return new TestAgent(app, options);
if (typeof app === 'function') app = http.createServer(app); // eslint-disable-line no-param-reassign
if (options) this._ca = options.ca;
if (options) {
this._ca = options.ca;
this._key = options.key;
this._cert = options.cert;
}
Agent.call(this);
this.app = app;
}
Expand All @@ -41,6 +45,8 @@ methods.forEach(function(method) {
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
var req = new Test(this.app, method.toUpperCase(), url);
req.ca(this._ca);
req.cert(this._cert);
req.key(this._key);

req.on('response', this._saveCookies.bind(this));
req.on('redirect', this._saveCookies.bind(this));
Expand Down

0 comments on commit 1d82e5b

Please sign in to comment.