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 "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Tracer from "effect/Tracer"; |
| 4 | import * as HttpClient from "effect/http/HttpClient"; |
| 5 | import * as HttpClientResponse from "effect/http/HttpClientResponse"; |
| 6 | |
| 7 | import * as HttpObservability from "./httpObservability.ts"; |
| 8 | |
| 9 | describe("HttpObservability.layer", () => { |
| 10 | it.effect("redacts credential query parameters on HTTP client spans", () => { |
| 11 | const spans: Array<Tracer.NativeSpan> = []; |
| 12 | const tracer = Tracer.make({ |
| 13 | span: (options) => { |
| 14 | const span = new Tracer.NativeSpan(options); |
| 15 | spans.push(span); |
| 16 | return span; |
| 17 | }, |
| 18 | }); |
| 19 | const client = HttpClient.make((request) => |
| 20 | Effect.succeed(HttpClientResponse.fromWeb(request, new Response("ok"))), |
| 21 | ); |
| 22 | return Effect.gen(function* () { |
| 23 | yield* client.get("https://example.com/ws?wsTicket=secret&clientOs=linux&dpop=proof"); |
| 24 | const span = spans.find((candidate) => candidate.kind === "client")!; |
| 25 | expect(span.attributes.get("url.full")).toBe( |
| 26 | "https://example.com/ws?wsTicket=REDACTED&clientOs=linux&dpop=REDACTED", |
| 27 | ); |
| 28 | expect(span.attributes.get("url.query")).toBe( |
| 29 | "wsTicket=REDACTED&clientOs=linux&dpop=REDACTED", |
| 30 | ); |
| 31 | }).pipe(Effect.provide(HttpObservability.layer), Effect.withTracer(tracer)); |
| 32 | }); |
| 33 | }); |