|
@@ -561,6 +561,46 @@ func (s *ProcessingOptionsTestSuite) TestParsePathSignedInvalid() {
|
|
assert.Equal(s.T(), errInvalidSignature.Error(), err.Error())
|
|
assert.Equal(s.T(), errInvalidSignature.Error(), err.Error())
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (s *ProcessingOptionsTestSuite) TestParsePathOnlyPresets() {
|
|
|
|
+ conf.OnlyPresets = true
|
|
|
|
+ conf.Presets["test1"] = urlOptions{
|
|
|
|
+ "blur": []string{"0.2"},
|
|
|
|
+ }
|
|
|
|
+ conf.Presets["test2"] = urlOptions{
|
|
|
|
+ "quality": []string{"50"},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ req := s.getRequest("http://example.com/unsafe/test1:test2/plain/http://images.dev/lorem/ipsum.jpg")
|
|
|
|
+
|
|
|
|
+ ctx, err := parsePath(context.Background(), req)
|
|
|
|
+
|
|
|
|
+ require.Nil(s.T(), err)
|
|
|
|
+
|
|
|
|
+ po := getProcessingOptions(ctx)
|
|
|
|
+ assert.Equal(s.T(), float32(0.2), po.Blur)
|
|
|
|
+ assert.Equal(s.T(), 50, po.Quality)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (s *ProcessingOptionsTestSuite) TestParseBase64URLOnlyPresets() {
|
|
|
|
+ conf.OnlyPresets = true
|
|
|
|
+ conf.Presets["test1"] = urlOptions{
|
|
|
|
+ "blur": []string{"0.2"},
|
|
|
|
+ }
|
|
|
|
+ conf.Presets["test2"] = urlOptions{
|
|
|
|
+ "quality": []string{"50"},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ imageURL := "http://images.dev/lorem/ipsum.jpg?param=value"
|
|
|
|
+ req := s.getRequest(fmt.Sprintf("http://example.com/unsafe/test1:test2/%s.png", base64.RawURLEncoding.EncodeToString([]byte(imageURL))))
|
|
|
|
+
|
|
|
|
+ ctx, err := parsePath(context.Background(), req)
|
|
|
|
+
|
|
|
|
+ require.Nil(s.T(), err)
|
|
|
|
+
|
|
|
|
+ po := getProcessingOptions(ctx)
|
|
|
|
+ assert.Equal(s.T(), float32(0.2), po.Blur)
|
|
|
|
+ assert.Equal(s.T(), 50, po.Quality)
|
|
|
|
+}
|
|
func TestProcessingOptions(t *testing.T) {
|
|
func TestProcessingOptions(t *testing.T) {
|
|
suite.Run(t, new(ProcessingOptionsTestSuite))
|
|
suite.Run(t, new(ProcessingOptionsTestSuite))
|
|
}
|
|
}
|