MCPcopy Create free account
hub / github.com/NoFxAiOS/nofx / TestMaskSensitiveString

Function TestMaskSensitiveString

api/utils_test.go:9–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func 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
52func TestSanitizeModelConfigForLog(t *testing.T) {
53 models := map[string]ModelConfigUpdate{

Callers

nothing calls this directly

Calls 3

MaskSensitiveStringFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected