added more tests

This commit is contained in:
2016-06-01 04:18:31 +02:00
parent 09d96fd94c
commit 78aa36c2be
10 changed files with 63 additions and 46 deletions

View File

@ -5,8 +5,4 @@ import {SshKey} from "./smartssh.classes.sshkey";
export let sshKeyArrayFromDir = function(dirArg:string):SshKey[]{
let sshKeyArray = []; //TODO
return sshKeyArray;
}
export let getKeyIndex = function(hostArg:string){
return 0; //TODO
}

View File

@ -27,19 +27,23 @@ export class SshInstance {
};
removeKey(sshKeyArg:SshKey){
this.sync("from");
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
this.sshKeyArray.splice(keyIndex,1);
let filteredArray = this.sshKeyArray.filter((sshKeyArg2:SshKey) => {
return (sshKeyArg != sshKeyArg2);
});
this.sshKeyArray = filteredArray;
this.sync("to");
};
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
this.sync("from");
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
this.sshKeyArray.splice(keyIndex,1,sshKeyNewArg);
let filteredArray = this.sshKeyArray.filter((sshKeyArg:SshKey) => {
return (sshKeyArg.host == "some"); //TODO
});
this.sshKeyArray = filteredArray;
this.sync("to");
};
//
getKey(hostArg:string){
getKey(hostArg:string):SshKey{
this.sync("from");
let filteredArray = this.sshKeyArray.filter(function(keyArg){
return (keyArg.host == hostArg);
@ -56,9 +60,9 @@ export class SshInstance {
sync(directionArg:string){
if(this.sshSync && directionArg == "from"){
this.sshDir.syncFromDir(); // call sync method of sshDir class;
} else if (this.sshSync && directionArg == "to") {
} else if(this.sshSync && directionArg == "to") {
this.sshDir.syncToDir();
} else {
} else if(this.sshSync) {
throw new Error("directionArg not recognised. Must be 'to' or 'from'");
}
};

View File

@ -23,7 +23,7 @@ export class SshKey {
return plugins.base64.encode(this.privKey);
}
get publicKey(){
return this.publicKey;
return this.pubKey;
}
get publicKeyBase64(){
return plugins.base64.encode(this.pubKey);