smartssh/test/test.js

70 lines
9.8 KiB
JavaScript
Raw Normal View History

"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(".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);
});
it(".type should be a valid type", function () {
testSshKey.type.should.equal("duplex");
});
it(".publicKey should be public key", function () {
testSshKey.publicKey.should.equal("someExamplePublicKey");
});
it(".privateKey should be private key", function () {
testSshKey.privateKey.should.equal("someExamplePrivateKey");
});
it(".publicKeyBase64 should be public key base 64 encoded", function () {
testSshKey.publicKeyBase64;
});
});
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-13 22:11:20 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLFFBQU8sUUFBUSxDQUFDLENBQUE7QUFDaEIsSUFBTyxRQUFRLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDM0MsUUFBUSxDQUFDLFVBQVUsRUFBQztJQUNoQixJQUFJLGVBQW9DLENBQUM7SUFDekMsSUFBSSxVQUEwQixDQUFDO0lBQy9CLFFBQVEsQ0FBQyxTQUFTLEVBQUM7UUFDZixFQUFFLENBQUMsbURBQW1ELEVBQUM7WUFDbkQsVUFBVSxHQUFHLElBQUksUUFBUSxDQUFDLE1BQU0sQ0FBQztnQkFDN0IsSUFBSSxFQUFDLGFBQWE7Z0JBQ2xCLE9BQU8sRUFBQyx1QkFBdUI7Z0JBQy9CLE1BQU0sRUFBQyxzQkFBc0I7YUFDaEMsQ0FBQyxDQUFDO1lBQ0gsVUFBVSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUNyRCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyw4QkFBOEIsRUFBQztZQUM5QixVQUFVLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUM7UUFDM0MsQ0FBQyxDQUFDLENBQUM7UUFDSCxF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