add some tests
This commit is contained in:
parent
9a96bbd266
commit
904129706c
1
dist/smartssh.classes.sshinstance.d.ts
vendored
1
dist/smartssh.classes.sshinstance.d.ts
vendored
@ -11,6 +11,7 @@ export declare class SshInstance {
|
|||||||
});
|
});
|
||||||
addKey(sshKeyArg: SshKey): void;
|
addKey(sshKeyArg: SshKey): void;
|
||||||
getKey(hostArg: string): SshKey;
|
getKey(hostArg: string): SshKey;
|
||||||
|
getKeys(): SshKey[];
|
||||||
removeKey(sshKeyArg: SshKey): void;
|
removeKey(sshKeyArg: SshKey): void;
|
||||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||||
sync(): void;
|
sync(): void;
|
||||||
|
5
dist/smartssh.classes.sshinstance.js
vendored
5
dist/smartssh.classes.sshinstance.js
vendored
File diff suppressed because one or more lines are too long
22
test/test.js
22
test/test.js
@ -10,7 +10,27 @@ describe("smartssh", function () {
|
|||||||
testSshInstance = new smartssh.SshInstance();
|
testSshInstance = new smartssh.SshInstance();
|
||||||
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
||||||
});
|
});
|
||||||
|
it("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: "somePublicKey",
|
||||||
|
private: "somePrivateKey",
|
||||||
|
host: "github.com"
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
it("should return an array of sshKeys", function () {
|
||||||
|
testSshInstance.getKeys();
|
||||||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HJcbiAgICAgICAgICAgICAgICBwcml2YXRlOlwic29tZVByaXZhdGVLZXlcIixcclxuICAgICAgICAgICAgICAgIGhvc3Q6XCJnaXRodWIuY29tXCJcclxuICAgICAgICAgICAgfSkpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIGl0KFwic2hvdWxkIHJldHVybiBhbiBhcnJheSBvZiBzc2hLZXlzXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdGVzdFNzaEluc3RhbmNlLmdldEtleXMoKTtcclxuICAgICAgICB9KTtcclxuICAgIH0pXHJcbn0pIl19
|
||||||
|
21
test/test.ts
21
test/test.ts
@ -9,8 +9,25 @@ describe("smartssh",function(){
|
|||||||
testSshInstance = new smartssh.SshInstance();
|
testSshInstance = new smartssh.SshInstance();
|
||||||
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
||||||
});
|
});
|
||||||
|
it("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:"somePublicKey",
|
||||||
|
private:"somePrivateKey",
|
||||||
|
host:"github.com"
|
||||||
|
}));
|
||||||
|
});
|
||||||
it("should return an array of sshKeys",function(){
|
it("should return an array of sshKeys",function(){
|
||||||
|
testSshInstance.getKeys();
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
@ -31,6 +31,11 @@ export class SshInstance {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getKeys(){
|
||||||
|
return this.sshKeys;
|
||||||
|
}
|
||||||
|
|
||||||
removeKey(sshKeyArg:SshKey){
|
removeKey(sshKeyArg:SshKey){
|
||||||
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
||||||
this.sshKeys.splice(keyIndex,1);
|
this.sshKeys.splice(keyIndex,1);
|
||||||
|
Loading…
Reference in New Issue
Block a user