2016-05-31 16:48:46 +00:00
|
|
|
import "typings-test"
|
2016-06-01 00:31:29 +00:00
|
|
|
import "should";
|
|
|
|
import smartssh = require("../dist/index");
|
|
|
|
describe("smartssh",function(){
|
|
|
|
let testSshInstance:smartssh.SshInstance;
|
|
|
|
let testSshKey:smartssh.SshKey;
|
|
|
|
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
|
|
|
let 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");
|
2016-06-01 00:48:38 +00:00
|
|
|
});
|
2016-06-01 02:18:31 +00:00
|
|
|
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:31:29 +00:00
|
|
|
})
|
|
|
|
})
|