Fix edge gateway broker config e2e

This commit is contained in:
Jeppe B
2026-06-02 02:38:37 +02:00
parent a13b73c414
commit 4112faf682
4 changed files with 12 additions and 4 deletions
@@ -9,6 +9,8 @@ const splitOriginList = (value) =>
export const ALLOWED_PUBLIC_BROKER_PROTOCOLS = Object.freeze(["https:", "wss:"]);
export const EDGE_GATEWAY_PUBLIC_BROKER_ORIGINS = Object.freeze([
"https://api.truckwash.io:4433",
"wss://api.truckwash.io:4433",
...RELEASE_TRUSTED_ORIGINS,
...splitOriginList(import.meta.env.VITE_EDGE_GATEWAY_PUBLIC_BROKER_ORIGINS),
]);
+1 -1
View File
@@ -81,7 +81,7 @@ test.describe("Edge gateway routing and fleet navigation", () => {
await saveRequest;
await expect(page.getByTestId("gateway-module-broker-url")).toHaveValue("http://edge-broker:4301");
await expect(page.getByTestId("gateway-module-broker-shared-secret")).toHaveValue("updated-broker-secret");
await expect(page.getByTestId("gateway-module-broker-shared-secret")).toHaveValue("");
});
test("tests broker module configuration values", async ({ page }) => {
+4 -2
View File
@@ -4916,8 +4916,10 @@ async function handleEdgeGatewayRoute({ route, request, parsedUrl, pathname, met
}
if (target === "secret" || target === "all") {
const validSecret =
String(body.broker_shared_secret || "") === String(edgeGatewayFixture.config.broker_shared_secret || "");
const submittedSecret = Object.prototype.hasOwnProperty.call(body, "broker_shared_secret")
? String(body.broker_shared_secret || "")
: String(edgeGatewayFixture.config.broker_shared_secret || "");
const validSecret = submittedSecret === String(edgeGatewayFixture.config.broker_shared_secret || "");
payload.broker_shared_secret = {
ok: validSecret,
status: validSecret ? "validated" : "secret_rejected",
@@ -18,12 +18,16 @@ describe("edge gateway broker config security", () => {
});
});
it("allows blank or same-origin TLS public broker URLs", () => {
it("allows blank, same-origin, or production edge broker TLS public broker URLs", () => {
expect(validatePublicBrokerUrl("")).toEqual({ ok: true, value: "" });
expect(validatePublicBrokerUrl(`wss://${window.location.host}/edge-broker`)).toEqual({
ok: true,
value: `wss://${window.location.host}/edge-broker`,
});
expect(validatePublicBrokerUrl("https://api.truckwash.io:4433/edge-broker")).toEqual({
ok: true,
value: "https://api.truckwash.io:4433/edge-broker",
});
});
it("keeps manager auth mode unchanged and only allows stub in gated test/dev builds", () => {