server: run the api checks against the path without params

pull/19205/head
R.B. Boyer 2023-10-13 15:05:00 -05:00
parent 99f7a1219e
commit 3894d93d61
2 changed files with 13 additions and 1 deletions

View File

@ -90,6 +90,18 @@ func TestAgentEndpointsFailInV2(t *testing.T) {
}) })
} }
t.Run("agent-self-with-params", func(t *testing.T) {
req, err := http.NewRequest("GET", "/v1/agent/self?dc=dc1", nil)
require.NoError(t, err)
resp := httptest.NewRecorder()
a.srv.h.ServeHTTP(resp, req)
require.Equal(t, http.StatusOK, resp.Code)
_, err = io.ReadAll(resp.Body)
require.NoError(t, err)
})
checkRequest("PUT", "/v1/agent/maintenance") checkRequest("PUT", "/v1/agent/maintenance")
checkRequest("GET", "/v1/agent/services") checkRequest("GET", "/v1/agent/services")
checkRequest("GET", "/v1/agent/service/web") checkRequest("GET", "/v1/agent/service/web")

View File

@ -396,7 +396,7 @@ func (s *HTTPHandlers) wrap(handler endpoint, methods []string) http.HandlerFunc
rejectCatalogV1Endpoint := false rejectCatalogV1Endpoint := false
if s.agent.baseDeps.UseV2Resources() { if s.agent.baseDeps.UseV2Resources() {
rejectCatalogV1Endpoint = isV1CatalogRequest(logURL) rejectCatalogV1Endpoint = isV1CatalogRequest(req.URL.Path)
} }
if s.denylist.Block(req.URL.Path) { if s.denylist.Block(req.URL.Path) {