package guardianextension import ( "testing" "github.com/stretchr/testify/assert" ) func TestValidateAuthToken(t *testing.T) { handler := &GuardianCacheHandler{ validTokens: map[string]bool{ "validToken": true, }, } tests := []struct { name string authToken string expected string err error }{ { name: "Empty auth token", authToken: "", expected: "", err: ErrNoAuthToken, }, { name: "Auth token too long", authToken: string(make([]byte, 257)), expected: "", err: ErrUnauthorized, }, { name: "Invalid auth token", authToken: "invalidToken", expected: "", err: ErrUnauthorized, }, { name: "Valid auth token", authToken: "validToken", expected: "validToken", err: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result, err := handler.validateAuthToken(tt.authToken) assert.Equal(t, tt.err, err) assert.Equal(t, tt.expected, result) }) } }