fix(ssh): modernize filesystem handling and package exports for NodeNext compatibility
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartssh from '../ts/index.js';
|
||||
import * as path from 'path';
|
||||
|
||||
const testDir = path.join(process.cwd(), '.nogit/test/temp');
|
||||
|
||||
let testSshInstance: smartssh.SshInstance;
|
||||
let testSshKey: smartssh.SshKey;
|
||||
tap.test('should create a valid SshKey object', async () => {
|
||||
@@ -26,13 +28,13 @@ tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
|
||||
testSshKey.pubKeyBase64;
|
||||
});
|
||||
tap.test('.store() should store the file to disk', async () => {
|
||||
testSshKey.store(path.join(process.cwd(), 'test/temp'));
|
||||
await testSshKey.store(testDir);
|
||||
});
|
||||
|
||||
// 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/'),
|
||||
sshDirPath: testDir,
|
||||
});
|
||||
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
|
||||
});
|
||||
@@ -69,11 +71,15 @@ tap.test('.sshKeys should point to an array of sshKeys', async () => {
|
||||
});
|
||||
|
||||
tap.test('.getKey() should get a specific key selected by host', async () => {
|
||||
expect(testSshInstance.getKey('github.com').pubKey).toEqual('someGitHubPublicKey');
|
||||
const sshKey = testSshInstance.getKey('github.com');
|
||||
expect(sshKey).toBeInstanceOf(smartssh.SshKey);
|
||||
expect(sshKey?.pubKey).toEqual('someGitHubPublicKey');
|
||||
});
|
||||
|
||||
tap.test('.removeKey() should remove a key', async () => {
|
||||
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
|
||||
const sshKey = testSshInstance.getKey('bitbucket.org');
|
||||
expect(sshKey).toBeInstanceOf(smartssh.SshKey);
|
||||
testSshInstance.removeKey(sshKey!);
|
||||
expect(testSshInstance.sshKeys[1].host).toEqual('github.com');
|
||||
});
|
||||
|
||||
@@ -81,4 +87,4 @@ tap.test('it should store to disk', async () => {
|
||||
testSshInstance.writeToDisk();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user