update to latest standards

This commit is contained in:
2017-06-15 17:52:22 +02:00
parent 56318f28cf
commit 6853fa28b6
19 changed files with 816 additions and 195 deletions

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,77 +0,0 @@
"use strict";
require("typings-test");
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({
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey'
});
should(testSshKey).be.instanceof(smartssh.SshKey);
});
it('.type should be a valid type', function () {
should(testSshKey.type).equal('duplex');
});
it('.publicKey should be public key', function () {
should(testSshKey.pubKey).equal('someExamplePublicKey');
});
it('.privateKey should be private key', function () {
should(testSshKey.privKey).equal('someExamplePrivateKey');
});
it('.publicKeyBase64 should be public key base 64 encoded', function () {
testSshKey.pubKeyBase64;
});
it('.store() should store the file to disk', function () {
testSshKey.store(path.join(process.cwd(), 'test/temp'));
});
});
describe('.SshInstance', function () {
it("'new' keyword should create a new SshInstance object from class", function () {
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(), 'test/temp/')
});
should(testSshInstance).be.instanceof(smartssh.SshInstance);
});
it('.addKey() should accept a new SshKey object', function () {
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({
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com'
}));
});
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');
});
it('.getKey() should get a specific key selected by host', function () {
should(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey');
});
it('.removeKey() should remove a key', function () {
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
should(testSshInstance.sshKeys[1].host).equal('github.com');
});
it('it should store to disk', function () {
testSshInstance.writeToDisk();
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsMENBQTBDO0FBQzFDLDZCQUE2QjtBQUM3QixRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLElBQUksZUFBcUMsQ0FBQTtJQUN6QyxJQUFJLFVBQTJCLENBQUE7SUFDL0IsUUFBUSxDQUFDLFNBQVMsRUFBQztRQUNmLEVBQUUsQ0FBQyxtREFBbUQsRUFBQztZQUNuRCxVQUFVLEdBQUcsSUFBSSxRQUFRLENBQUMsTUFBTSxDQUFDO2dCQUM3QixJQUFJLEVBQUUsYUFBYTtnQkFDbkIsT0FBTyxFQUFFLHVCQUF1QjtnQkFDaEMsTUFBTSxFQUFFLHNCQUFzQjthQUNqQyxDQUFDLENBQUE7WUFDRixNQUFNLENBQUMsVUFBVSxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUE7UUFDckQsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsOEJBQThCLEVBQUM7WUFDOUIsTUFBTSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUE7UUFDM0MsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsaUNBQWlDLEVBQUM7WUFDakMsTUFBTSx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xDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxzREFBc0QsRUFBQztZQUN0RCxNQUFNLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLENBQUMscUJBQXFCLENBQUMsQ0FBQTtRQUNwRixDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxrQ0FBa0MsRUFBQztZQUNsQyxlQUFlLENBQUMsU0FBUyxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQTtZQUNsRSxNQUFNLENBQUMsZUFBZSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDL0QsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMseUJBQXlCLEVBQUM7WUFDekIsZUFBZSxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -1,75 +1,78 @@
import 'typings-test'
import * as should from 'should'
import { expect, tap } from 'tapbundle'
import smartssh = require('../dist/index')
import path = require('path')
describe('smartssh',function(){
let testSshInstance: smartssh.SshInstance
let testSshKey: smartssh.SshKey
describe('.SshKey',function(){
it("'new' keyword should create a valid SshKey object",function(){
testSshKey = new smartssh.SshKey({
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey'
})
should(testSshKey).be.instanceof(smartssh.SshKey)
})
it('.type should be a valid type',function(){
should(testSshKey.type).equal('duplex')
})
it('.publicKey should be public key',function(){
should(testSshKey.pubKey).equal('someExamplePublicKey')
})
it('.privateKey should be private key',function(){
should(testSshKey.privKey).equal('someExamplePrivateKey')
})
it('.publicKeyBase64 should be public key base 64 encoded',function(){
testSshKey.pubKeyBase64
})
it('.store() should store the file to disk',function(){
testSshKey.store(path.join(process.cwd(),'test/temp'))
})
})
describe('.SshInstance',function(){
it("'new' keyword should create a new SshInstance object from class",function(){
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(),'test/temp/')
})
should(testSshInstance).be.instanceof(smartssh.SshInstance)
})
it('.addKey() should accept a new SshKey object',function(){
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({
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com'
}))
})
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')
})
it('.getKey() should get a specific key selected by host',function(){
should(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey')
})
it('.removeKey() should remove a key',function(){
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'))
should(testSshInstance.sshKeys[1].host).equal('github.com')
})
it('it should store to disk',function(){
testSshInstance.writeToDisk()
})
})
let testSshInstance: smartssh.SshInstance
let testSshKey: smartssh.SshKey
tap.test('should create a valid SshKey object', async () => {
testSshKey = new smartssh.SshKey({
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey'
})
expect(testSshKey).to.be.instanceof(smartssh.SshKey)
})
tap.test('.type should be a valid type', async () => {
expect(testSshKey.type).equal('duplex')
})
tap.test('.publicKey should be public key', async () => {
expect(testSshKey.pubKey).equal('someExamplePublicKey')
})
tap.test('.privateKey should be private key', async () => {
expect(testSshKey.privKey).equal('someExamplePrivateKey')
})
tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
// tslint:disable-next-line:no-unused-expression
testSshKey.pubKeyBase64
})
tap.test('.store() should store the file to disk', async () => {
testSshKey.store(path.join(process.cwd(), 'test/temp'))
})
// SSH INstance
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(), 'test/temp/')
})
expect(testSshInstance).be.instanceof(smartssh.SshInstance)
})
tap.test('.addKey() should accept a new SshKey object', async () => {
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({
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com'
}))
})
tap.test('.sshKeys should point to an array of sshKeys', async () => {
let sshKeyArray = testSshInstance.sshKeys
expect(sshKeyArray).be.instanceOf(Array)
expect(sshKeyArray[ 0 ].host).equal('gitlab.com')
expect(sshKeyArray[ 1 ].host).equal('bitbucket.org')
expect(sshKeyArray[ 2 ].host).equal('github.com')
})
tap.test('.getKey() should get a specific key selected by host', async () => {
expect(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey')
})
tap.test('.removeKey() should remove a key', async () => {
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'))
expect(testSshInstance.sshKeys[ 1 ].host).equal('github.com')
})
tap.test('it should store to disk', async () => {
testSshInstance.writeToDisk()
})
tap.start()