Use example.com hosts in config test fixtures (closes #371)
check / check (push) In progress

The allowlist fixtures named one of our storage hosts and the owner's
domain. They now use s3.example.com and images.example.org; the tests
check the same behaviour.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-16 05:58:33 +00:00
1 parent cf6f8172e3
commit 9bcef9d06e
2 files changed
+8 -8

No files matched your search

@@ -52,7 +52,7 @@ const validTestSigningKey = "0123456789abcdef0123456789abcdef"
const signingKeyLine = "signing_key: " + validTestSigningKey + "\n"
// testHostS3 is an allowlist host entry used across the config tests.
const testHostS3 = "s3.sneak.cloud"
const testHostS3 = "s3.example.com"
// nullValueText is the substring that error messages about explicitly
// null config values must contain.
@@ -272,7 +272,7 @@ state_dir: /tmp/pixa-test-state
db_url: "file:/tmp/pixa-test-state/other.sqlite3"
signing_key: ` + validTestSigningKey + `
allowlist_hosts:
- s3.sneak.cloud
- s3.example.com
- .example.com
allow_http: true
upstream_connections_per_host: 5
@@ -306,7 +306,7 @@ metrics:
if len(c.AllowlistHosts) != 2 || c.AllowlistHosts[0] != testHostS3 ||
c.AllowlistHosts[1] != ".example.com" {
t.Errorf("AllowlistHosts = %v, want [s3.sneak.cloud .example.com]",
t.Errorf("AllowlistHosts = %v, want [s3.example.com .example.com]",
c.AllowlistHosts)
}
@@ -328,7 +328,7 @@ func TestCommaSeparatedAllowlistStillSupported(t *testing.T) {
t.Parallel()
yamlContent := signingKeyLine +
`allowlist_hosts: "s3.sneak.cloud, sneak.berlin"
`allowlist_hosts: "s3.example.com, images.example.org"
`
c, err := configFromYAML(t, yamlContent)
@@ -337,8 +337,8 @@ func TestCommaSeparatedAllowlistStillSupported(t *testing.T) {
}
if len(c.AllowlistHosts) != 2 || c.AllowlistHosts[0] != testHostS3 ||
c.AllowlistHosts[1] != "sneak.berlin" {
t.Errorf("AllowlistHosts = %v, want [s3.sneak.cloud sneak.berlin]",
c.AllowlistHosts[1] != "images.example.org" {
t.Errorf("AllowlistHosts = %v, want [s3.example.com images.example.org]",
c.AllowlistHosts)
}
}
+2 -2
View File
@@ -64,7 +64,7 @@ func TestEnvironmentSetsEveryKey(t *testing.T) {
t.Setenv("PIXA_METRICS_USERNAME", "metricsuser")
t.Setenv("PIXA_METRICS_PASSWORD", "metricspass")
t.Setenv("PIXA_SIGNING_KEY", validTestSigningKey)
t.Setenv("PIXA_ALLOWLIST_HOSTS", "s3.sneak.cloud,.example.com")
t.Setenv("PIXA_ALLOWLIST_HOSTS", "s3.example.com,.example.com")
t.Setenv("PIXA_REFERER_BLOCKLIST", "hotlinker.example,.leech.example")
t.Setenv("PIXA_ALLOW_HTTP", "true")
t.Setenv("PIXA_UPSTREAM_CONNECTIONS_PER_HOST", "5")
@@ -262,7 +262,7 @@ func TestListFromEnvironmentReplacesConfigFileList(t *testing.T) {
t.Setenv("PIXA_ALLOWLIST_HOSTS", " cdn.example.com , .example.org ")
c, err := configFromYAML(t, signingKeyLine+
"allowlist_hosts:\n - s3.sneak.cloud\n - sneak.berlin\n")
"allowlist_hosts:\n - s3.example.com\n - images.example.org\n")
if err != nil {
t.Fatalf("PIXA_ALLOWLIST_HOSTS should load: %v", err)
}