Co-authored-by: Mathias <mthbqv@gmail.com>
This commit was merged in pull request #183.
This commit is contained in:
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mathiasbq/hyperguild/ingestion/internal/metrics"
|
||||
)
|
||||
|
||||
// wrongTokSentinel is a presented credential distinctive enough that any
|
||||
@@ -53,8 +51,8 @@ func TestBuildMuxAcceptedLogLineOmitsTheBareStaticToken(t *testing.T) {
|
||||
// An authenticated REST request is labelled with the REST mux's pattern:
|
||||
// the inner mux sets it on the same *http.Request the outer middleware reads.
|
||||
func TestMetricsLabelAnAuthenticatedRESTRequestWithItsRoutePattern(t *testing.T) {
|
||||
reg := metrics.New()
|
||||
code, _ := do(t, reg.Middleware(testMux(t)), "GET", "/pending", "Bearer "+routesTok)
|
||||
mux, reg := testMuxAndRegistry(t)
|
||||
code, _ := do(t, mux, "GET", "/pending", "Bearer "+routesTok)
|
||||
require.Equal(t, http.StatusOK, code)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
@@ -67,8 +65,8 @@ func TestMetricsLabelAnAuthenticatedRESTRequestWithItsRoutePattern(t *testing.T)
|
||||
// so it was labelled path="/" and a 4xx on /query could not be told from one
|
||||
// on /write. It is now labelled with the REST pattern it was addressed to.
|
||||
func TestMetricsLabelARejectedRESTRequestWithItsRoutePattern(t *testing.T) {
|
||||
reg := metrics.New()
|
||||
code, _ := do(t, reg.Middleware(testMux(t)), "POST", "/query", "")
|
||||
mux, reg := testMuxAndRegistry(t)
|
||||
code, _ := do(t, mux, "POST", "/query", "")
|
||||
require.Equal(t, http.StatusUnauthorized, code)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
@@ -79,8 +77,8 @@ func TestMetricsLabelARejectedRESTRequestWithItsRoutePattern(t *testing.T) {
|
||||
// A path no REST route matches keeps the catch-all label, so an attacker
|
||||
// probing random URLs cannot grow the series set.
|
||||
func TestMetricsLabelARejectedUnknownPathWithTheCatchAll(t *testing.T) {
|
||||
reg := metrics.New()
|
||||
code, _ := do(t, reg.Middleware(testMux(t)), "POST", "/no-such-route-zq", "")
|
||||
mux, reg := testMuxAndRegistry(t)
|
||||
code, _ := do(t, mux, "POST", "/no-such-route-zq", "")
|
||||
require.Equal(t, http.StatusUnauthorized, code)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
Reference in New Issue
Block a user