Read referer_blocklist through strictLoader and fix test lint

newFromSmartConfig went over the line limit, so referer_blocklist is now
read through strictLoader, like the other typed settings, instead of its
own parse step. The tests stop repeating string literals that goconst
counts: the environment test uses other hosts, two case names change, and
the handler test names each image route's URL instead of its path.

Model: opus-5-5
This commit is contained in:
2026-10-04 18:59:29 +00:00
parent d9fa7d9130
commit 8f66a795ad
4 changed files with 32 additions and 20 deletions
@@ -133,19 +133,24 @@ func TestRefererBlocklist(t *testing.T) {
"https://hotlinker.example.evil.example/", http.StatusOK},
}
for _, route := range []string{"/v1/image/", "/v1/e/"} {
// The photo's URL on each image route.
photoURLs := map[string]func(t *testing.T, h *Handlers) string{
"plain URL": func(t *testing.T, _ *Handlers) string {
t.Helper()
return photoURL(allowlistedHost)
},
"encrypted URL": encPhotoURL,
}
for urlName, photoURLFor := range photoURLs {
for _, tc := range cases {
t.Run(route+" "+tc.name, func(t *testing.T) {
t.Run(urlName+", "+tc.name, func(t *testing.T) {
t.Parallel()
routes, h, fetcher := newRefererRoutes(t)
target := photoURL(allowlistedHost)
if route == "/v1/e/" {
target = encPhotoURL(t, h)
}
rec := getWithReferer(t, routes, target, tc.referer)
rec := getWithReferer(t, routes, photoURLFor(t, h), tc.referer)
if tc.want == http.StatusOK {
requireServedPhoto(t, rec)