next into main #370

Open
clawbot wants to merge 2 commits from next into main
pull from: next
3 changed files with 12 additions and 8 deletions

No files matched your search

+4
View File
@@ -545,6 +545,10 @@ need that fetch. An image whose first bytes libvips reads as another format is
refused with 415 too. An SVG whose first bytes pass the check for AVIF is one
example.
**Animated images.** pixa serves only the first frame of an animated GIF, WebP,
PNG or JPEG XL source. This holds in every output format, `orig` included. So an
animated GIF requested as GIF comes back as a still GIF.
**SVG sources.** `orig` of an SVG source is the SVG itself, unchanged, and is
cached like any other image. It is given only at the `orig` size, since pixa
does not resize an SVG as SVG. `orig` of an SVG at any other size is refused
@@ -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)
}