Skip to content

Commit

Permalink
feat(TestAgent): decoupled TestAgent and superagent's Agent to suppor…
Browse files Browse the repository at this point in the history
…t more than `ca`, `key`, `cert`

`options` object is now a direct passthrough, TestAgent can support whichever superagent's Agent is expecting
i.e. `ca`, `key`, `cert`, `pfx`, `rejectUnauthorized`
  • Loading branch information
lamweili committed Sep 20, 2022
1 parent 6d9b9cb commit 5e23869
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/agent.js
Expand Up @@ -20,12 +20,7 @@ const Test = require('./test.js');
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;
this._key = options.key;
this._cert = options.cert;
}
Agent.call(this);
Agent.call(this, options);
this.app = app;
}

Expand All @@ -45,9 +40,7 @@ TestAgent.prototype.host = function(host) {
methods.forEach(function(method) {
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
const req = new Test(this.app, method.toUpperCase(), url, this._host);
req.ca(this._ca);
req.cert(this._cert);
req.key(this._key);

if (this._host) {
req.set('host', this._host);
}
Expand Down

0 comments on commit 5e23869

Please sign in to comment.