From 293ca65a4fa5d0d699ae107be3b89910bfbcd168 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Mon, 3 Mar 2025 13:27:24 +0100 Subject: [PATCH] auth: fix middleware tests They got broken with 6eae2199 because the tests cannot use `config.LoadConfig`, so the list of internal IP nets never gets populated. --- auth/middleware_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/auth/middleware_test.go b/auth/middleware_test.go index f4ff340be7334b4a05679f8102417869c946fbde..2289ee9a1b4737c0b63125f9e4d7c7cc191fedde 100644 --- a/auth/middleware_test.go +++ b/auth/middleware_test.go @@ -3,6 +3,7 @@ package auth import ( "context" "encoding/json" + "net" "net/http" "strings" "testing" @@ -165,6 +166,12 @@ internal-ipnet=127.0.0.1/24,::1/64`)) panic(err) } crypto.InitCrypto(conf) + + // This doesn't get populated because we can't use config.LoadFile + _, local4, _ := net.ParseCIDR("127.0.0.1/8") + _, local6, _ := net.ParseCIDR("::1/64") + config.InternalIPNet = append(config.InternalIPNet, *local4) + config.InternalIPNet = append(config.InternalIPNet, *local6) } func middleware() (http.HandlerFunc, *context.Context, *bool) {