Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/testcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func testData(t *testing.T, templateData any, files ...string) TestCases {

for _, doc := range bytes.Split(b.Bytes(), []byte("---")) {
var testcase Case
err = yaml.Unmarshal(doc, &testcase)
err = yaml.UnmarshalStrict(doc, &testcase)
require.NoError(t, err)
configs = append(configs, testcase)
}
Expand Down
19 changes: 19 additions & 0 deletions test/testcases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package test_test
import (
"context"
"log"
"os"
"os/exec"
"testing"
"time"

Expand All @@ -13,6 +15,23 @@ import (
"github.com/stretchr/testify/suite"
)

func TestLoadRejectsUnknownFields(t *testing.T) {
// Load fails via t.FailNow, so assert on it from a child process.
if os.Getenv("EXTPROC_LOAD_CHILD") == "1" {
extproctest.Load(t, "testdata/unknown_field.yml")
return
}
if testing.Short() {
t.Skip()
}

cmd := exec.Command(os.Args[0], "-test.run=^TestLoadRejectsUnknownFields$")
cmd.Env = append(os.Environ(), "EXTPROC_LOAD_CHILD=1")
out, err := cmd.CombinedOutput()
require.Error(t, err, "Load should fail on unknown fields:\n%s", out)
require.Contains(t, string(out), `unknown field "expect"`)
}

func TestIntegration(t *testing.T) {
suite.Run(t, &IntegrationTestSuite{})
}
Expand Down
9 changes: 9 additions & 0 deletions test/testdata/unknown_field.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: expect is wrongly nested under input
input:
headers:
- name: user-agent
value: curl/8.0.0
expect:
requestHeaders:
- name: x-custom-header
exact: value-1
Loading