Fix metrics authorization middleware bleed (#3183)

fix: metrics authorization middleware bleed (#3182)

Fixes `extension_metrics_disabled.go` to correctly isolate the authz
middleware when the metrics extension is disabled.

Signed-off-by: Matthieu Mottet <m.mottet@outlook.com>
This commit is contained in:
mottetm
2025-06-06 00:41:32 +02:00
committed by GitHub
parent 0c51cb72c3
commit 483c869920
3 changed files with 16 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
function dist_route_check () {
local servername="http://127.0.0.1:${1}/v2/"
status_code=$(curl --write-out '%{http_code}' ${2} --silent --output /dev/null ${servername})
[ "$status_code" -eq ${3} ]
}
+6
View File
@@ -4,6 +4,7 @@
load helpers_zot
load helpers_metrics
load helpers_dist
function verify_prerequisites() {
if [ ! $(command -v curl) ]; then
@@ -107,4 +108,9 @@ function teardown_file() {
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
run metrics_route_check ${zot_port} "-u ${METRICS_USER}:${METRICS_PASS}" 200
[ "$status" -eq 0 ]
# anonymous policy: /v2/ endpoint should be available
# 200 - http.StatusOK
zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port`
run dist_route_check ${zot_port} "" 200
[ "$status" -eq 0 ]
}