@@ -142,3 +142,34 @@ func TestSetCustomHeader(t *testing.T) {
142142 SetCustomHeader (req , "X-Custom-Header" , "CustomValue" )
143143 assert .Equal (t , "CustomValue" , req .Header .Get ("X-Custom-Header" ))
144144}
145+
146+ // TestRedactSensitiveData tests the RedactSensitiveData function with various scenarios
147+ func TestRedactSensitiveData (t * testing.T ) {
148+ tests := []struct {
149+ name string
150+ hideSensitive bool
151+ key string
152+ value string
153+ expectedOutcome string
154+ }{
155+ {"RedactSensitiveKey" , true , "AccessToken" , "secret-token" , "REDACTED" },
156+ {"RedactSensitiveKeyAuthorization" , true , "Authorization" , "Bearer secret-token" , "REDACTED" },
157+ {"DoNotRedactNonSensitiveKey" , true , "NonSensitiveKey" , "non-sensitive-value" , "non-sensitive-value" },
158+ {"DoNotRedactWhenDisabled" , false , "AccessToken" , "secret-token" , "secret-token" },
159+ }
160+
161+ for _ , tt := range tests {
162+ t .Run (tt .name , func (t * testing.T ) {
163+ client := & Client {
164+ clientConfig : ClientConfig {
165+ ClientOptions : ClientOptions {
166+ HideSensitiveData : tt .hideSensitive ,
167+ },
168+ },
169+ }
170+
171+ result := RedactSensitiveHeaderData (client , tt .key , tt .value )
172+ assert .Equal (t , tt .expectedOutcome , result , "Redaction outcome should match expected" )
173+ })
174+ }
175+ }
0 commit comments