package telemetry import ( "strings" "testing" ) func TestRouteLabelsNeverContainResourceIDs(t *testing.T) { ids := []string{"11111111-1111-4111-8111-111111111111", "22222222-2222-4222-8222-222222222222"} for _, id := range ids { cases := map[string]string{ "/api/v1/chats/" + id: "/api/v1/chats/{chat_id}", "/api/v1/chats/" + id + "/messages": "/api/v1/chats/{chat_id}/messages", "/api/v1/chats/" + id + "/attachments": "/api/v1/chats/{chat_id}/attachments", "/api/v1/attachments/" + id + "/content": "/api/v1/attachments/{attachment_id}/content", "/arbitrary/" + id: "/unmatched", } for input, want := range cases { got := Route(input) if got != want || strings.Contains(got, id) { t.Fatalf("unsafe route label %q for %q", got, input) } } } if Method("CUSTOM-USER-METHOD") != "OTHER" { t.Fatal("unbounded method label") } }