mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Add e2e tests to verify existing proxy is being respected.
This commit is contained in:
parent
53bfb14fea
commit
32f5ef9b16
2 changed files with 63 additions and 0 deletions
|
|
@ -29,6 +29,9 @@ ARG PNPM_VERSION=latest
|
||||||
SHELL ["/bin/bash", "-c"]
|
SHELL ["/bin/bash", "-c"]
|
||||||
ENV BASH_ENV=~/.bashrc
|
ENV BASH_ENV=~/.bashrc
|
||||||
|
|
||||||
|
# Install a proxy
|
||||||
|
RUN apt-get update && apt-get install tinyproxy -y
|
||||||
|
|
||||||
# Install zsh
|
# Install zsh
|
||||||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)"
|
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)"
|
||||||
# Install fish
|
# Install fish
|
||||||
|
|
|
||||||
60
test/e2e/safe-chain-proxy.e2e.spec.js
Normal file
60
test/e2e/safe-chain-proxy.e2e.spec.js
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
import { describe, it, before, beforeEach, afterEach } from "node:test";
|
||||||
|
import { DockerTestContainer } from "./DockerTestContainer.js";
|
||||||
|
import assert from "node:assert";
|
||||||
|
|
||||||
|
describe("E2E: Safe chain proxy", () => {
|
||||||
|
let container;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
DockerTestContainer.buildImage();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
// Run a new Docker container for each test
|
||||||
|
container = new DockerTestContainer();
|
||||||
|
await container.start();
|
||||||
|
|
||||||
|
const installationShell = await container.openShell("zsh");
|
||||||
|
await installationShell.runCommand("safe-chain setup");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
// Stop and clean up the container after each test
|
||||||
|
if (container) {
|
||||||
|
await container.stop();
|
||||||
|
container = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`safe-chain proxy respects upstream proxy settings`, async () => {
|
||||||
|
// Configure and start a proxy inside the container
|
||||||
|
const proxy = await container.openShell("zsh");
|
||||||
|
await proxy.runCommand(
|
||||||
|
`echo 'BasicAuth user password' >> /etc/tinyproxy/tinyproxy.conf`
|
||||||
|
);
|
||||||
|
await proxy.runCommand("tinyproxy");
|
||||||
|
|
||||||
|
const shell = await container.openShell("zsh");
|
||||||
|
await shell.runCommand(
|
||||||
|
'export HTTPS_PROXY="http://user:password@localhost:8888"'
|
||||||
|
);
|
||||||
|
const { output } = await shell.runCommand("npm install axios");
|
||||||
|
|
||||||
|
// Check if the installation was successful
|
||||||
|
assert(
|
||||||
|
output.includes("added") || output.includes("up to date"),
|
||||||
|
"npm install did not complete successfully"
|
||||||
|
);
|
||||||
|
|
||||||
|
const proxyLog = await container.openShell("zsh");
|
||||||
|
const { output: logOutput } = await proxyLog.runCommand(
|
||||||
|
"cat /var/log/tinyproxy/tinyproxy.log"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if the proxy log contains entries for the npm install
|
||||||
|
assert(
|
||||||
|
logOutput.includes("CONNECT registry.npmjs.org:443"),
|
||||||
|
"Proxy log does not contain expected entries"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue