ssh-client-wrapper 2.13.1 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +61 -0
- package/package.json +3 -2
- package/.dockerignore +0 -2
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/coverage_report.yml +0 -24
- package/.github/workflows/release.yml +0 -29
- package/.github/workflows/run_test.yml +0 -40
- package/.husky/_pre-commit +0 -1
- package/.husky/pre-commit +0 -1
- package/.releaserc.json +0 -16
- package/CHANGELOG.md +0 -20
- package/Dockerfile +0 -7
- package/Dockerfile-bullseye +0 -7
- package/Dockerfile-buster +0 -7
- package/compose.yml +0 -36
- package/eslint.config.mjs +0 -181
- package/run_test_all.sh +0 -18
- package/run_test_local.sh +0 -13
- package/test/getSshOption.js +0 -49
- package/test/interface.js +0 -182
- package/test/rsyncExec.js +0 -406
- package/test/sanityCheck.js +0 -106
- package/test/sshExec.js +0 -145
- package/test/testUtil/hostInfo.js +0 -9
- package/test/testUtil/testFiles.js +0 -101
- package/test/testUtil/testrc +0 -1
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare module "ssh-client-wrapper" {
|
|
2
|
+
type HostInfo = {
|
|
3
|
+
host: string;
|
|
4
|
+
user: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
password?: string | (() => string);
|
|
7
|
+
passphrase?: string | (() => string);
|
|
8
|
+
keyFile?: string;
|
|
9
|
+
noStrictHostKeyChecking?: boolean;
|
|
10
|
+
ControlPersist?: number;
|
|
11
|
+
ConnectTimeout?: number;
|
|
12
|
+
maxRetry?: number;
|
|
13
|
+
retryDuration?: number;
|
|
14
|
+
rcfile?: string;
|
|
15
|
+
prependCmd?: string;
|
|
16
|
+
sshOpt?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
class SshClientWrapper {
|
|
20
|
+
constructor(hostInfo: HostInfo);
|
|
21
|
+
exec(
|
|
22
|
+
cmd: string,
|
|
23
|
+
timeout?: number,
|
|
24
|
+
outputCallback?: (data: string) => void,
|
|
25
|
+
rcfile?: string,
|
|
26
|
+
prependCmd?: string
|
|
27
|
+
): Promise<number>;
|
|
28
|
+
execAndGetOutput(
|
|
29
|
+
cmd: string,
|
|
30
|
+
timeout?: number,
|
|
31
|
+
rcfile?: string,
|
|
32
|
+
prependCmd?: string
|
|
33
|
+
): Promise<{ output: string[]; rt: number }>;
|
|
34
|
+
ls(
|
|
35
|
+
target: string,
|
|
36
|
+
lsOpt?: string[],
|
|
37
|
+
timeout?: number
|
|
38
|
+
): Promise<string[] | number>;
|
|
39
|
+
expect(
|
|
40
|
+
cmd: string,
|
|
41
|
+
expects: [string, string][],
|
|
42
|
+
timeout?: number
|
|
43
|
+
): Promise<number>;
|
|
44
|
+
send(
|
|
45
|
+
src: string[],
|
|
46
|
+
dst: string,
|
|
47
|
+
opt?: string[],
|
|
48
|
+
timeout?: number
|
|
49
|
+
): Promise<void>;
|
|
50
|
+
recv(
|
|
51
|
+
src: string[],
|
|
52
|
+
dst: string,
|
|
53
|
+
opt?: string[],
|
|
54
|
+
timeout?: number
|
|
55
|
+
): Promise<void>;
|
|
56
|
+
canConnect(timeout?: number): Promise<boolean>;
|
|
57
|
+
disconnect(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default SshClientWrapper;
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-client-wrapper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "wrapper library for open ssh client and rsync",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ssh",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
16
17
|
"scripts": {
|
|
17
18
|
"mocha": "mocha --recursive test",
|
|
18
19
|
"lint": "eslint --fix ./",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"ajv": "^8.17.1",
|
|
38
39
|
"ajv-keywords": "^5.1.0",
|
|
39
|
-
"debug": "^4.4.
|
|
40
|
+
"debug": "^4.4.3",
|
|
40
41
|
"glob": "^11.0.3",
|
|
41
42
|
"node-pty-prebuilt-multiarch": "^0.10.1-pre.5"
|
|
42
43
|
},
|
package/.dockerignore
DELETED
package/.github/dependabot.yml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
-
|
|
6
|
-
version: 2
|
|
7
|
-
updates:
|
|
8
|
-
- package-ecosystem: "" # See documentation for possible values
|
|
9
|
-
directory: "/" # Location of package manifests
|
|
10
|
-
schedule:
|
|
11
|
-
interval: "weekly"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: report coverage data to code climate
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
jobs:
|
|
7
|
-
test:
|
|
8
|
-
uses: ./.github/workflows/run_test.yml
|
|
9
|
-
coverage:
|
|
10
|
-
needs:
|
|
11
|
-
- test
|
|
12
|
-
name: coverage report
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
- uses: actions/download-artifact@v4
|
|
17
|
-
with:
|
|
18
|
-
name: code-coverage-report
|
|
19
|
-
- uses: paambaati/codeclimate-action@v5.0.0
|
|
20
|
-
env:
|
|
21
|
-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
|
22
|
-
with:
|
|
23
|
-
coverageLocations: "coverage-report.lcov:lcov"
|
|
24
|
-
debug: true
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Release and Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
test:
|
|
10
|
-
uses: ./.github/workflows/run_test.yml
|
|
11
|
-
|
|
12
|
-
release:
|
|
13
|
-
needs: test
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
permissions:
|
|
16
|
-
contents: write
|
|
17
|
-
issues: write
|
|
18
|
-
pull-requests: write
|
|
19
|
-
steps:
|
|
20
|
-
- uses: actions/checkout@v4
|
|
21
|
-
- uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: 20
|
|
24
|
-
- run: npm ci
|
|
25
|
-
- name: Semantic Release
|
|
26
|
-
uses: cycjimmy/semantic-release-action@v4
|
|
27
|
-
env:
|
|
28
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: run UT
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
workflow_call:
|
|
7
|
-
concurrency:
|
|
8
|
-
group: ${{ github.workflow }}-${{ github.ref }}
|
|
9
|
-
cancel-in-progress: true
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
services:
|
|
13
|
-
testbed:
|
|
14
|
-
image: naoso5/test-sshd
|
|
15
|
-
ports:
|
|
16
|
-
- 10022:22
|
|
17
|
-
env:
|
|
18
|
-
TEST_USER: testuser
|
|
19
|
-
TEST_PW: passw0rd
|
|
20
|
-
TEST_PORT: 10022
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
strategy:
|
|
23
|
-
matrix:
|
|
24
|
-
node-version: [16.x, 18.x, 20.x, 22.x]
|
|
25
|
-
steps:
|
|
26
|
-
- uses: actions/checkout@v4
|
|
27
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
28
|
-
uses: actions/setup-node@v4
|
|
29
|
-
with:
|
|
30
|
-
node-version: ${{ matrix.node-version }}
|
|
31
|
-
- run: npm ci
|
|
32
|
-
- run: npm run test
|
|
33
|
-
- run: npm run coverage
|
|
34
|
-
if: matrix.node-version == '22.x'
|
|
35
|
-
- uses: actions/upload-artifact@v4
|
|
36
|
-
if: matrix.node-version == '22.x'
|
|
37
|
-
with:
|
|
38
|
-
name: code-coverage-report
|
|
39
|
-
path: coverage-report.lcov
|
|
40
|
-
retention-days: 1
|
package/.husky/_pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx lint-staged
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx lint-staged
|
package/.releaserc.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": ["main"],
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@semantic-release/commit-analyzer",
|
|
5
|
-
"@semantic-release/release-notes-generator",
|
|
6
|
-
"@semantic-release/changelog",
|
|
7
|
-
["@semantic-release/npm", {
|
|
8
|
-
"npmPublish": true
|
|
9
|
-
}],
|
|
10
|
-
["@semantic-release/git", {
|
|
11
|
-
"assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
|
|
12
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\\n\\n${nextRelease.notes}"
|
|
13
|
-
}],
|
|
14
|
-
"@semantic-release/github"
|
|
15
|
-
]
|
|
16
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
## [2.13.1](https://github.com/so5/ssh-client-wrapper/compare/v2.13.0...v2.13.1) (2025-08-20)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* Update Code Climate workflow trigger ([7cf0a93](https://github.com/so5/ssh-client-wrapper/commit/7cf0a93913ceef762c267cb3a947c176479ce068))
|
|
7
|
-
|
|
8
|
-
# [2.13.0](https://github.com/so5/ssh-client-wrapper/compare/v2.12.4...v2.13.0) (2025-08-20)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* upgrade debug from 4.4.0 to 4.4.1 ([35f966a](https://github.com/so5/ssh-client-wrapper/commit/35f966a7212d6bb9677964688bb94ae06f869ada))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
### Features
|
|
17
|
-
|
|
18
|
-
* Improve DX and automate releases ([805f2ea](https://github.com/so5/ssh-client-wrapper/commit/805f2ea7756f6ad61238a4a21d86575a17e748d9))
|
|
19
|
-
* Rewrite in ESM ([c5a95c1](https://github.com/so5/ssh-client-wrapper/commit/c5a95c18401e7b373249d3707609f2a9576f7400))
|
|
20
|
-
* Rewrite in ESM ([71ed6f5](https://github.com/so5/ssh-client-wrapper/commit/71ed6f56af43cac1471cbf4a4ed3016f7e55ab4d))
|
package/Dockerfile
DELETED
package/Dockerfile-bullseye
DELETED
package/Dockerfile-buster
DELETED
package/compose.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
testbed:
|
|
3
|
-
image: naoso5/test-sshd
|
|
4
|
-
ports:
|
|
5
|
-
- "4100:22"
|
|
6
|
-
container_name: testbed
|
|
7
|
-
tester:
|
|
8
|
-
build:
|
|
9
|
-
context: .
|
|
10
|
-
dockerfile: Dockerfile
|
|
11
|
-
environment:
|
|
12
|
-
TEST_USER: testuser
|
|
13
|
-
TEST_PW: passw0rd
|
|
14
|
-
TEST_HOST: testbed
|
|
15
|
-
working_dir: /work/ssh-client-wrapper
|
|
16
|
-
command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
|
|
17
|
-
tester-bullseye:
|
|
18
|
-
build:
|
|
19
|
-
context: .
|
|
20
|
-
dockerfile: Dockerfile-bullseye
|
|
21
|
-
environment:
|
|
22
|
-
TEST_USER: testuser
|
|
23
|
-
TEST_PW: passw0rd
|
|
24
|
-
TEST_HOST: testbed
|
|
25
|
-
working_dir: /work/ssh-client-wrapper
|
|
26
|
-
command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
|
|
27
|
-
tester-buster:
|
|
28
|
-
build:
|
|
29
|
-
context: .
|
|
30
|
-
dockerfile: Dockerfile-buster
|
|
31
|
-
environment:
|
|
32
|
-
TEST_USER: testuser
|
|
33
|
-
TEST_PW: passw0rd
|
|
34
|
-
TEST_HOST: testbed
|
|
35
|
-
working_dir: /work/ssh-client-wrapper
|
|
36
|
-
command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
|
package/eslint.config.mjs
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import stylistic from "@stylistic/eslint-plugin";
|
|
4
|
-
import jsdoc from "eslint-plugin-jsdoc";
|
|
5
|
-
import eslintPluginChaiFriendly from "eslint-plugin-chai-friendly";
|
|
6
|
-
import eslintPluginChaiExpect from "eslint-plugin-chai-expect";
|
|
7
|
-
|
|
8
|
-
const styleRules = {
|
|
9
|
-
"arrow-body-style": ["error", "always"],
|
|
10
|
-
"@stylistic/arrow-spacing": [
|
|
11
|
-
"error",
|
|
12
|
-
{
|
|
13
|
-
after: false,
|
|
14
|
-
before: false
|
|
15
|
-
}],
|
|
16
|
-
"@stylistic/comma-dangle": [
|
|
17
|
-
"error",
|
|
18
|
-
"never"
|
|
19
|
-
],
|
|
20
|
-
"@stylistic/spaced-comment": [
|
|
21
|
-
"error",
|
|
22
|
-
"never"
|
|
23
|
-
],
|
|
24
|
-
"@stylistic/lines-around-comment": [
|
|
25
|
-
"error",
|
|
26
|
-
{
|
|
27
|
-
beforeBlockComment: true,
|
|
28
|
-
afterBlockComment: false,
|
|
29
|
-
beforeLineComment: false,
|
|
30
|
-
afterLineComment: false,
|
|
31
|
-
allowBlockStart: true
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"@stylistic/lines-between-class-members": [
|
|
35
|
-
"error",
|
|
36
|
-
"always",
|
|
37
|
-
{
|
|
38
|
-
exceptAfterSingleLine: true
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"@stylistic/newline-per-chained-call": [
|
|
42
|
-
"error",
|
|
43
|
-
{
|
|
44
|
-
ignoreChainWithDepth: 2
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"@stylistic/padded-blocks": [
|
|
48
|
-
"error",
|
|
49
|
-
"never"
|
|
50
|
-
],
|
|
51
|
-
"@stylistic/brace-style": [
|
|
52
|
-
"error",
|
|
53
|
-
"1tbs",
|
|
54
|
-
{
|
|
55
|
-
allowSingleLine: true
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"@stylistic/padding-line-between-statements": [
|
|
59
|
-
"error",
|
|
60
|
-
{
|
|
61
|
-
blankLine: "any",
|
|
62
|
-
prev: [
|
|
63
|
-
"const",
|
|
64
|
-
"let",
|
|
65
|
-
"var"
|
|
66
|
-
],
|
|
67
|
-
next: "*"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
blankLine: "always",
|
|
71
|
-
prev: "*",
|
|
72
|
-
next: [
|
|
73
|
-
"class",
|
|
74
|
-
"do",
|
|
75
|
-
"for",
|
|
76
|
-
"function",
|
|
77
|
-
"switch",
|
|
78
|
-
"try",
|
|
79
|
-
"while"
|
|
80
|
-
]
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
blankLine: "any",
|
|
84
|
-
prev: [
|
|
85
|
-
"const",
|
|
86
|
-
"let",
|
|
87
|
-
"var",
|
|
88
|
-
"for",
|
|
89
|
-
"while",
|
|
90
|
-
"do",
|
|
91
|
-
"block-like",
|
|
92
|
-
"multiline-block-like"
|
|
93
|
-
],
|
|
94
|
-
next: [
|
|
95
|
-
"block-like",
|
|
96
|
-
"do",
|
|
97
|
-
"for",
|
|
98
|
-
"multiline-block-like",
|
|
99
|
-
"switch",
|
|
100
|
-
"try",
|
|
101
|
-
"while"
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
"@stylistic/quotes": [
|
|
106
|
-
"error",
|
|
107
|
-
"double"
|
|
108
|
-
],
|
|
109
|
-
"@stylistic/semi": [
|
|
110
|
-
"error",
|
|
111
|
-
"always"
|
|
112
|
-
]
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const jsdocRules = {
|
|
116
|
-
"jsdoc/require-jsdoc": ["warn", { enableFixer: false }],
|
|
117
|
-
"jsdoc/require-param": ["warn", { enableFixer: false }],
|
|
118
|
-
"jsdoc/require-param-description": "warn",
|
|
119
|
-
"jsdoc/require-param-name": "warn",
|
|
120
|
-
"jsdoc/require-param-type": "warn",
|
|
121
|
-
"jsdoc/require-hyphen-before-param-description": [
|
|
122
|
-
"warn",
|
|
123
|
-
"always"
|
|
124
|
-
],
|
|
125
|
-
"jsdoc/require-returns": "warn",
|
|
126
|
-
"jsdoc/require-returns-check": "error"
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export default [
|
|
130
|
-
// Global configuration
|
|
131
|
-
{
|
|
132
|
-
ignores: ["coverage-report.lcov", "node_modules/"]
|
|
133
|
-
},
|
|
134
|
-
js.configs.recommended,
|
|
135
|
-
{
|
|
136
|
-
plugins: {
|
|
137
|
-
"@stylistic": stylistic
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
// Lib configuration
|
|
141
|
-
{
|
|
142
|
-
files: ["lib/**/*.js"],
|
|
143
|
-
plugins: {
|
|
144
|
-
jsdoc
|
|
145
|
-
},
|
|
146
|
-
languageOptions: {
|
|
147
|
-
ecmaVersion: "latest",
|
|
148
|
-
sourceType: "module",
|
|
149
|
-
globals: {
|
|
150
|
-
...globals.es2021,
|
|
151
|
-
...globals.node
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
rules: {
|
|
155
|
-
...styleRules,
|
|
156
|
-
...jsdocRules
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
// Test configuration
|
|
160
|
-
{
|
|
161
|
-
files: ["test/**/*.js"],
|
|
162
|
-
plugins: {
|
|
163
|
-
"chai-friendly": eslintPluginChaiFriendly,
|
|
164
|
-
"chai-expect": eslintPluginChaiExpect
|
|
165
|
-
},
|
|
166
|
-
languageOptions: {
|
|
167
|
-
ecmaVersion: "latest",
|
|
168
|
-
sourceType: "module",
|
|
169
|
-
globals: {
|
|
170
|
-
...globals.es2021,
|
|
171
|
-
...globals.node,
|
|
172
|
-
...globals.mocha
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
rules: {
|
|
176
|
-
...styleRules,
|
|
177
|
-
"no-unused-expressions": "off",
|
|
178
|
-
"chai-friendly/no-unused-expressions": "error"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
];
|
package/run_test_all.sh
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
function cleanup(){
|
|
3
|
-
docker compose down
|
|
4
|
-
}
|
|
5
|
-
trap cleanup EXIT
|
|
6
|
-
set -e -o pipefail
|
|
7
|
-
|
|
8
|
-
./run_test_local.sh keep
|
|
9
|
-
|
|
10
|
-
docker compose run --build --rm tester
|
|
11
|
-
echo test on latest ubuntu success
|
|
12
|
-
|
|
13
|
-
docker compose run --build --rm tester-bullseye
|
|
14
|
-
echo test on bullseye success
|
|
15
|
-
|
|
16
|
-
docker compose run --build --rm tester-buster
|
|
17
|
-
echo test on buster success
|
|
18
|
-
docker compose down
|
package/run_test_local.sh
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
docker compose up testbed -d
|
|
3
|
-
export TEST_HOST=localhost
|
|
4
|
-
export TEST_USER=testuser
|
|
5
|
-
export TEST_PW=passw0rd
|
|
6
|
-
export TEST_PORT=4100
|
|
7
|
-
ssh-keygen -R '[localhost]:4100'
|
|
8
|
-
|
|
9
|
-
npm run test
|
|
10
|
-
echo local test success
|
|
11
|
-
if [ x${1} != xkeep ];then
|
|
12
|
-
docker compose down
|
|
13
|
-
fi
|
package/test/getSshOption.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
process.on("unhandledRejection", console.dir);
|
|
2
|
-
|
|
3
|
-
//setup test framework
|
|
4
|
-
import * as chai from "chai";
|
|
5
|
-
import { expect } from "chai";
|
|
6
|
-
import chaiAsPromised from "chai-as-promised";
|
|
7
|
-
chai.use(chaiAsPromised);
|
|
8
|
-
|
|
9
|
-
//testee
|
|
10
|
-
import { getSshOption } from "../lib/util.js";
|
|
11
|
-
|
|
12
|
-
describe("test for getSshOption", ()=>{
|
|
13
|
-
const defaultValues = {
|
|
14
|
-
host: "testHostName",
|
|
15
|
-
ControlPersist: 180,
|
|
16
|
-
maxRetry: 3,
|
|
17
|
-
retryDuration: 1000
|
|
18
|
-
};
|
|
19
|
-
it("should return minimum ssh option array", ()=>{
|
|
20
|
-
const sshOpts = getSshOption(defaultValues);
|
|
21
|
-
expect(sshOpts).to.be.an("array");
|
|
22
|
-
expect(sshOpts).to.have.lengthOf(4);
|
|
23
|
-
expect(sshOpts[0]).to.equal(defaultValues.host);
|
|
24
|
-
expect(sshOpts[1]).to.equal("-oControlMaster=auto");
|
|
25
|
-
expect(sshOpts[2]).to.equal("-oControlPath=~/.ssh/ssh-client-wrapper-%r@%h:%p");
|
|
26
|
-
expect(sshOpts[3]).to.equal("-oControlPersist=180");
|
|
27
|
-
});
|
|
28
|
-
it("should change ControlPath by ControlPersistDir", ()=>{
|
|
29
|
-
const hostInfo = { ...defaultValues };
|
|
30
|
-
hostInfo.ControlPersistDir = "/tmp";
|
|
31
|
-
const sshOpts = getSshOption(hostInfo);
|
|
32
|
-
expect(sshOpts).to.be.an("array");
|
|
33
|
-
expect(sshOpts).to.have.lengthOf(4);
|
|
34
|
-
expect(sshOpts[0]).to.equal(defaultValues.host);
|
|
35
|
-
expect(sshOpts[1]).to.equal("-oControlMaster=auto");
|
|
36
|
-
expect(sshOpts[2]).to.equal("-oControlPath=/tmp/ssh-client-wrapper-%r@%h:%p");
|
|
37
|
-
expect(sshOpts[3]).to.equal("-oControlPersist=180");
|
|
38
|
-
});
|
|
39
|
-
it("should change ControlPath by Environment variable", ()=>{
|
|
40
|
-
process.env.SSH_CONTROL_PERSIST_DIR = "/tmp";
|
|
41
|
-
const sshOpts = getSshOption(defaultValues);
|
|
42
|
-
expect(sshOpts).to.be.an("array");
|
|
43
|
-
expect(sshOpts).to.have.lengthOf(4);
|
|
44
|
-
expect(sshOpts[0]).to.equal(defaultValues.host);
|
|
45
|
-
expect(sshOpts[1]).to.equal("-oControlMaster=auto");
|
|
46
|
-
expect(sshOpts[2]).to.equal("-oControlPath=/tmp/ssh-client-wrapper-%r@%h:%p");
|
|
47
|
-
expect(sshOpts[3]).to.equal("-oControlPersist=180");
|
|
48
|
-
});
|
|
49
|
-
});
|