smartssh/test/test.ts

66 lines
2.8 KiB
TypeScript
Raw Normal View History

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;
2016-06-01 02:25:59 +00:00
describe(".SshKey",function(){
it("'new' keyword should create a valid SshKey object",function(){
testSshKey = new smartssh.SshKey({
host:"example.com",
private:"someExamplePrivateKey",
public:"someExamplePublicKey"
});
testSshKey.should.be.instanceof(smartssh.SshKey);
2016-06-01 02:25:59 +00:00
});
it(".type should be a valid type",function(){
testSshKey.type.should.equal("duplex");
});
it(".publicKey should be public key",function(){
2016-06-25 00:29:34 +00:00
testSshKey.pubKey.should.equal("someExamplePublicKey");
});
it(".privateKey should be private key",function(){
2016-06-25 00:29:34 +00:00
testSshKey.privKey.should.equal("someExamplePrivateKey");
});
it(".publicKeyBase64 should be public key base 64 encoded",function(){
2016-06-25 00:29:34 +00:00
testSshKey.pubKeyBase64;
})
2016-06-01 02:25:59 +00:00
});
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(){
2016-06-25 00:29:34 +00:00
testSshInstance.getKey("github.com").pubKey.should.equal("someGitHubPublicKey");
2016-06-01 02:18:31 +00:00
})
it(".removeKey() should remove a key",function(){
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
testSshInstance.sshKeys[1].host.should.equal("github.com");
})
2016-06-01 02:25:59 +00:00
});
2016-06-01 00:31:29 +00:00
})