mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Cleanup debugging code from test again
This commit is contained in:
parent
056a1963e3
commit
fce7550609
4 changed files with 4 additions and 24 deletions
|
|
@ -1,10 +1,8 @@
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import * as https from "https";
|
import * as https from "https";
|
||||||
// oxlint-disable no-console - just for testing, remove afterwards
|
|
||||||
|
|
||||||
export function handleHttpProxyRequest(req, res) {
|
export function handleHttpProxyRequest(req, res) {
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
console.log(`Proxying request to: ${req.url}`);
|
|
||||||
|
|
||||||
let protocol;
|
let protocol;
|
||||||
if (url.protocol === "http:") {
|
if (url.protocol === "http:") {
|
||||||
|
|
@ -25,27 +23,12 @@ export function handleHttpProxyRequest(req, res) {
|
||||||
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
||||||
proxyRes.pipe(res);
|
proxyRes.pipe(res);
|
||||||
|
|
||||||
proxyRes.on("error", (err) => {
|
|
||||||
console.log("Error in proxy response stream:", err);
|
|
||||||
// Stream error while piping response
|
|
||||||
// Response headers already sent, can't send error status
|
|
||||||
});
|
|
||||||
|
|
||||||
proxyRes.on("close", () => {
|
proxyRes.on("close", () => {
|
||||||
console.log("Proxy response stream closed");
|
|
||||||
// Clean up if the proxy response stream closes
|
// Clean up if the proxy response stream closes
|
||||||
if (!res.writableEnded) {
|
if (!res.writableEnded) {
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
proxyRes.on("end", () => {
|
|
||||||
console.log("Proxy response stream ended");
|
|
||||||
// End of proxy response
|
|
||||||
if (!res.writableEnded) {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.on("error", (err) => {
|
.on("error", (err) => {
|
||||||
|
|
@ -54,21 +37,18 @@ export function handleHttpProxyRequest(req, res) {
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on("error", () => {
|
req.on("error", () => {
|
||||||
console.log("Error in client request stream");
|
|
||||||
// Client request stream error
|
// Client request stream error
|
||||||
// Abort the proxy request
|
// Abort the proxy request
|
||||||
proxyRequest.destroy();
|
proxyRequest.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
res.on("error", () => {
|
res.on("error", () => {
|
||||||
console.log("Error in client response stream");
|
|
||||||
// Client response stream error (client disconnected)
|
// Client response stream error (client disconnected)
|
||||||
// Clean up proxy streams
|
// Clean up proxy streams
|
||||||
proxyRequest.destroy();
|
proxyRequest.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
res.on("close", () => {
|
res.on("close", () => {
|
||||||
console.log("Client response stream closed");
|
|
||||||
// Client disconnected
|
// Client disconnected
|
||||||
// Abort the proxy request to avoid unnecessary work
|
// Abort the proxy request to avoid unnecessary work
|
||||||
if (!res.writableEnded) {
|
if (!res.writableEnded) {
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ export class DockerTestContainer {
|
||||||
console.log("Command timeout reached");
|
console.log("Command timeout reached");
|
||||||
resolve({ allData, output: parseShellOutput(allData), command });
|
resolve({ allData, output: parseShellOutput(allData), command });
|
||||||
ptyProcess.removeListener("data", handleInput);
|
ptyProcess.removeListener("data", handleInput);
|
||||||
}, 20000);
|
}, 15000);
|
||||||
|
|
||||||
function handleInput(data) {
|
function handleInput(data) {
|
||||||
allData.push(data);
|
allData.push(data);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "End-to-end tests for the Aikido Safe Chain",
|
"description": "End-to-end tests for the Aikido Safe Chain",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node --test --test-concurrency=1 **/safe-chain-proxy.e2e.spec.js"
|
"test": "node --test --test-concurrency=1 **/*.spec.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Aikido Security",
|
"author": "Aikido Security",
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ describe("E2E: Safe chain proxy", () => {
|
||||||
container = new DockerTestContainer();
|
container = new DockerTestContainer();
|
||||||
await container.start();
|
await container.start();
|
||||||
|
|
||||||
// const installationShell = await container.openShell("zsh");
|
const installationShell = await container.openShell("zsh");
|
||||||
// await installationShell.runCommand("safe-chain setup");
|
await installationShell.runCommand("safe-chain setup");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue