package chat import "testing" // TestDashboardPathStaysInTheDashboard guards the link the agent can offer // the operator: it must never lead off the dashboard or outside its pages. func TestDashboardPathStaysInTheDashboard(t *testing.T) { cases := map[string]bool{ "/runs": true, "/runs/0b8f6c1e-4a7e-4f6d": true, "/classes/github:merge_pr": true, "//evil.example/runs": false, "https://evil.example/runs": false, "javascript:alert(1)": false, "/runs/../settings": false, "/runs/a/b": false, "/runs/..": false, "/admin": false, "runs": false, } for path, want := range cases { if got := dashboardPath(path); got != want { t.Errorf("dashboardPath(%q) = %v, want %v", path, got, want) } } }