@@ -5,14 +5,13 @@ import axios from "axios";
55jest . mock ( "axios" ) ;
66const mockedAxios = axios as jest . Mocked < typeof axios > ;
77
8+ import { BaseIterableClient } from "../../src/client/base.js" ;
89// Import the real logger to spy on it
910import { logger } from "../../src/logger.js" ;
10- import { BaseIterableClient } from "../../src/client/base.js" ;
1111
1212describe ( "Debug Logging Sanitization" , ( ) => {
1313 let mockClientInstance : any ;
1414 let requestInterceptor : any ;
15- let responseInterceptorSuccess : any ;
1615 let responseInterceptorError : any ;
1716
1817 let debugSpy : any ;
@@ -27,7 +26,6 @@ describe("Debug Logging Sanitization", () => {
2726 errorSpy = jest . spyOn ( logger , "error" ) . mockImplementation ( ( ) => logger ) ;
2827
2928 requestInterceptor = undefined ;
30- responseInterceptorSuccess = undefined ;
3129 responseInterceptorError = undefined ;
3230
3331 mockClientInstance = {
@@ -40,7 +38,6 @@ describe("Debug Logging Sanitization", () => {
4038 } ,
4139 response : {
4240 use : jest . fn ( ( success , error ) => {
43- responseInterceptorSuccess = success ;
4441 responseInterceptorError = error ;
4542 return 0 ;
4643 } ) ,
@@ -102,59 +99,6 @@ describe("Debug Logging Sanitization", () => {
10299 ) ;
103100 } ) ;
104101
105- it ( "should redact sensitive query parameters in debug logs" , ( ) => {
106- new BaseIterableClient ( {
107- apiKey : "test-api-key" ,
108- debug : true ,
109- baseUrl : "https://api.iterable.com" ,
110- } ) ;
111-
112- if ( ! requestInterceptor ) throw new Error ( "Request interceptor missing" ) ;
113-
114- const requestConfig = {
115- method : "get" ,
116- url : "https://api.iterable.com/test?apiKey=secret-key&token=secret-token&safe=value" ,
117- } ;
118-
119- requestInterceptor ( requestConfig ) ;
120-
121- const logCall = debugSpy . mock . calls . find (
122- ( call : any ) => call [ 0 ] === "API request"
123- ) ;
124-
125- const logData = logCall ?. [ 1 ] as any ;
126- const decodedUrl = decodeURIComponent ( logData . url ) ;
127- expect ( decodedUrl ) . toContain ( "apiKey=[REDACTED]" ) ;
128- expect ( decodedUrl ) . toContain ( "token=[REDACTED]" ) ;
129- expect ( decodedUrl ) . toContain ( "safe=value" ) ;
130- } ) ;
131-
132- it ( "should handle relative URLs in debug logs" , ( ) => {
133- new BaseIterableClient ( {
134- apiKey : "test-api-key" ,
135- debug : true ,
136- baseUrl : "https://api.iterable.com" ,
137- } ) ;
138-
139- if ( ! requestInterceptor ) throw new Error ( "Request interceptor missing" ) ;
140-
141- const requestConfig = {
142- method : "get" ,
143- url : "/test?apiKey=secret-key&token=secret-token" ,
144- } ;
145-
146- requestInterceptor ( requestConfig ) ;
147-
148- const logCall = debugSpy . mock . calls . find (
149- ( call : any ) => call [ 0 ] === "API request"
150- ) ;
151-
152- const logData = logCall ?. [ 1 ] as any ;
153- const decodedUrl = decodeURIComponent ( logData . url ) ;
154- expect ( decodedUrl ) . toContain ( "/test?apiKey=[REDACTED]&token=[REDACTED]" ) ;
155- expect ( logData . url ) . not . toContain ( "https://" ) ;
156- } ) ;
157-
158102 it ( "should NOT log error response data by default (debugVerbose=false)" , async ( ) => {
159103 new BaseIterableClient ( {
160104 apiKey : "test-api-key" ,
@@ -175,7 +119,7 @@ describe("Debug Logging Sanitization", () => {
175119
176120 try {
177121 await responseInterceptorError ( errorResponse ) ;
178- } catch ( e ) {
122+ } catch {
179123 // Expected
180124 }
181125
@@ -214,7 +158,7 @@ describe("Debug Logging Sanitization", () => {
214158
215159 try {
216160 await responseInterceptorError ( errorResponse ) ;
217- } catch ( e ) {
161+ } catch {
218162 // Expected
219163 }
220164
0 commit comments