Skip to content

Commit be70439

Browse files
NathanFlurryclaude
andcommitted
feat: US-006 - Create ssh2-connect fixture
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 697ebf7 commit be70439

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"entry": "src/index.js",
3+
"expectation": "fail",
4+
"services": ["ssh"],
5+
"fail": {
6+
"code": 1,
7+
"stderrIncludes": "net.Socket is not supported in sandbox"
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "e2e-docker-ssh2-connect",
3+
"private": true,
4+
"type": "commonjs",
5+
"dependencies": {
6+
"ssh2": "1.17.0"
7+
}
8+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const { Client } = require("ssh2");
2+
3+
async function main() {
4+
const result = await new Promise((resolve, reject) => {
5+
const conn = new Client();
6+
7+
conn.on("ready", () => {
8+
conn.exec("echo hello-from-sandbox && whoami", (err, stream) => {
9+
if (err) return reject(err);
10+
11+
let stdout = "";
12+
let stderr = "";
13+
14+
stream.on("data", (data) => {
15+
stdout += data.toString();
16+
});
17+
stream.stderr.on("data", (data) => {
18+
stderr += data.toString();
19+
});
20+
stream.on("close", (code) => {
21+
conn.end();
22+
resolve({
23+
connected: true,
24+
code,
25+
stdout: stdout.trim(),
26+
stderr: stderr.trim(),
27+
});
28+
});
29+
});
30+
});
31+
32+
conn.on("error", reject);
33+
34+
conn.connect({
35+
host: process.env.SSH_HOST,
36+
port: Number(process.env.SSH_PORT),
37+
username: "testuser",
38+
password: "testpass",
39+
});
40+
});
41+
42+
console.log(JSON.stringify(result));
43+
}
44+
45+
main().catch((err) => {
46+
console.error(err.message);
47+
process.exit(1);
48+
});

0 commit comments

Comments
 (0)