Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dropwhile committed Jun 18, 2024
1 parent 706d47c commit 1bc2ce6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pkg/camo/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func TestVideoContentTypeAllowed(t *testing.T) {
// bump limit, try again (should succeed)
camoConfigWithVideo.MaxSize = 5000 * 1024
_, err = makeTestReq(testURL, 200, camoConfigWithVideo)
// fmt.Println(err)
assert.Check(t, err)
}

Expand Down Expand Up @@ -260,6 +259,30 @@ func TestCredetialURLsAllowed(t *testing.T) {
assert.Check(t, err)
}

func TestMaxSizeRedirect(t *testing.T) {
t.Parallel()

camoConfigWithMaxSizeRedirect := Config{
HMACKey: []byte("0x24FEEDFACEDEADBEEFCAFE"),
MaxSize: 1 * 1024,
RequestTimeout: time.Duration(10) * time.Second,
MaxRedirects: 3,
MaxSizeRedirect: "http://example.com/some-image.png",
ServerName: "go-camo",
AllowContentVideo: true,
}

testURL := "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4"

// try a range request (should fail, MaxSize is smaller than requested range)
req, err := makeReq(camoConfigWithMaxSizeRedirect, testURL)
assert.Check(t, err)
req.Header.Add("Range", "bytes=0-1025")
resp, err := processRequest(req, 302, camoConfigWithMaxSizeRedirect, nil)
assert.Check(t, is.Equal(resp.Header.Get("Location"), camoConfigWithMaxSizeRedirect.MaxSizeRedirect))
assert.Check(t, err)
}

func TestSupplyAcceptIfNoneGiven(t *testing.T) {
t.Parallel()
testURL := "http://images.anandtech.com/doci/6673/OpenMoboAMD30_575px.png"
Expand Down

0 comments on commit 1bc2ce6

Please sign in to comment.