mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
test(environment): verify registry pins in the exported bundle (#11870)
This commit is contained in:
1 parent
6f0f9a122d
commit
e9cc643198
3 files changed
+39
-129
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import { isPortableBundleName } from "../../domain/portableBundleName.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { timedCaptureEvidence } from "../../../tests/fixtures/analysisView.js";
|
||||
@@ -110,34 +109,6 @@ describe("planEnvironmentBundle", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("pins the registry package to this build's exact version in the Dockerfile", () => {
|
||||
const dockerfile = file(plan(), "envs/grafana-example/Dockerfile");
|
||||
const lines = dockerfile.trimEnd().split("\n");
|
||||
expect(lines[0]).toMatch(/^FROM node:\d+\.\d+\.\d+-bookworm-slim$/u);
|
||||
expect(lines).toContain("ENV MCP_HOST=0.0.0.0");
|
||||
expect(lines).toContain("ENV MCP_PORT=18765");
|
||||
expect(lines).toContain(
|
||||
`ENV MCP_ALLOWED_HOSTS=127.0.0.1,localhost,grafana-example`,
|
||||
);
|
||||
expect(lines).toContain(
|
||||
"RUN apt-get update && apt-get install -y --no-install-recommends python3 && rm -rf /var/lib/apt/lists/*",
|
||||
);
|
||||
expect(lines).toContain(
|
||||
`RUN npm install -g --ignore-scripts --no-fund --no-audit rea-agents@${PACKAGE_METADATA.version}`,
|
||||
);
|
||||
expect(lines).toContain(
|
||||
"COPY --chown=node:node manifest.json evidence.json /env/",
|
||||
);
|
||||
expect(lines).toContain("USER node");
|
||||
expect(lines.at(-1)).toBe(
|
||||
'CMD ["rea","environment-serve","/env/manifest.json","--evidence","/env/evidence.json"]',
|
||||
);
|
||||
expect(dockerfile).not.toContain("rea-agents.tgz");
|
||||
expect(dockerfile.indexOf("RUN npm install")).toBeLessThan(
|
||||
dockerfile.indexOf("USER node"),
|
||||
);
|
||||
});
|
||||
|
||||
it("copies and installs the tarball instead of the registry package when one is given", () => {
|
||||
const planned = plan({ tarball: "/packed/rea-agents-1.2.3.tgz" });
|
||||
expect(planned.copies.tarball).toBe("envs/grafana-example/rea-agents.tgz");
|
||||
@@ -147,9 +118,6 @@ describe("planEnvironmentBundle", () => {
|
||||
"RUN npm install -g --ignore-scripts --no-fund --no-audit /tmp/rea-agents.tgz && rm /tmp/rea-agents.tgz\n",
|
||||
);
|
||||
expect(dockerfile).not.toContain(`rea-agents@${PACKAGE_METADATA.version}`);
|
||||
expect(file(plan(), "envs/grafana-example/Dockerfile")).not.toBe(
|
||||
dockerfile,
|
||||
);
|
||||
});
|
||||
|
||||
it("writes a verifier that checks the served tool count and the status the server answers the first parameterless GET tool with", () => {
|
||||
@@ -221,7 +189,6 @@ describe("planEnvironmentBundle", () => {
|
||||
expect(readme).toContain("```sh\nagent-env run .\n```");
|
||||
expect(readme).not.toContain("agent-env run grafana-example");
|
||||
expect(readme).toContain("## What the environment serves");
|
||||
expect(readme).not.toContain("What replay means");
|
||||
expect(readme).toContain(
|
||||
"write tools are served only where the capture's later reads confirmed\ntheir effect",
|
||||
);
|
||||
@@ -239,34 +206,24 @@ describe("planEnvironmentBundle", () => {
|
||||
});
|
||||
|
||||
describe("planEnvironmentBundle portable names", () => {
|
||||
it.each(["4294967296", "123", "0xffffffff"])(
|
||||
"refuses bundle name %s when HTTP cannot preserve its host identity",
|
||||
(name) => {
|
||||
expect(nameRefusal(name)).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
operation: "environment-export",
|
||||
issues: [{ path: ["name"], reason: "invalid_value" }],
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
it("refuses a hexadecimal IP spelling before preparing state", () => {
|
||||
expect(nameRefusal("0xffffffff")).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
operation: "environment-export",
|
||||
issues: [{ path: ["name"], reason: "invalid_value" }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps addressable numeric prefixes and admits the DNS label boundary", () => {
|
||||
for (const name of ["123-replay", "0xffffffff-replay", "a".repeat(63)]) {
|
||||
expect(isPortableBundleName(name)).toBe(true);
|
||||
const planned = plan({ name });
|
||||
expect(planned.name).toBe(name);
|
||||
expect(file(planned, `envs/${name}/Dockerfile`)).toContain(
|
||||
`ENV MCP_ALLOWED_HOSTS=127.0.0.1,localhost,${name}`,
|
||||
);
|
||||
}
|
||||
expect(isPortableBundleName("a".repeat(64))).toBe(false);
|
||||
expect(nameRefusal("a".repeat(64))).toMatchObject({
|
||||
code: "invalid_request",
|
||||
});
|
||||
for (const name of ["123", "4294967296", "0xffffffff"])
|
||||
expect(isPortableBundleName(name)).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts a kebab-case name override and refuses any other name as invalid input", () => {
|
||||
|
||||
Reference in new issue
Block a user