Unified · Split
| @@ -23,47 +23,43 @@ const loggerLayer = (messages: Array<unknown>) => · 22 unmodified lines | |||
| 23 | ); | 23 | ); |
| 24 | 24 | ||
| 25 | describe("auth http diagnostics", () => { | 25 | describe("auth http diagnostics", () => { |
| 26 | it.effect( | 26 | it.effect("logs and encodes bounded internal diagnostics without exposing secrets", () => { |
| 27 | "retains the exact internal cause while logging and encoding bounded diagnostics", | 27 | const messages: Array<unknown> = []; |
| 28 | () => { | 28 | const cause = new Error("credential=secret-value"); |
| 29 | const messages: Array<unknown> = []; | ||
| 30 | const cause = new Error("credential=secret-value"); | ||
| 31 | 29 | ||
| 32 | return Effect.gen(function* () { | 30 | return Effect.gen(function* () { |
| 33 | const error = yield* Effect.flip( | 31 | const error = yield* Effect.flip( |
| 34 | AuthHttp.failEnvironmentInternal("browser_session_cookie_failed", cause), | 32 | AuthHttp.failEnvironmentInternal("browser_session_cookie_failed", cause), |
| 35 | ); | 33 | ); |
| 36 | 34 | ||
| 37 | expect(error).toBeInstanceOf(AuthHttp.EnvironmentHttpInternalError); | 35 | expect(error).toBeInstanceOf(AuthHttp.EnvironmentHttpInternalError); |
| 38 | expect(error.cause).toBe(cause); | 36 | expect(error.failureTag).toBe("Error"); |
| 39 | expect(error.failureTag).toBe("Error"); | 37 | expect(error.message).toBe( |
| 40 | expect(error.message).toBe( | 38 | "Environment API operation failed (browser_session_cookie_failed).", |
| 41 | "Environment API operation failed (browser_session_cookie_failed).", | 39 | ); |
| 42 | ); | 40 | expect(encodeEnvironmentInternalError(error)).toEqual({ |
| 43 | expect(encodeEnvironmentInternalError(error)).toEqual({ | 41 | _tag: "EnvironmentInternalError", |
| 44 | _tag: "EnvironmentInternalError", | 42 | code: "internal_error", |
| 45 | code: "internal_error", | 43 | reason: "browser_session_cookie_failed", |
| 46 | reason: "browser_session_cookie_failed", | 44 | traceId: error.traceId, |
| 47 | traceId: error.traceId, | 45 | }); |
| 48 | }); | ||
| 49 | 46 | ||
| 50 | expect(messages).toEqual([ | 47 | expect(messages).toEqual([ |
| 51 | [ | 48 | [ |
| 52 | "environment api operation failed", | 49 | "environment api operation failed", |
| 53 | { | 50 | { |
| 54 | reason: "browser_session_cookie_failed", | 51 | reason: "browser_session_cookie_failed", |
| 55 | traceId: error.traceId, | 52 | traceId: error.traceId, |
| 56 | failureTag: "Error", | 53 | failureTag: "Error", |
| 57 | reasonCount: 1, | 54 | reasonCount: 1, |
| 58 | failureCount: 1, | 55 | failureCount: 1, |
| 59 | defectCount: 0, | 56 | defectCount: 0, |
| 60 | interruptionCount: 0, | 57 | interruptionCount: 0, |
| 61 | }, | 58 | }, |
| 62 | ], | 59 | ], |
| 63 | ]); | 60 | ]); |
| 64 | }).pipe(Effect.provide(loggerLayer(messages))); | 61 | }).pipe(Effect.provide(loggerLayer(messages))); |
| 65 | }, | 62 | }); |
| 66 | ); | ||
| 67 | 63 | ||
| 68 | it.effect("logs request failures without serializing their Error or Cause values", () => { | 64 | it.effect("logs request failures without serializing their Error or Cause values", () => { |
| 69 | const messages: Array<unknown> = []; | 65 | const messages: Array<unknown> = []; |