INNER CODE UNIT · Go
TestLandingPageHTMLEscapesMetricsPath
oracle/oracle-db-appdev-monitoring · main_test.go:12
func TestLandingPageHTMLEscapesMetricsPath(t *testing.T) {
originalVersion := Version
Version = "test"
t.Cleanup(func() {
Version = originalVersion
})
body := landingPageHTML("/metrics' onclick='alert(1)")
if strings.Contains(body, "onclick='alert(1)") {
t.Fatalf("expected landing page to escape metrics path, got %q", body)
}
if !strings.Contains(body, "href='/metrics' onclick='alert(1)'") {
t.Fatalf("expected escaped metrics path in href, got %q", body)
}
}
func TestParseConfigFileExplicitFlag(t *testing.T) {