The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import * as PlatformError from "effect/PlatformError"; |
| 3 | |
| 4 | import { SecretStorePersistError } from "./ServerSecretStore.ts"; |
| 5 | import { mapDpopReplayStoreError } from "./dpop.ts"; |
| 6 | |
| 7 | const storeFailure = (tag: "AlreadyExists" | "PermissionDenied") => |
| 8 | new SecretStorePersistError({ |
| 9 | resource: "DPoP proof", |
| 10 | cause: PlatformError.systemError({ |
| 11 | _tag: tag, |
| 12 | module: "FileSystem", |
| 13 | method: "open", |
| 14 | pathOrDescriptor: "dpop-proof.bin", |
| 15 | }), |
| 16 | }); |
| 17 | |
| 18 | describe("mapDpopReplayStoreError", () => { |
| 19 | it("reports replay conflicts as invalid credentials", () => { |
| 20 | const cause = storeFailure("AlreadyExists"); |
| 21 | const error = mapDpopReplayStoreError(cause); |
| 22 | |
| 23 | expect(error._tag).toBe("ServerAuthInvalidCredentialError"); |
| 24 | if (error._tag === "ServerAuthInvalidCredentialError") { |
| 25 | expect(error.cause).toBe(cause); |
| 26 | expect(error.dpopFailureReason).toBe("replay"); |
| 27 | } |
| 28 | }); |
| 29 | }); |