This commit is contained in:
Reinier Criel 2025-11-10 10:46:15 -08:00
parent 76acf43128
commit e04c4b6f21
7 changed files with 92 additions and 19 deletions

View file

@ -16,11 +16,12 @@ const yarnVersion = process.env.YARN_VERSION || "latest";
const pnpmVersion = process.env.PNPM_VERSION || "latest";
export class DockerTestContainer {
constructor() {
constructor({ asRootUser = false } = {}) {
this.containerName = `safe-chain-test-${Math.random()
.toString(36)
.substring(2, 15)}`;
this.isRunning = false;
this.asRootUser = asRootUser;
}
static buildImage() {
@ -50,8 +51,9 @@ export class DockerTestContainer {
try {
// Start a long-running container that we can exec commands into
const userFlag = this.asRootUser ? "--user root" : "";
execSync(
`docker run -d --name ${this.containerName} ${imageName} sleep infinity`,
`docker run -d --name ${this.containerName} ${userFlag} ${imageName} sleep infinity`,
{ stdio: "ignore" }
);
this.isRunning = true;

View file

@ -30,8 +30,8 @@ ARG PYTHON_VERSION=3
SHELL ["/bin/bash", "-c"]
ENV BASH_ENV=~/.bashrc
# Install a proxy
RUN apt-get update && apt-get install tinyproxy -y
# Install a proxy and sudo
RUN apt-get update && apt-get install -y tinyproxy sudo
# Install zsh
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)"

View file

@ -10,7 +10,7 @@ describe("E2E: safe-chain setup-ci command for pip/pip3", () => {
});
beforeEach(async () => {
container = new DockerTestContainer();
container = new DockerTestContainer({ asRootUser: true });
await container.start();
});

View file

@ -10,8 +10,8 @@ describe("E2E: pip coverage", () => {
});
beforeEach(async () => {
// Run a new Docker container for each test
container = new DockerTestContainer();
// Run a new Docker container for each test as root user
container = new DockerTestContainer({ asRootUser: true });
await container.start();
const installationShell = await container.openShell("zsh");
@ -316,10 +316,9 @@ describe("E2E: pip coverage", () => {
);
// Should NOT contain certificate verification errors
const sslErrorPattern = /certificate verify failed|CERTIFICATE_VERIFY_FAILED|SSLError/i;
assert.ok(
!result.output.match(
/SSL|certificate verify failed|CERTIFICATE_VERIFY_FAILED/i
),
!sslErrorPattern.test(result.output),
`Should not have SSL/certificate errors for tunneled hosts. Output was:\n${result.output}`
);
});