-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow arbitrary sshOptions to be passed to ssh2
This allows for an arbitrary `sshOptions` to be passed in `Modem` options and be used when passed to the `ssh` constructor to get an agent from the `ssh2` library. Tests are added to be sure we're still respecting the `SSH_AUTH_SOCK` env var.
- Loading branch information
Showing
2 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,4 +144,29 @@ describe('Modem', function() { | |
assert.ok(modem.agent instanceof http.Agent); | ||
assert.strictEqual(modem.agent, httpAgent); | ||
}); | ||
|
||
it('should set default ssh agent options from DOCKER_HOST', function() { | ||
process.env.DOCKER_HOST = 'ssh://[email protected]:5555'; | ||
process.env.SSH_AUTH_SOCK = '/var/lib/sock'; | ||
|
||
var modem = new Modem(); | ||
assert.strictEqual(modem.protocol, 'ssh'); | ||
assert.strictEqual(modem.username, 'user'); | ||
assert.ok(modem.sshOptions); | ||
assert.strictEqual(modem.sshOptions.agent, '/var/lib/sock'); | ||
}); | ||
|
||
it('should combine custom ssh agent options', function() { | ||
process.env.DOCKER_HOST = 'ssh://[email protected]:5555'; | ||
process.env.SSH_AUTH_SOCK = '/var/lib/sock'; | ||
|
||
var modem = new Modem({ | ||
sshOptions: { | ||
foo: 'bar', // options are arbitrary, whatever ssh2 supports | ||
}, | ||
}); | ||
assert.ok(modem.sshOptions); | ||
assert.strictEqual(modem.sshOptions.agent, '/var/lib/sock'); | ||
assert.strictEqual(modem.sshOptions.foo, 'bar'); | ||
}); | ||
}); |