feat(chromium): return 409 Conflict if HTTP status code from main page is not acceptable (#755)

This commit is contained in:
Julien Neuhart
2023-12-14 21:39:36 +01:00
committed by GitHub
parent 390c8437c5
commit 64af65b0e7
6 changed files with 166 additions and 4 deletions

View File

@@ -415,6 +415,39 @@ func TestChromiumBrowser_pdf(t *testing.T) {
"skipping network idle event",
},
},
{
scenario: "ErrInvalidHttpStatusCode",
browser: newChromiumBrowser(
browserArguments{
binPath: os.Getenv("CHROMIUM_BIN_PATH"),
wsUrlReadTimeout: 5 * time.Second,
allowList: regexp.MustCompile(""),
denyList: regexp.MustCompile(""),
},
),
fs: func() *gotenberg.FileSystem {
fs := gotenberg.NewFileSystem()
err := os.MkdirAll(fs.WorkingDirPath(), 0o755)
if err != nil {
t.Fatalf(fmt.Sprintf("expected no error but got: %v", err))
}
err = os.WriteFile(fmt.Sprintf("%s/index.html", fs.WorkingDirPath()), []byte("<h1>ErrInvalidHttpStatusCode</h1>"), 0o755)
if err != nil {
t.Fatalf("expected no error but got: %v", err)
}
return fs
}(),
options: Options{
FailOnHttpStatusCodes: []int64{299},
},
noDeadline: false,
start: true,
expectError: true,
expectedError: ErrInvalidHttpStatusCode,
},
{
scenario: "ErrConsoleExceptions",
browser: newChromiumBrowser(