Skip to content

Commit

Permalink
Add backwards-compatibility with sshAuthAgent option
Browse files Browse the repository at this point in the history
Since d2f92b2, callers may be passing this option in and expect it to be used as the `agent` option for ssh2.
  • Loading branch information
steverice committed Apr 22, 2020
1 parent 779cdc1 commit e226c99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ var Modem = function (options) {
this.headers = opts.headers || {};
this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);

// Support sshAuthAgent for backwards-compatibility with d2f92b22cf284d537a57cc255ba11b4c4c5d7b61
if (options && options.sshAuthAgent) {
this.sshOptions.agent = options.sshAuthAgent;
}

if (this.key && this.cert && this.ca) {
this.protocol = 'https';
}
Expand Down
10 changes: 10 additions & 0 deletions test/modem_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,14 @@ describe('Modem', function() {
assert.strictEqual(modem.sshOptions.agent, '/var/lib/sock');
assert.strictEqual(modem.sshOptions.foo, 'bar');
});

it('supports custom sshAuthAgent for backwards-compatbility', function() {
process.env.DOCKER_HOST = 'ssh://[email protected]:5555';
process.env.SSH_AUTH_SOCK = '/var/lib/sock';

var modem = new Modem({
sshAuthAgent: '/var/lib/custom_agent',
});
assert.strictEqual(modem.sshOptions.agent, '/var/lib/custom_agent');
});
});

0 comments on commit e226c99

Please sign in to comment.