Skip to content

Commit 5e23869

Browse files
committedSep 20, 2022
feat(TestAgent): decoupled TestAgent and superagent's Agent to support 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`
1 parent 6d9b9cb commit 5e23869

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed
 

Diff for: ‎lib/agent.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ const Test = require('./test.js');
2020
function TestAgent(app, options) {
2121
if (!(this instanceof TestAgent)) return new TestAgent(app, options);
2222
if (typeof app === 'function') app = http.createServer(app); // eslint-disable-line no-param-reassign
23-
if (options) {
24-
this._ca = options.ca;
25-
this._key = options.key;
26-
this._cert = options.cert;
27-
}
28-
Agent.call(this);
23+
Agent.call(this, options);
2924
this.app = app;
3025
}
3126

@@ -45,9 +40,7 @@ TestAgent.prototype.host = function(host) {
4540
methods.forEach(function(method) {
4641
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
4742
const req = new Test(this.app, method.toUpperCase(), url, this._host);
48-
req.ca(this._ca);
49-
req.cert(this._cert);
50-
req.key(this._key);
43+
5144
if (this._host) {
5245
req.set('host', this._host);
5346
}

0 commit comments

Comments
 (0)
Please sign in to comment.