Skip to content

Commit e574f74

Browse files
Copilotlpcox
andcommitted
Fix linting error: Add TestTruncateSessionID test calling sanitize.TruncateSessionID
The test was added in main branch but was calling the function directly from the auth package. Since the function was moved to sanitize package, the test now correctly calls sanitize.TruncateSessionID. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 3b58536 commit e574f74

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

internal/auth/header_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,81 @@ func TestExtractSessionID(t *testing.T) {
344344
})
345345
}
346346
}
347+
348+
func TestTruncateSessionID(t *testing.T) {
349+
assert := assert.New(t)
350+
351+
tests := []struct {
352+
name string
353+
sessionID string
354+
want string
355+
}{
356+
{
357+
name: "Empty session ID returns (none)",
358+
sessionID: "",
359+
want: "(none)",
360+
},
361+
{
362+
name: "Single character",
363+
sessionID: "a",
364+
want: "a",
365+
},
366+
{
367+
name: "Short session ID (5 chars)",
368+
sessionID: "abc12",
369+
want: "abc12",
370+
},
371+
{
372+
name: "Exactly 8 characters - not truncated",
373+
sessionID: "abcd1234",
374+
want: "abcd1234",
375+
},
376+
{
377+
name: "Exactly 9 characters - truncated",
378+
sessionID: "abcd12345",
379+
want: "abcd1234...",
380+
},
381+
{
382+
name: "Long session ID (>8 chars)",
383+
sessionID: "my-session-id-12345",
384+
want: "my-sessi...",
385+
},
386+
{
387+
name: "Very long session ID",
388+
sessionID: "my-super-long-session-id-with-many-characters-12345678901234567890",
389+
want: "my-super...",
390+
},
391+
{
392+
name: "Session ID with special characters",
393+
sessionID: "key!@#$%^&*()",
394+
want: "key!@#$%...",
395+
},
396+
{
397+
name: "Session ID with unicode",
398+
sessionID: "session-émojis-🔑",
399+
want: "session-...",
400+
},
401+
{
402+
name: "UUID format",
403+
sessionID: "550e8400-e29b-41d4-a716-446655440000",
404+
want: "550e8400...",
405+
},
406+
{
407+
name: "Whitespace only (under 8 chars)",
408+
sessionID: " ",
409+
want: " ",
410+
},
411+
{
412+
name: "Whitespace only (over 8 chars)",
413+
sessionID: " ",
414+
want: " ...",
415+
},
416+
}
417+
418+
for _, tt := range tests {
419+
t.Run(tt.name, func(t *testing.T) {
420+
got := sanitize.TruncateSessionID(tt.sessionID)
421+
assert.Equal(tt.want, got)
422+
})
423+
}
424+
}

0 commit comments

Comments
 (0)