IMG-57: introduce processing options factory (#1526)

* Intoduced options.Factory

* ProcessingOptionsFactory in processing and watermark

* Clone with testutil.Helper
This commit is contained in:
Victor Sokolov
2025-09-16 17:04:21 +02:00
committed by GitHub
parent 355e3c506e
commit 4b05e87274
18 changed files with 739 additions and 399 deletions

View File

@@ -168,7 +168,7 @@ func (s *ProcessingHandlerTestSuite) TestResultingFormatNotSupported() {
}
func (s *ProcessingHandlerTestSuite) TestSkipProcessingConfig() {
config.SkipProcessingFormats = []imagetype.Type{imagetype.PNG}
s.Config().Options.SkipProcessingFormats = []imagetype.Type{imagetype.PNG}
res := s.GET("/unsafe/rs:fill:4:4/plain/local:///test1.png")
@@ -184,7 +184,7 @@ func (s *ProcessingHandlerTestSuite) TestSkipProcessingPO() {
}
func (s *ProcessingHandlerTestSuite) TestSkipProcessingSameFormat() {
config.SkipProcessingFormats = []imagetype.Type{imagetype.PNG}
s.Config().Options.SkipProcessingFormats = []imagetype.Type{imagetype.PNG}
res := s.GET("/unsafe/rs:fill:4:4/plain/local:///test1.png@png")
@@ -477,7 +477,7 @@ func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvg() {
func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgWithEnforceAvif() {
config.AlwaysRasterizeSvg = true
config.EnforceWebp = true
s.Config().Options.EnforceWebp = true
res := s.GET("/unsafe/plain/local:///test1.svg", http.Header{"Accept": []string{"image/webp"}})
@@ -487,7 +487,7 @@ func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgWithEnforceAvif() {
func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgDisabled() {
config.AlwaysRasterizeSvg = false
config.EnforceWebp = true
s.Config().Options.EnforceWebp = true
res := s.GET("/unsafe/plain/local:///test1.svg")
@@ -497,7 +497,7 @@ func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgDisabled() {
func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgWithFormat() {
config.AlwaysRasterizeSvg = true
config.SkipProcessingFormats = []imagetype.Type{imagetype.SVG}
s.Config().Options.SkipProcessingFormats = []imagetype.Type{imagetype.SVG}
res := s.GET("/unsafe/plain/local:///test1.svg@svg")
@@ -506,7 +506,7 @@ func (s *ProcessingHandlerTestSuite) TestAlwaysRasterizeSvgWithFormat() {
}
func (s *ProcessingHandlerTestSuite) TestMaxSrcFileSizeGlobal() {
config.MaxSrcFileSize = 1
s.Config().Security.DefaultOptions.MaxSrcFileSize = 1
ts := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(200)