test(webhook): add integration testing for the webhook feature - testing the custom Content-Disposition header from #1165

This commit is contained in:
Julien Neuhart
2025-04-08 18:51:51 +02:00
parent 10588efe25
commit 7fe0e05050
2 changed files with 44 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import (
"strings"
"github.com/cucumber/godog"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/mholt/archives"
)
@@ -62,7 +63,16 @@ func newServer(ctx context.Context, workdir string) (*server, error) {
filename, ok := params["filename"]
if !ok {
return webhookErr(errors.New("no filename in Content-Disposition header"))
filename = uuid.NewString()
contentType := s.req.Header.Get("Content-Type")
switch contentType {
case "application/zip":
filename = fmt.Sprintf("%s.zip", filename)
case "application/pdf":
filename = fmt.Sprintf("%s.pdf", filename)
default:
return webhookErr(errors.New("no filename in Content-Disposition header"))
}
}
dirPath := fmt.Sprintf("%s/%s", workdir, s.req.Header.Get("Gotenberg-Trace"))