fix: use authoritative runtime removal result
This commit is contained in:
@@ -177,12 +177,13 @@ Deno.test("Runtime detail keeps trust controls owner-only and conflict-safe", as
|
||||
"Revoke Workspace trust",
|
||||
"Workspace trust only; this does not delete the Runtime process, Workers, or Workdirs.",
|
||||
"await revokeRuntimeTrustKey(",
|
||||
"deleteRemoteRuntime(data.workspaceId, operation.runtimeId)",
|
||||
"Revoke trust and delete registration",
|
||||
"trust.status !== 'revoked'",
|
||||
"await removeRemoteRuntime(",
|
||||
"operation_id: crypto.randomUUID()",
|
||||
"expected_binding_revision: trust.revision",
|
||||
"The Backend removes Workspace trust and this Runtime registration as one guarded operation.",
|
||||
"deleteRuntimeConfirmation.trim() !== data.runtimeId",
|
||||
"Delete Runtime registration",
|
||||
"Delete registration",
|
||||
"Remove Runtime registration",
|
||||
"This does not stop the Runtime process",
|
||||
"RuntimeTrustConflictError",
|
||||
"RuntimeTrustRouteFence",
|
||||
@@ -211,6 +212,9 @@ Deno.test("Runtime detail keeps trust controls owner-only and conflict-safe", as
|
||||
"fingerprintConfirmation",
|
||||
"revokeFingerprintConfirmation",
|
||||
"Confirm current fingerprint",
|
||||
"deleteRemoteRuntime",
|
||||
"if (data.runtimeDetail.trust_key.status !== 'revoked')",
|
||||
"Revoke trust and delete registration",
|
||||
]
|
||||
) {
|
||||
assert(!page.includes(token), `Runtime detail must not require ${token}`);
|
||||
|
||||
@@ -4,12 +4,13 @@ declare const Deno: {
|
||||
|
||||
import {
|
||||
createRemoteRuntime,
|
||||
deleteRemoteRuntime,
|
||||
parseRuntimeRemovalOperationResponse,
|
||||
parseRuntimeTrustConflict,
|
||||
parseRuntimeTrustKeyRevealResponse,
|
||||
parseWorkspaceRuntimeDetail,
|
||||
parseWorkspaceRuntimeList,
|
||||
previewRuntimePublicKeyFingerprint,
|
||||
removeRemoteRuntime,
|
||||
revokeRuntimeTrustKey,
|
||||
RuntimeTrustConflictError,
|
||||
RuntimeTrustRouteFence,
|
||||
@@ -313,22 +314,56 @@ Deno.test("Runtime metadata update never sends public key authority", async () =
|
||||
assert(!("public_key" in body), "metadata update sent public_key");
|
||||
});
|
||||
|
||||
Deno.test("Runtime registration delete uses the Workspace-scoped resource route", async () => {
|
||||
Deno.test("Runtime removal uses the Workspace-scoped operation route", async () => {
|
||||
let requestedUrl = "";
|
||||
let requestedMethod = "";
|
||||
let requestedBody: unknown = null;
|
||||
const fetchImpl = ((input: string | URL | Request, init?: RequestInit) => {
|
||||
requestedUrl = String(input);
|
||||
requestedMethod = init?.method ?? "GET";
|
||||
return Promise.resolve(new Response(null, { status: 204 }));
|
||||
requestedBody = JSON.parse(String(init?.body));
|
||||
return Promise.resolve(Response.json({
|
||||
operation_id: "remove-runtime-a",
|
||||
workspace_id: "workspace a",
|
||||
runtime_id: "runtime/a",
|
||||
state: "succeeded",
|
||||
binding_removed: true,
|
||||
runtime_registration_removed: true,
|
||||
created_at: "2026-01-01T00:00:00Z",
|
||||
updated_at: "2026-01-01T00:00:01Z",
|
||||
completed_at: "2026-01-01T00:00:01Z",
|
||||
}));
|
||||
}) as typeof fetch;
|
||||
|
||||
await deleteRemoteRuntime("workspace a", "runtime/a", fetchImpl);
|
||||
const operation = await removeRemoteRuntime(
|
||||
"workspace a",
|
||||
"runtime/a",
|
||||
{ operation_id: "remove-runtime-a", expected_binding_revision: 7 },
|
||||
fetchImpl,
|
||||
);
|
||||
|
||||
assert(
|
||||
requestedUrl === "/api/w/workspace%20a/runtimes/runtime%2Fa",
|
||||
`unexpected delete URL: ${requestedUrl}`,
|
||||
`unexpected removal URL: ${requestedUrl}`,
|
||||
);
|
||||
assert(requestedMethod === "DELETE", "Runtime removal must use DELETE");
|
||||
assert(
|
||||
JSON.stringify(requestedBody) === JSON.stringify({
|
||||
operation_id: "remove-runtime-a",
|
||||
expected_binding_revision: 7,
|
||||
}),
|
||||
"Runtime removal request body drifted",
|
||||
);
|
||||
assert(operation.state === "succeeded", "Runtime removal did not complete");
|
||||
|
||||
assertThrows(
|
||||
() =>
|
||||
parseRuntimeRemovalOperationResponse({
|
||||
...operation,
|
||||
unknown: "rejected",
|
||||
}),
|
||||
"not part of the wire contract",
|
||||
);
|
||||
assert(requestedMethod === "DELETE", "Runtime delete must use DELETE");
|
||||
});
|
||||
|
||||
Deno.test("Runtime route fence rejects a delayed reveal from the prior Runtime", async () => {
|
||||
|
||||
Reference in New Issue
Block a user