@@ -28023,13 +28023,59 @@ describe("fleet identity", () => {
2802328023 missing: ["DAYTONA_CRABBOX_KEY"],
2802428024 });
2802528025
28026- const daytonaFleet = testFleet(undefined, {}, { DAYTONA_CRABBOX_KEY: "live-key" });
28026+ const daytonaRequests: Request[] = [];
28027+ vi.stubGlobal(
28028+ "fetch",
28029+ vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
28030+ const daytonaRequest = input instanceof Request ? input : new Request(input, init);
28031+ daytonaRequests.push(daytonaRequest.clone());
28032+ return Response.json({
28033+ items: [
28034+ {
28035+ id: "sandbox-one",
28036+ name: "crabbox-one",
28037+ state: "started",
28038+ labels: { crabbox: "true" },
28039+ },
28040+ ],
28041+ nextCursor: null,
28042+ });
28043+ }),
28044+ );
28045+ const daytonaFleet = testFleet(
28046+ undefined,
28047+ {},
28048+ {
28049+ DAYTONA_CRABBOX_KEY: "live-key",
28050+ CRABBOX_DAYTONA_API_URL: "https://daytona.example/api",
28051+ CRABBOX_DAYTONA_SNAPSHOT: "crabbox-ready",
28052+ },
28053+ );
2802728054 const daytona = await daytonaFleet.fetch(request("GET", "/v1/providers/daytona/readiness"));
2802828055 await expect(daytona.json()).resolves.toMatchObject({
2802928056 provider: "daytona",
2803028057 configured: true,
2803128058 missing: [],
28059+ checks: [
28060+ {
28061+ status: "ok",
28062+ check: "daytona-fallback",
28063+ details: {
28064+ api: "list",
28065+ mutation: "false",
28066+ client_auth: "crabbox",
28067+ control_plane: "coordinator",
28068+ data_plane: "ssh-rsync",
28069+ snapshot: "configured",
28070+ leases: "1",
28071+ },
28072+ },
28073+ ],
2803228074 });
28075+ expect(daytonaRequests).toHaveLength(1);
28076+ expect(daytonaRequests[0]?.method).toBe("GET");
28077+ expect(daytonaRequests[0]?.headers.get("authorization")).toBe("Bearer live-key");
28078+ expect(new URL(daytonaRequests[0]!.url).pathname).toBe("/api/sandbox");
2803328079 });
2803428080
2803528081 it("reports AWS capacity quota readiness before a lease is requested", async () => {
@@ -28082,6 +28128,54 @@ describe("fleet identity", () => {
2808228128 );
2808328129 });
2808428130
28131+ it("reports a configured but unusable Daytona fallback without leaking its key", async () => {
28132+ vi.stubGlobal(
28133+ "fetch",
28134+ vi.fn(
28135+ async () =>
28136+ new Response(
28137+ JSON.stringify({
28138+ error: "unauthorized",
28139+ workerKey: "daytona-live-secret",
28140+ }),
28141+ { status: 401 },
28142+ ),
28143+ ),
28144+ );
28145+ const fleet = testFleet(
28146+ undefined,
28147+ {},
28148+ {
28149+ DAYTONA_CRABBOX_KEY: "daytona-live-secret",
28150+ CRABBOX_DAYTONA_API_URL: "https://daytona.example/api",
28151+ },
28152+ );
28153+
28154+ const response = await fleet.fetch(request("GET", "/v1/providers/daytona/readiness"));
28155+ expect(response.status).toBe(200);
28156+ const body = await response.text();
28157+ expect(body).not.toContain("daytona-live-secret");
28158+ expect(JSON.parse(body)).toMatchObject({
28159+ provider: "daytona",
28160+ configured: true,
28161+ missing: [],
28162+ checks: [
28163+ {
28164+ status: "failed",
28165+ check: "daytona-fallback",
28166+ details: {
28167+ api: "list",
28168+ mutation: "false",
28169+ client_auth: "crabbox",
28170+ control_plane: "coordinator",
28171+ data_plane: "ssh-rsync",
28172+ snapshot: "account-default",
28173+ },
28174+ },
28175+ ],
28176+ });
28177+ });
28178+
2808528179 it("rejects path-bearing AWS regions before signed requests", async () => {
2808628180 const fetchMock = vi.fn<typeof fetch>();
2808728181 vi.stubGlobal("fetch", fetchMock);
0 commit comments