(t *testing.T)
| 1065 | } |
| 1066 | |
| 1067 | func TestPprofCmdlineDisabled(t *testing.T) { |
| 1068 | var cfg Config |
| 1069 | flagext.DefaultValues(&cfg) |
| 1070 | setAutoAssignedPorts("tcp", &cfg) |
| 1071 | reg := prometheus.NewPedanticRegistry() |
| 1072 | cfg.Registerer, cfg.Gatherer = reg, reg |
| 1073 | |
| 1074 | srv, err := New(cfg) |
| 1075 | require.NoError(t, err) |
| 1076 | go func() { require.NoError(t, srv.Run()) }() |
| 1077 | t.Cleanup(srv.Shutdown) |
| 1078 | |
| 1079 | // /debug/pprof/cmdline should return 404 |
| 1080 | resp, err := http.Get(httpTarget(srv, "/debug/pprof/cmdline")) |
| 1081 | require.NoError(t, err) |
| 1082 | defer resp.Body.Close() |
| 1083 | assert.Equal(t, http.StatusNotFound, resp.StatusCode) |
| 1084 | |
| 1085 | // Other pprof endpoints should still work |
| 1086 | for _, path := range []string{"/debug/pprof/", "/debug/pprof/heap"} { |
| 1087 | resp, err := http.Get(httpTarget(srv, path)) |
| 1088 | require.NoError(t, err) |
| 1089 | resp.Body.Close() |
| 1090 | assert.Equal(t, http.StatusOK, resp.StatusCode, "expected 200 for %s", path) |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | func httpTarget(srv *Server, path string) string { |
| 1095 | return fmt.Sprintf("http://%s%s", srv.HTTPListenAddr().String(), path) |
nothing calls this directly
no test coverage detected