2016-05-31 17:16:45 +00:00
|
|
|
"use strict";
|
|
|
|
require("typings-test");
|
2016-06-01 00:31:29 +00:00
|
|
|
require("should");
|
|
|
|
var smartssh = require("../dist/index");
|
|
|
|
describe("smartssh", function () {
|
|
|
|
var testSshInstance;
|
|
|
|
var testSshKey;
|
|
|
|
describe("SshInstance", function () {
|
2016-06-01 02:18:31 +00:00
|
|
|
it("'new' keyword should create a new SshInstance object from class", function () {
|
2016-06-01 00:31:29 +00:00
|
|
|
testSshInstance = new smartssh.SshInstance();
|
|
|
|
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
|
|
|
});
|
2016-06-01 02:18:31 +00:00
|
|
|
it(".addKey() should accept a new SshKey object", function () {
|
2016-06-01 00:48:38 +00:00
|
|
|
testSshInstance.addKey(new smartssh.SshKey({
|
|
|
|
public: "somePublicKey",
|
|
|
|
private: "somePrivateKey",
|
|
|
|
host: "gitlab.com"
|
|
|
|
}));
|
|
|
|
testSshInstance.addKey(new smartssh.SshKey({
|
|
|
|
public: "somePublicKey",
|
|
|
|
private: "somePrivateKey",
|
|
|
|
host: "bitbucket.org"
|
|
|
|
}));
|
|
|
|
testSshInstance.addKey(new smartssh.SshKey({
|
2016-06-01 02:18:31 +00:00
|
|
|
public: "someGitHubPublicKey",
|
|
|
|
private: "someGitHubPrivateKey",
|
2016-06-01 00:48:38 +00:00
|
|
|
host: "github.com"
|
|
|
|
}));
|
|
|
|
});
|
2016-06-01 02:18:31 +00:00
|
|
|
it(".sshKeys should point to an array of sshKeys", function () {
|
2016-06-01 01:57:17 +00:00
|
|
|
var sshKeyArray = testSshInstance.sshKeys;
|
|
|
|
sshKeyArray.should.be.Array();
|
|
|
|
sshKeyArray[0].host.should.equal("gitlab.com");
|
2016-06-01 02:18:31 +00:00
|
|
|
sshKeyArray[1].host.should.equal("bitbucket.org");
|
|
|
|
sshKeyArray[2].host.should.equal("github.com");
|
|
|
|
});
|
|
|
|
it(".getKey() should get a specific key selected by host", function () {
|
|
|
|
testSshInstance.getKey("github.com").publicKey.should.equal("someGitHubPublicKey");
|
|
|
|
});
|
|
|
|
it(".removeKey() should remove a key", function () {
|
|
|
|
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
|
|
|
|
testSshInstance.sshKeys[1].host.should.equal("github.com");
|
2016-06-01 00:48:38 +00:00
|
|
|
});
|
2016-06-01 00:31:29 +00:00
|
|
|
});
|
|
|
|
});
|
2016-04-25 02:06:20 +00:00
|
|
|
|
2016-06-01 02:18:31 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLFFBQU8sUUFBUSxDQUFDLENBQUE7QUFDaEIsSUFBTyxRQUFRLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDM0MsUUFBUSxDQUFDLFVBQVUsRUFBQztJQUNoQixJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxVQUEwQixDQUFDO0lBQy9CLFFBQVEsQ0FBQyxhQUFhLEVBQUM7UUFDbkIsRUFBRSxDQUFDLGlFQUFpRSxFQUFDO1lBQ2pFLGVBQWUsR0FBRyxJQUFJLFFBQVEsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUM3QyxlQUFlLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQy9ELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLDZDQUE2QyxFQUFDO1lBQzdDLGVBQWUsQ0FBQyxNQUFNLENBQUMsSUFBSSxRQUFRLENBQUMsTUFBTSxDQUFDO2dCQUN2QyxNQUFNLEVBQUMsZUFBZTtnQkFDdEIsT0FBTyxFQUFDLGdCQUFnQjtnQkFDeEIsSUFBSSxFQUFDLFlBQVk7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mKHNtYXJ0c3NoLlNzaEluc3RhbmNlKTtcclxuICAgICAgICB9KTtcclxuICAgICAgICBpdChcIi5hZGRLZXkoKSBzaG91bGQgYWNjZXB0IGEgbmV3IFNzaEtleSBvYmplY3RcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICB0ZXN0U3NoSW5zdGFuY2UuYWRkS2V5KG5ldyBzbWFydHNzaC5Tc2hLZXkoe1xyXG4gICAgICAgICAgICAgICAgcHVibGljOlwic29tZVB1YmxpY0tleVwiLFxyXG4gICAgICAgICAgICAgICAgcHJpdmF0ZTpcInNvbWVQcml2YXRlS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBob3N0OlwiZ2l0bGFiLmNvbVwiXHJcbiAgICAgICAgICAgIH0pKTtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlLmFkZEtleShuZXcgc21hcnRzc2guU3NoS2V5KHtcclxuICAgICAgICAgICAgICAgIHB1YmxpYzpcInNvbWVQdWJsaWNLZXlcIixcclxuICAgICAgICAgICAgICAgIHByaXZhdGU6XCJzb21lUHJpdmF0ZUtleVwiLFxyXG4gICAgICAgICAgICAgICAgaG9zdDpcImJpdGJ1Y2tldC5vcmdcIlxyXG4gICAgICAgICAgICB9KSk7XHJcbiAgICAgICAgICAgIHRlc3RTc2hJbnN0YW5jZS5hZGRLZXkobmV3IHNtYXJ0c3NoLlNzaEtleSh7XHJcbiAgICAgICAgICAgICAgICBwdWJsaWM6XCJzb21lR2l0SHViUHVibGljS2V5XCIsXHJcbiAgICAgICAgICAgICAgICBwcml2YXRlOlwic29tZUdpdEh1YlByaXZhdGVLZXlcIixcclxuICAgICAgICAgICAgICAgIGhvc3Q6XCJnaXRodWIuY29tXCJcclxuICAgICAgICAgICAgfSkpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIGl0KFwiLnNzaEtleXMgc2hvdWxkIHBvaW50IHRvIGFuIGFycmF5IG9mIHNzaEtleXNcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBsZXQgc3NoS2V5QXJyYXkgPSB0ZXN0U3NoSW5zdGFu
|