Remove the code nothing in production calls (closes #312)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Service.Warm, the ImageCache interface, both GenerateSignedURL methods, signature.ParseParams, three functions of internal/magic, the image processor's lists of supported formats, IsEmpty and Count of the allowlist, ssrfSafeDialer, CacheStale, ErrCacheMiss, ErrNegativeCache, ImageResponse.LastModified and VariantStorage.Load had no caller outside tests. They are gone, with the tests that tested only them. The handlers tests sign their image URLs with generateSignedURL, a test helper that builds the URL as the removed generator did. The SSRF dialer tests call dialSSRFSafe with no operator blocklist, which is all ssrfSafeDialer did. ParseImageURL, MIMEToImageFormat, ContentStorage.Store and CleanExpired stay, as pixa calls them. Model: opus-5-5
This commit is contained in:
@@ -22,11 +22,6 @@ type goldenVector struct {
|
||||
// padded) HMAC-SHA256 signature for the request with Expires
|
||||
// set to goldenExpiresUnix.
|
||||
wantSignature string
|
||||
// wantSignedPath is the exact path returned by
|
||||
// GenerateSignedURL for the request. The signature and
|
||||
// expiration are returned separately by GenerateSignedURL and
|
||||
// are not embedded in the path.
|
||||
wantSignedPath string
|
||||
}
|
||||
|
||||
// goldenVectors returns the known-answer vectors. The expected values
|
||||
@@ -50,8 +45,7 @@ func goldenVectors() []goldenVector {
|
||||
},
|
||||
// Signed data:
|
||||
// "cdn.example.com:/photos/cat.jpg::800:600:webp:1704067200:85:cover"
|
||||
wantSignature: "kdqeGoW2SX7qnaYtoB970wEnLydn0UnIgQYQLfAnjXQ=",
|
||||
wantSignedPath: testSignedPath,
|
||||
wantSignature: "kdqeGoW2SX7qnaYtoB970wEnLydn0UnIgQYQLfAnjXQ=",
|
||||
},
|
||||
{
|
||||
name: "resized with query string",
|
||||
@@ -71,8 +65,6 @@ func goldenVectors() []goldenVector {
|
||||
// Signed data:
|
||||
// "cdn.example.com:/photos/cat.jpg:token=abc&v=2:800:600:webp:1704067200:85:cover"
|
||||
wantSignature: "pKgVBOTd_Q_EikI7MNQLC9Q8Hurdxzyv3EIYvVhqc2I=",
|
||||
wantSignedPath: "/v1/image/cdn.example.com/photos/cat.jpg" +
|
||||
"%3Ftoken=abc&v=2/800x600.webp",
|
||||
},
|
||||
{
|
||||
name: "original size without query",
|
||||
@@ -91,8 +83,7 @@ func goldenVectors() []goldenVector {
|
||||
},
|
||||
// Signed data:
|
||||
// "cdn.example.com:/photos/cat.jpg::0:0:png:1704067200:85:cover"
|
||||
wantSignature: "6_rZ0yyVbGZRs8kG7n7HLgLi5Jt8vjiWQljIEL1jbIs=",
|
||||
wantSignedPath: "/v1/image/cdn.example.com/photos/cat.jpg/orig.png",
|
||||
wantSignature: "6_rZ0yyVbGZRs8kG7n7HLgLi5Jt8vjiWQljIEL1jbIs=",
|
||||
},
|
||||
{
|
||||
name: "non-default quality and fit",
|
||||
@@ -112,22 +103,17 @@ func goldenVectors() []goldenVector {
|
||||
// Signed data:
|
||||
// "cdn.example.com:/photos/cat.jpg::800:600:webp:1704067200:40:contain"
|
||||
wantSignature: "pGaXpPUbI3A7nMx-4T9bfq9bYWBNL0kY4bxlcv3g1F8=",
|
||||
// The path is the same as for the default quality and fit:
|
||||
// q=40&fit=contain go in the query string next to sig and
|
||||
// exp (imgcache.Service.GenerateSignedURL adds all four).
|
||||
wantSignedPath: testSignedPath,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TestSigner_GoldenVectors pins the exact HMAC-SHA256 signature output and
|
||||
// the exact generated signed URL path for fully-specified requests with a
|
||||
// hardcoded signing key.
|
||||
// TestSigner_GoldenVectors pins the exact HMAC-SHA256 signature output for
|
||||
// fully-specified requests with a hardcoded signing key.
|
||||
//
|
||||
// If any of these assertions fail, the signed byte format
|
||||
// ("host:path:query:width:height:format:expiration:quality:fit"), the
|
||||
// base64url encoding, or the signed URL layout has changed. Update these
|
||||
// constants only when that change is intended.
|
||||
// ("host:path:query:width:height:format:expiration:quality:fit") or the
|
||||
// base64url encoding has changed. Update these constants only when that
|
||||
// change is intended.
|
||||
func TestSigner_GoldenVectors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -145,14 +131,6 @@ func TestSigner_GoldenVectors(t *testing.T) {
|
||||
t.Errorf("Sign() = %q, want %q (signed byte format changed?)",
|
||||
gotSignature, tt.wantSignature)
|
||||
}
|
||||
|
||||
urlReq := tt.req
|
||||
|
||||
gotPath, _, _ := signer.GenerateSignedURL(&urlReq, time.Hour)
|
||||
if gotPath != tt.wantSignedPath {
|
||||
t.Errorf("GenerateSignedURL() path = %q, want %q (signed URL layout changed?)",
|
||||
gotPath, tt.wantSignedPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user