fix(aws): refuse Docker/VPN on Fargate without grandfathering; launchTypePatch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-11-16 12:56:18 -08:00
1 parent 86f253b7da
commit c6b46a7347
4 files changed
+60 -16

No files matched your search

@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import RuntimeSection from "./RuntimeSection";
import type { AuthBridgeStatus, Project } from "../../../../lib/types";
import { launchTypePatch } from "../../../../lib/awsWorkspace";
import { awsProject } from "../../../../test/awsFixtures";
// The auth-bridge row owns its own IPC — see `AuthBridgeRow.tsx` for why it
@@ -196,4 +197,23 @@ describe("RuntimeSection — Docker and VPN on AWS follow the launch type", () =
expect(screen.getByRole("switch", { name: VPN })).toBeEnabled();
expect(screen.getByRole("switch", { name: "Allow container spawning" })).toBeEnabled();
});
it("saves the flags when toggled on EC2", () => {
const p = awsProject({ vpn_support_enabled: false, allow_docker_access: false });
renderSection({ ...p, aws: { ...p.aws!, launch_type: "ec2" } });
fireEvent.click(screen.getByRole("switch", { name: VPN }));
expect(save).toHaveBeenCalledWith({ vpn_support_enabled: true });
fireEvent.click(screen.getByRole("switch", { name: "Allow container spawning" }));
expect(save).toHaveBeenCalledWith({ allow_docker_access: true });
});
it("launchTypePatch clears Docker and VPN when switching to Fargate", () => {
const p = awsProject({ allow_docker_access: true, vpn_support_enabled: true });
const toFargate = launchTypePatch(p, "fargate");
expect(toFargate).toMatchObject({ allow_docker_access: false, vpn_support_enabled: false });
expect(toFargate.aws?.launch_type).toBe("fargate");
const toEc2 = launchTypePatch(p, "ec2");
expect(toEc2.allow_docker_access).toBeUndefined();
expect(toEc2.aws?.launch_type).toBe("ec2");
});
});
+13
View File
@@ -2,6 +2,7 @@ import type {
AwsWorkspaceConfig,
DetectedEnvironment,
GatewaySettings,
LaunchType,
Project,
RepoSource,
UnsavedWork,
@@ -238,3 +239,15 @@ export function localEndpointProblem(url: string, gatewayPort: number | null): s
}
return null;
}
/** The save patch for switching an AWS project's launch type. Docker access and
* VPN need EC2 (Rust refuses them on Fargate), so switching to Fargate turns
* them off in the same save. Task 6's launch-type control must use this. */
export function launchTypePatch(project: Project, launch_type: LaunchType): Partial<Project> {
const patch: Partial<Project> = { aws: { ...project.aws!, launch_type } };
if (launch_type !== "ec2") {
patch.allow_docker_access = false;
patch.vpn_support_enabled = false;
}
return patch;
}