Files
archie/modules/chat/tools_test.go
T

30 lines
951 B
Go

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{
"/": true,
"/runs": true,
"/runs/0b8f6c1e-4a7e-4f6d": true,
"/controls/github:merge_pr": true,
"/proposals": true,
"/settings/extensions": 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)
}
}
}