From ca6287ef1d0bb73bba583fe20d76d2f24a699b23 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 15 Oct 2026 02:41:51 +0000 Subject: [PATCH] Test that the example config allowlists no host Loads configs/config.example.yml with a real signing key, as Getting Started has it copied and edited, and fails while the example allowlists any host: every image on an allowlisted host is served to anyone without a signature. Fails until https://git.eeqj.de/sneak/pixa/issues/249 is fixed. Model: opus-5-5 --- internal/config/config_internal_test.go | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/config/config_internal_test.go b/internal/config/config_internal_test.go index de33d40..b655b35 100644 --- a/internal/config/config_internal_test.go +++ b/internal/config/config_internal_test.go @@ -92,6 +92,32 @@ func TestGetStringSlice_Empty(t *testing.T) { } } +// TestExampleConfigAllowlistsNoHost loads configs/config.example.yml +// with a real signing key, as Getting Started in README.md has it copied +// and edited, and checks that it allowlists no host: every image on an +// allowlisted host is served to anyone without a signature. +func TestExampleConfigAllowlistsNoHost(t *testing.T) { + t.Setenv("PIXA_SIGNING_KEY", validTestSigningKey) + + examplePath := filepath.Join("..", "..", "configs", "config.example.yml") + + sc, err := loadTestConfig(examplePath) + if err != nil { + t.Fatalf("failed to load %s: %v", examplePath, err) + } + + c, err := newFromSmartConfig(sc) + if err != nil { + t.Fatalf("%s is not a valid config: %v", examplePath, err) + } + + t.Logf("allowlist_hosts in %s: %v", examplePath, c.AllowlistHosts) + + if len(c.AllowlistHosts) != 0 { + t.Errorf("%s allowlists %v, want no host", examplePath, c.AllowlistHosts) + } +} + // loadTestConfig is a helper to load a config file for testing. func loadTestConfig(path string) (*smartconfig.Config, error) { return smartconfig.NewFromConfigPath(path)