From 6c5fc3eacd3b7c8be9b0030fff719d06888c8de2 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Mon, 9 Nov 2026 18:24:42 +0000 Subject: [PATCH] test: cover QUERY CORS preflight --- main_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main_test.go b/main_test.go index 6c4342b..47d6c7a 100644 --- a/main_test.go +++ b/main_test.go @@ -186,6 +186,24 @@ func TestValidateEndpoint(t *testing.T) { runTestCases(t, tests) } +func TestValidatePreflight(t *testing.T) { + req, err := http.NewRequest(http.MethodOptions, "/v1/validate", nil) + if err != nil { + t.Fatal(err) + } + req.Header.Set("Origin", "https://validator.example") + req.Header.Set("Access-Control-Request-Method", "QUERY") + + res, err := app.Test(req, fiber.TestConfig{Timeout: 0, FailOnTimeout: false}) + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + + assert.Equal(t, http.StatusNoContent, res.StatusCode) + assert.Contains(t, res.Header.Get("Access-Control-Allow-Methods"), "QUERY") +} + func TestStatusEndpoints(t *testing.T) { tests := []TestCase{ {