Fix formatting in fetcher and signature tests
This commit is contained in:
@@ -58,11 +58,11 @@ func TestSigner_Verify(t *testing.T) {
|
||||
name: "valid signature",
|
||||
setup: func() *ImageRequest {
|
||||
req := &ImageRequest{
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
}
|
||||
req.Signature = signer.Sign(req)
|
||||
|
||||
@@ -74,11 +74,11 @@ func TestSigner_Verify(t *testing.T) {
|
||||
name: "expired signature",
|
||||
setup: func() *ImageRequest {
|
||||
req := &ImageRequest{
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(-1 * time.Hour), // Expired
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(-1 * time.Hour), // Expired
|
||||
}
|
||||
req.Signature = signer.Sign(req)
|
||||
|
||||
@@ -90,12 +90,12 @@ func TestSigner_Verify(t *testing.T) {
|
||||
name: "invalid signature",
|
||||
setup: func() *ImageRequest {
|
||||
return &ImageRequest{
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
Signature: "invalid-signature",
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
Signature: "invalid-signature",
|
||||
}
|
||||
},
|
||||
wantErr: ErrSignatureInvalid,
|
||||
@@ -118,11 +118,11 @@ func TestSigner_Verify(t *testing.T) {
|
||||
name: "tampered request",
|
||||
setup: func() *ImageRequest {
|
||||
req := &ImageRequest{
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
}
|
||||
req.Signature = signer.Sign(req)
|
||||
// Tamper with the request
|
||||
@@ -157,11 +157,11 @@ func TestSigner_DifferentKeys(t *testing.T) {
|
||||
signer2 := NewSigner("secret-key-2")
|
||||
|
||||
req := &ImageRequest{
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
SourceHost: "cdn.example.com",
|
||||
SourcePath: "/photos/cat.jpg",
|
||||
Size: Size{Width: 800, Height: 600},
|
||||
Format: FormatWebP,
|
||||
Expires: time.Now().Add(1 * time.Hour),
|
||||
}
|
||||
|
||||
// Sign with key 1
|
||||
|
||||
Reference in New Issue
Block a user