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