(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestMaskSensitiveString(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | input string |
| 13 | expected string |
| 14 | }{ |
| 15 | { |
| 16 | name: "Empty string", |
| 17 | input: "", |
| 18 | expected: "", |
| 19 | }, |
| 20 | { |
| 21 | name: "Short string (8 characters or less)", |
| 22 | input: "short", |
| 23 | expected: "****", |
| 24 | }, |
| 25 | { |
| 26 | name: "Normal API key", |
| 27 | input: "sk-1234567890abcdefghijklmnopqrstuvwxyz", |
| 28 | expected: "sk-1****wxyz", |
| 29 | }, |
| 30 | { |
| 31 | name: "Normal private key", |
| 32 | input: "0x1234567890abcdef1234567890abcdef12345678", |
| 33 | expected: "0x12****5678", |
| 34 | }, |
| 35 | { |
| 36 | name: "Exactly 9 characters", |
| 37 | input: "123456789", |
| 38 | expected: "1234****6789", |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | for _, tt := range tests { |
| 43 | t.Run(tt.name, func(t *testing.T) { |
| 44 | result := MaskSensitiveString(tt.input) |
| 45 | if result != tt.expected { |
| 46 | t.Errorf("MaskSensitiveString(%q) = %q, want %q", tt.input, result, tt.expected) |
| 47 | } |
| 48 | }) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestSanitizeModelConfigForLog(t *testing.T) { |
| 53 | models := map[string]ModelConfigUpdate{ |
nothing calls this directly
no test coverage detected