From e226c99ae602efc3e9313fba62dd9923f3cde540 Mon Sep 17 00:00:00 2001 From: Steve Rice Date: Wed, 22 Apr 2020 08:41:11 -0700 Subject: [PATCH] Add backwards-compatibility with sshAuthAgent option Since d2f92b22cf284d537a57cc255ba11b4c4c5d7b61, callers may be passing this option in and expect it to be used as the `agent` option for ssh2. --- lib/modem.js | 5 +++++ test/modem_test.js | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/modem.js b/lib/modem.js index 846d98b..60ec49e 100644 --- a/lib/modem.js +++ b/lib/modem.js @@ -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'; } diff --git a/test/modem_test.js b/test/modem_test.js index 1de08e2..8a0855b 100644 --- a/test/modem_test.js +++ b/test/modem_test.js @@ -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://user@192.168.59.105: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'); + }); });