smartssh/test/test.js

77 lines
6.7 KiB
JavaScript
Raw Normal View History

"use strict";
require("typings-test");
2016-11-23 11:38:38 +00:00
const should = require("should");
const smartssh = require("../dist/index");
const path = require("path");
describe('smartssh', function () {
let testSshInstance;
let testSshKey;
describe('.SshKey', function () {
it("'new' keyword should create a valid SshKey object", function () {
testSshKey = new smartssh.SshKey({
2016-11-23 11:38:38 +00:00
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey'
});
2016-11-23 11:38:38 +00:00
should(testSshKey).be.instanceof(smartssh.SshKey);
});
2016-11-23 11:38:38 +00:00
it('.type should be a valid type', function () {
should(testSshKey.type).equal('duplex');
});
2016-11-23 11:38:38 +00:00
it('.publicKey should be public key', function () {
should(testSshKey.pubKey).equal('someExamplePublicKey');
});
2016-11-23 11:38:38 +00:00
it('.privateKey should be private key', function () {
should(testSshKey.privKey).equal('someExamplePrivateKey');
});
2016-11-23 11:38:38 +00:00
it('.publicKeyBase64 should be public key base 64 encoded', function () {
2016-06-25 00:29:34 +00:00
testSshKey.pubKeyBase64;
});
2016-11-23 11:38:38 +00:00
it('.store() should store the file to disk', function () {
testSshKey.store(path.join(process.cwd(), 'test/temp'));
2016-06-26 02:07:03 +00:00
});
});
2016-11-23 11:38:38 +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-26 14:16:12 +00:00
testSshInstance = new smartssh.SshInstance({
2016-11-23 11:38:38 +00:00
sshDirPath: path.join(process.cwd(), 'test/temp/')
2016-06-26 14:16:12 +00:00
});
2016-11-23 11:38:38 +00:00
should(testSshInstance).be.instanceof(smartssh.SshInstance);
2016-06-01 00:31:29 +00:00
});
2016-11-23 11:38:38 +00:00
it('.addKey() should accept a new SshKey object', function () {
2016-06-01 00:48:38 +00:00
testSshInstance.addKey(new smartssh.SshKey({
2016-11-23 11:38:38 +00:00
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'gitlab.com'
2016-06-01 00:48:38 +00:00
}));
testSshInstance.addKey(new smartssh.SshKey({
2016-11-23 11:38:38 +00:00
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'bitbucket.org'
2016-06-01 00:48:38 +00:00
}));
testSshInstance.addKey(new smartssh.SshKey({
2016-11-23 11:38:38 +00:00
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com'
2016-06-01 00:48:38 +00:00
}));
});
2016-11-23 11:38:38 +00:00
it('.sshKeys should point to an array of sshKeys', function () {
let sshKeyArray = testSshInstance.sshKeys;
should(sshKeyArray).be.Array();
should(sshKeyArray[0].host).equal('gitlab.com');
should(sshKeyArray[1].host).equal('bitbucket.org');
should(sshKeyArray[2].host).equal('github.com');
2016-06-01 02:18:31 +00:00
});
2016-11-23 11:38:38 +00:00
it('.getKey() should get a specific key selected by host', function () {
should(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey');
2016-06-01 02:18:31 +00:00
});
2016-11-23 11:38:38 +00:00
it('.removeKey() should remove a key', function () {
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
should(testSshInstance.sshKeys[1].host).equal('github.com');
2016-06-01 00:48:38 +00:00
});
2016-11-23 11:38:38 +00:00
it('it should store to disk', function () {
2016-06-26 14:16:12 +00:00
testSshInstance.writeToDisk();
});
2016-06-01 00:31:29 +00:00
});
});
2016-11-23 11:38:38 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsMENBQTBDO0FBQzFDLDZCQUE2QjtBQUM3QixRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLElBQUksZUFBcUMsQ0FBQTtJQUN6QyxJQUFJLFVBQTJCLENBQUE7SUFDL0IsUUFBUSx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