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