From 7359167c3fc4c42067a68cc33f9cb0a466c63653 Mon Sep 17 00:00:00 2001 From: quobix Date: Tue, 6 Oct 2026 08:53:09 -0400 Subject: [PATCH 1/3] Upgrade OpenAPI dependencies and migrate to pb33f YAML and testify --- .github/workflows/build.yaml | 2 +- .github/workflows/publish.yaml | 2 +- Dockerfile | 2 +- cmd/root_command.go | 2 +- cmd/run_service_test.go | 4 +- config/paths_test.go | 4 +- controls/controls_service_test.go | 2 +- daemon/broadcast/broadcaster_test.go | 4 +- daemon/build_request_test.go | 4 +- daemon/clone_request_test.go | 4 +- daemon/hard_error_status_test.go | 2 +- daemon/mock_problem_response_test.go | 4 +- daemon/mockproxy/handler_test.go | 4 +- daemon/mockproxy/static_response_test.go | 4 +- daemon/prep_test.go | 4 +- daemon/problems/problem_response_test.go | 2 +- daemon/proxy/api_test.go | 4 +- daemon/proxy/handler_test.go | 2 +- daemon/stream_chan_test.go | 2 +- daemon/validate_test.go | 4 +- daemon/validator/validator_test.go | 4 +- daemon/wiretap_utils_test.go | 2 +- go.mod | 29 +++++++----- go.sum | 60 +++++++++++++----------- har/build_har_test.go | 4 +- har/har_service_test.go | 2 +- har/validate_har_test.go | 4 +- mock/mock_engine_test.go | 5 +- shared/config.go | 2 +- shared/config_test.go | 56 ++++++++++++++++++++++ shared/error_test.go | 2 +- specs/conflicts_test.go | 4 +- specs/discovery_test.go | 4 +- specs/report_console_test.go | 2 +- validation/spec_router_test.go | 4 +- validation/validator_test.go | 2 +- 36 files changed, 155 insertions(+), 93 deletions(-) create mode 100644 shared/config_test.go diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f0a0a0d..0ac474c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v3 with: - go-version: ^1.24 + go-version: '1.26.x' id: go - name: Checkout code diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index abc4ca1..b6100dc 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -24,7 +24,7 @@ jobs: uses: actions/setup-go@v3 id: go with: - go-version: ^1.24 + go-version: '1.26.x' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 diff --git a/Dockerfile b/Dockerfile index 72083fe..1097a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ COPY ui/ ./ # run ui build RUN npm run build -FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS gobuilder +FROM --platform=$BUILDPLATFORM golang:1.26-bookworm AS gobuilder ARG TARGETOS ARG TARGETARCH diff --git a/cmd/root_command.go b/cmd/root_command.go index 1fa7513..da494a0 100644 --- a/cmd/root_command.go +++ b/cmd/root_command.go @@ -13,13 +13,13 @@ import ( "path/filepath" "github.com/pb33f/doctor/terminal" + "github.com/pb33f/go-yaml" "github.com/pb33f/libopenapi" "github.com/pb33f/libopenapi/orderedmap" "github.com/pb33f/wiretap/har" "github.com/pb33f/wiretap/shared" wiretapSpecs "github.com/pb33f/wiretap/specs" "github.com/spf13/cobra" - "go.yaml.in/yaml/v4" ) var ( diff --git a/cmd/run_service_test.go b/cmd/run_service_test.go index 46022da..9b5efcb 100644 --- a/cmd/run_service_test.go +++ b/cmd/run_service_test.go @@ -7,11 +7,11 @@ import ( "os" "testing" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" "github.com/spf13/cobra" "github.com/spf13/pflag" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRunWiretapServiceRejectsInvalidWebSocketPort(t *testing.T) { diff --git a/config/paths_test.go b/config/paths_test.go index 032ac7f..5416763 100644 --- a/config/paths_test.go +++ b/config/paths_test.go @@ -8,9 +8,9 @@ import ( "net/http" "testing" + "github.com/pb33f/go-yaml" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "go.yaml.in/yaml/v4" ) func TestIsHardErrorsSet(t *testing.T) { diff --git a/controls/controls_service_test.go b/controls/controls_service_test.go index db0dbae..52a333e 100644 --- a/controls/controls_service_test.go +++ b/controls/controls_service_test.go @@ -8,8 +8,8 @@ import ( "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/store" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" ) func TestResetRuntimeStateClearsTransactionAndHARState(t *testing.T) { diff --git a/daemon/broadcast/broadcaster_test.go b/daemon/broadcast/broadcaster_test.go index 77f35dd..b28ddfd 100644 --- a/daemon/broadcast/broadcaster_test.go +++ b/daemon/broadcast/broadcaster_test.go @@ -10,9 +10,9 @@ import ( "github.com/google/uuid" "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/model" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/transaction" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestBroadcasterSendsPreMarshaledTransactionPayload(t *testing.T) { diff --git a/daemon/build_request_test.go b/daemon/build_request_test.go index a63e430..7beb6e0 100644 --- a/daemon/build_request_test.go +++ b/daemon/build_request_test.go @@ -16,10 +16,10 @@ import ( "github.com/google/uuid" "github.com/pb33f/libopenapi/orderedmap" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" "github.com/pb33f/wiretap/transaction" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestBuildHttpTransactionMultipartLargeForm(t *testing.T) { diff --git a/daemon/clone_request_test.go b/daemon/clone_request_test.go index 362b791..431e364 100644 --- a/daemon/clone_request_test.go +++ b/daemon/clone_request_test.go @@ -9,8 +9,8 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) func TestCloneExistingRequestInstallsReplayableBody(t *testing.T) { diff --git a/daemon/hard_error_status_test.go b/daemon/hard_error_status_test.go index b9b12b2..425bbf1 100644 --- a/daemon/hard_error_status_test.go +++ b/daemon/hard_error_status_test.go @@ -6,9 +6,9 @@ package daemon import ( "testing" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/daemon/problems" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" ) func TestPickHardErrorStatus(t *testing.T) { diff --git a/daemon/mock_problem_response_test.go b/daemon/mock_problem_response_test.go index df84cdf..506431e 100644 --- a/daemon/mock_problem_response_test.go +++ b/daemon/mock_problem_response_test.go @@ -19,10 +19,10 @@ import ( "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/model" "github.com/pb33f/ranch/store" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/daemon/problems" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func newMockModeWiretapService(t *testing.T, config *shared.WiretapConfiguration) *WiretapService { diff --git a/daemon/mockproxy/handler_test.go b/daemon/mockproxy/handler_test.go index d07dc98..8273336 100644 --- a/daemon/mockproxy/handler_test.go +++ b/daemon/mockproxy/handler_test.go @@ -14,10 +14,10 @@ import ( "github.com/google/uuid" validationerrors "github.com/pb33f/libopenapi-validator/errors" "github.com/pb33f/ranch/model" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/daemon/problems" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestHandlerWritesMockResponse(t *testing.T) { diff --git a/daemon/mockproxy/static_response_test.go b/daemon/mockproxy/static_response_test.go index d922409..f2bbc4a 100644 --- a/daemon/mockproxy/static_response_test.go +++ b/daemon/mockproxy/static_response_test.go @@ -14,8 +14,8 @@ import ( "github.com/google/uuid" "github.com/pb33f/ranch/model" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) func TestHandleStaticResponseWritesResponseAndBroadcasts(t *testing.T) { diff --git a/daemon/prep_test.go b/daemon/prep_test.go index 934e8e9..d7d8949 100644 --- a/daemon/prep_test.go +++ b/daemon/prep_test.go @@ -14,9 +14,9 @@ import ( "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/model" "github.com/pb33f/ranch/store" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestPrepareRequestBuildsDisplayAndAPIRequests(t *testing.T) { diff --git a/daemon/problems/problem_response_test.go b/daemon/problems/problem_response_test.go index 38de0cc..ac0bb58 100644 --- a/daemon/problems/problem_response_test.go +++ b/daemon/problems/problem_response_test.go @@ -9,8 +9,8 @@ import ( "testing" validationerrors "github.com/pb33f/libopenapi-validator/errors" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" ) func buildSampleErrors(messages ...string) []*shared.WiretapValidationError { diff --git a/daemon/proxy/api_test.go b/daemon/proxy/api_test.go index 252eea6..aac3b17 100644 --- a/daemon/proxy/api_test.go +++ b/daemon/proxy/api_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/pb33f/libopenapi/orderedmap" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestCallAPIRewritesReferer(t *testing.T) { diff --git a/daemon/proxy/handler_test.go b/daemon/proxy/handler_test.go index b2f3b37..15832be 100644 --- a/daemon/proxy/handler_test.go +++ b/daemon/proxy/handler_test.go @@ -15,9 +15,9 @@ import ( "github.com/google/uuid" validationerrors "github.com/pb33f/libopenapi-validator/errors" "github.com/pb33f/ranch/model" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/daemon/problems" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" ) func TestHandlerWritesUpstreamResponse(t *testing.T) { diff --git a/daemon/stream_chan_test.go b/daemon/stream_chan_test.go index 4da0a0e..1302a4f 100644 --- a/daemon/stream_chan_test.go +++ b/daemon/stream_chan_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" + "github.com/pb33f/testify/assert" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" ) // TestSendToStreamChan_DoesNotBlockWhenFull proves that the sync hard-error diff --git a/daemon/validate_test.go b/daemon/validate_test.go index 3f8b048..92f8156 100644 --- a/daemon/validate_test.go +++ b/daemon/validate_test.go @@ -18,12 +18,12 @@ import ( "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/model" "github.com/pb33f/ranch/store" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/daemon/proxy" "github.com/pb33f/wiretap/shared" "github.com/pb33f/wiretap/specs" "github.com/pb33f/wiretap/transaction" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestHandleHttpRequestValidatesResponseAgainstPreparedRequestPath(t *testing.T) { diff --git a/daemon/validator/validator_test.go b/daemon/validator/validator_test.go index b493663..fbb93ca 100644 --- a/daemon/validator/validator_test.go +++ b/daemon/validator/validator_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/pb33f/libopenapi" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/validation" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestValidateRequestUsesMethodSpecificSpecWhenRoutesMatch(t *testing.T) { diff --git a/daemon/wiretap_utils_test.go b/daemon/wiretap_utils_test.go index 5e9c502..63f167f 100644 --- a/daemon/wiretap_utils_test.go +++ b/daemon/wiretap_utils_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" + "github.com/pb33f/testify/assert" ) func TestReconstructURL(t *testing.T) { diff --git a/go.mod b/go.mod index b77728b..b4defb3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pb33f/wiretap -go 1.25.7 +go 1.26.0 require ( github.com/gobwas/glob v0.2.3 @@ -9,26 +9,29 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/json-iterator/go v1.1.12 - github.com/pb33f/doctor v0.0.78 + github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598 + github.com/pb33f/go-yaml v0.1.1 github.com/pb33f/harific v0.0.6 - github.com/pb33f/libopenapi v0.38.3 - github.com/pb33f/libopenapi-validator v0.13.13 + github.com/pb33f/libopenapi v0.41.2 + github.com/pb33f/libopenapi-validator v0.15.0 github.com/pb33f/ranch v0.9.0 + github.com/pb33f/testify v0.1.1 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 - go.yaml.in/yaml/v4 v4.0.0-rc.6 ) require ( charm.land/bubbles/v2 v2.1.0 // indirect charm.land/bubbletea/v2 v2.0.7 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/a-h/templ v0.3.1020 // indirect - github.com/alecthomas/chroma/v2 v2.26.1 // indirect + github.com/alecthomas/chroma/v2 v2.27.0 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect - github.com/dlclark/regexp2/v2 v2.1.1 // indirect + github.com/dlclark/regexp2/v2 v2.2.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/yuin/goldmark v1.8.2 // indirect github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc // indirect @@ -55,8 +58,8 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 - github.com/go-openapi/jsonpointer v0.23.1 // indirect - github.com/go-openapi/swag/jsonname v0.26.0 // indirect + github.com/go-openapi/jsonpointer v0.23.2 // indirect + github.com/go-openapi/swag/jsonname v0.26.1 // indirect github.com/go-stomp/stomp/v3 v3.1.3 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 github.com/hashicorp/golang-lru/v2 v2.0.7 @@ -67,8 +70,8 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/muesli/cancelreader v0.2.2 // indirect - github.com/pb33f/jsonpath v0.8.2 // indirect - github.com/pb33f/ordered-map/v2 v2.3.1 // indirect + github.com/pb33f/jsonpath v0.8.4 // indirect + github.com/pb33f/ordered-map/v2 v2.3.2 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect @@ -78,12 +81,12 @@ require ( github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/spf13/viper v1.21.0 // indirect - github.com/stretchr/testify v1.11.1 + github.com/stretchr/testify v1.11.1 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/net v0.56.0 // indirect - golang.org/x/sync v0.21.0 // indirect + golang.org/x/sync v0.23.0 // indirect golang.org/x/sys v0.46.0 // indirect golang.org/x/text v0.38.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index e0f278d..38b418e 100644 --- a/go.sum +++ b/go.sum @@ -4,13 +4,15 @@ charm.land/bubbletea/v2 v2.0.7 h1:7qw2tTAVar7m7klOPBYfTB0mniv/RuexsYwMRNxSeL0= charm.land/bubbletea/v2 v2.0.7/go.mod h1:DGW2q8gvzHnOpMpZTORs0aySVHCox5C+2Svk0fci1qs= charm.land/lipgloss/v2 v2.0.4 h1:lcPeVtcp23SNra7lHy8iYE4UC2aIipVQ47sbGyyxR5Q= charm.land/lipgloss/v2 v2.0.4/go.mod h1:0653x8epbZSzdDfO/XPS1a/uYPOBeSsCssOpJOqDzik= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/a-h/templ v0.3.1020 h1:ypAT/L5ySWEnZ6Zft/5yfoWXYYkhFNvEFOeeqecg4tw= github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs= -github.com/alecthomas/chroma/v2 v2.26.1 h1:2X21EdxGZNv5GF9mG5u+uzc02GCFyGxbcBm3Grd9A78= -github.com/alecthomas/chroma/v2 v2.26.1/go.mod h1:lxhRRa9H4hPmRLOOdYga4zkQIQjq3dtrrdwQeCfu78Y= +github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r5BXYZs= +github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8= github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs= github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= @@ -55,8 +57,8 @@ github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55k github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8= github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dlclark/regexp2/v2 v2.1.1 h1:LCUGyd9Wf+r+VVOl8Ny38JTpWJcAsdVnCIuhhtthmKw= -github.com/dlclark/regexp2/v2 v2.1.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU= +github.com/dlclark/regexp2/v2 v2.2.1 h1:mf4KkFUj0gJuarK8P+LgiS+Lit7m9N1yAwEfPbee7R0= +github.com/dlclark/regexp2/v2 v2.2.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -65,12 +67,12 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4= -github.com/go-openapi/jsonpointer v0.23.1/go.mod h1:iWRmZTrGn7XwYhtPt/fvdSFj1OfNBngqRT2UG3BxSqY= -github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w= -github.com/go-openapi/swag/jsonname v0.26.0/go.mod h1:urBBR8bZNoDYGr653ynhIx+gTeIz0ARZxHkAPktJK2M= -github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLuq0ePx4= -github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/jsonpointer v0.23.2 h1:DK7R/3zAt4xTytxNkw7jARGPFI7rkaSsii58n8X45x0= +github.com/go-openapi/jsonpointer v0.23.2/go.mod h1:noUOckXtq7b4bVkqw0sbHKieq9uEZRN7p6EF/dalc4w= +github.com/go-openapi/swag/jsonname v0.26.1 h1:VReupaV6WxlAsCn0e4DUfgV6bPmINnPpyJDLqSfNPcE= +github.com/go-openapi/swag/jsonname v0.26.1/go.mod h1:OvdW6BoWoj33pTfi7x9vFrgmT+fk7aw0BRwvCE0YOuc= +github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= +github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= github.com/go-stomp/stomp/v3 v3.1.3 h1:5/wi+bI38O1Qkf2cc7Gjlw7N5beHMWB/BxpX+4p/MGI= github.com/go-stomp/stomp/v3 v3.1.3/go.mod h1:ztzZej6T2W4Y6FlD+Tb5n7HQP3/O5UNQiuC169pIp10= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= @@ -124,22 +126,26 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/pb33f/doctor v0.0.78 h1:6bAgJDacnUYNd6Neg9/nBl+L6aukmvBFopx37eqgHYw= -github.com/pb33f/doctor v0.0.78/go.mod h1:UCAKkAJpdcndw0vlTpQXTwq6npad1/m2Hvqem4zSMSw= +github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598 h1:DjkKy1l+Hy6sPFhNor4g97L0LR/3sj5EY6eL9Gmvvqw= +github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598/go.mod h1:QnCkf+zudvwyO8uFfVv9WJOeRbFzojy6e/3qvnL3pkE= +github.com/pb33f/go-yaml v0.1.1 h1:yWGmhVdwzionRnSc/hEJwcfq6PaZL2QdYzyReXBbX7Q= +github.com/pb33f/go-yaml v0.1.1/go.mod h1:QvWdkHP5VjFYAeHMQUkaPQqREaQnBNOXmWzAjNrnSdo= github.com/pb33f/harific v0.0.6 h1:jRll6fYIg1YbHmt/uQwWQ2tGXsQFPOaosE7A+HHo/lA= github.com/pb33f/harific v0.0.6/go.mod h1:lJrqd81pq/OhthWTJQduRxidldufqIkMQTwE/XZWg+M= -github.com/pb33f/jsonpath v0.8.2 h1:Ou4C7zjYClBm97dfZjDCjdZGusJoynv/vrtiEKNfj2Y= -github.com/pb33f/jsonpath v0.8.2/go.mod h1:zBV5LJW4OQOPatmQE2QdKpGQJvhDTlE5IEj6ASaRNTo= -github.com/pb33f/libopenapi v0.38.3 h1:ToJU49mGkr6IVTPvTY9V0QkzuoS0+HarSOuzHN8z54A= -github.com/pb33f/libopenapi v0.38.3/go.mod h1:8yHl64vr+ICrnzSgiwJmZ54heRqCqrhI/JL1ge+CPIY= -github.com/pb33f/libopenapi-validator v0.13.13 h1:RZk8CUsZ1x0yObHPY7KP+VKiW3iyLE65yOup0Elxfr0= -github.com/pb33f/libopenapi-validator v0.13.13/go.mod h1:KWbtcurMJX/VZkorPidKRrWQpFjRk4teAO9aYwKu4fY= -github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY= -github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ= +github.com/pb33f/jsonpath v0.8.4 h1:Yx7fxsKl8scgERL22WhKDs2c6gYNNUonPSWEG8Y194s= +github.com/pb33f/jsonpath v0.8.4/go.mod h1:eO6mgdhw5RgzCxm/bXTi75VUs0/cCYJzdGjMCCUEI6M= +github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641 h1:8D2syZhlMlHiB1bvm8o9Iapa72MhpgjeVaZvxN5rzfY= +github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641/go.mod h1:oV64uhHNjEgvdiKALbOoXSQpt/to0HNTShFFjKzi5Mg= +github.com/pb33f/libopenapi v0.41.2 h1:7/KNzJJ0o5fC/tYxDYcHjziKfg0bkBpFUfI2UDbChAo= +github.com/pb33f/libopenapi v0.41.2/go.mod h1:mUldESjO6ownR1TCcywvoYp7e4v/bCdQyiiIqsgWne0= +github.com/pb33f/libopenapi-validator v0.15.0 h1:5wl7/tpyewqzZ7Y5/M9CZjojlaaK2DYKPZYGIvPq7SI= +github.com/pb33f/libopenapi-validator v0.15.0/go.mod h1:P52RfZsY/+oWjRL52mpQ8Icwual6rtkJt1qOWdAe4eM= +github.com/pb33f/ordered-map/v2 v2.3.2 h1:wDyaZ2Pv9QLh64X4utCeD5Zoi9nIv2aW3lwv172O5PQ= +github.com/pb33f/ordered-map/v2 v2.3.2/go.mod h1:1OhFrXu3OYw3kM+FXF+Ug3ugmmZ9LE8z0JfQMLvtV0w= github.com/pb33f/ranch v0.9.0 h1:3alq+6o/fedVx26a0TCir4To2IniAvFsgNHwt3I1tIY= github.com/pb33f/ranch v0.9.0/go.mod h1:1FFDEs8Bl4CwaOad+NEczR2q0SitMjk4/3zEEtQzbds= -github.com/pb33f/testify v0.1.0 h1:g48/HDU/jn2COspS4nM0scptxiKTJ4DnbX/4ehK6IZ8= -github.com/pb33f/testify v0.1.0/go.mod h1:nq283P/jJ8hXMmdhAqfj7BJIz0y+6IOHj9q0044rKt4= +github.com/pb33f/testify v0.1.1 h1:mnHe7uxKt8dyNYEGUspow72VjD264DB5rOJq4bz5tJw= +github.com/pb33f/testify v0.1.1/go.mod h1:keghMqOLECF1ENzESnfM+cwPcKN5uhTOpvbtjgL6aZg= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -170,8 +176,8 @@ github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3A github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= @@ -189,8 +195,6 @@ github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+ github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= -go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -216,8 +220,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk= +golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/har/build_har_test.go b/har/build_har_test.go index 7abfdfc..49ad286 100644 --- a/har/build_har_test.go +++ b/har/build_har_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/pb33f/harific/motor" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) func TestNewHARStreamerStreamsEntriesFromPath(t *testing.T) { diff --git a/har/har_service_test.go b/har/har_service_test.go index cbd0dd6..ec1ab37 100644 --- a/har/har_service_test.go +++ b/har/har_service_test.go @@ -11,7 +11,7 @@ import ( "github.com/pb33f/ranch/bus" "github.com/pb33f/ranch/store" - "github.com/stretchr/testify/assert" + "github.com/pb33f/testify/assert" ) func TestNewHARServiceUsesDefaultReplayDelay(t *testing.T) { diff --git a/har/validate_har_test.go b/har/validate_har_test.go index 6267e2e..5312887 100644 --- a/har/validate_har_test.go +++ b/har/validate_har_test.go @@ -10,9 +10,9 @@ import ( "github.com/pb33f/libopenapi" v3 "github.com/pb33f/libopenapi/datamodel/high/v3" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestValidateHARStreamsFromPath(t *testing.T) { diff --git a/mock/mock_engine_test.go b/mock/mock_engine_test.go index ce0de8f..3fe0a69 100644 --- a/mock/mock_engine_test.go +++ b/mock/mock_engine_test.go @@ -15,8 +15,8 @@ import ( "github.com/pb33f/libopenapi" "github.com/pb33f/libopenapi-validator/helpers" v3 "github.com/pb33f/libopenapi/datamodel/high/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) var giftshopBytes []byte @@ -1768,4 +1768,3 @@ func TestMockBypass_NonHardValidation_IsNoOp(t *testing.T) { }) } } - diff --git a/shared/config.go b/shared/config.go index 868a017..91a513d 100644 --- a/shared/config.go +++ b/shared/config.go @@ -13,8 +13,8 @@ import ( "regexp" "strings" + "github.com/pb33f/go-yaml" "github.com/pb33f/libopenapi/orderedmap" - "go.yaml.in/yaml/v4" "github.com/gobwas/glob" ) diff --git a/shared/config_test.go b/shared/config_test.go new file mode 100644 index 0000000..234e04b --- /dev/null +++ b/shared/config_test.go @@ -0,0 +1,56 @@ +// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley +// SPDX-License-Identifier: AGPL + +package shared + +import ( + "testing" + + "github.com/pb33f/go-yaml" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" +) + +func TestWiretapConfigurationYAMLPreservesPathOrderAndAliases(t *testing.T) { + const source = `paths: + /products/special: &upstream + target: api.example.com + secure: true + /products/**: *upstream +mockMode: true +` + var config WiretapConfiguration + require.NoError(t, yaml.Unmarshal([]byte(source), &config)) + require.NotNil(t, config.PathConfigurations) + require.NotNil(t, config.CompiledPaths) + assert.True(t, config.MockMode) + + var paths []string + for pair := config.PathConfigurations.First(); pair != nil; pair = pair.Next() { + paths = append(paths, pair.Key()) + require.NotNil(t, pair.Value()) + assert.Equal(t, "api.example.com", pair.Value().Target) + assert.True(t, pair.Value().Secure) + } + assert.Equal(t, []string{"/products/special", "/products/**"}, paths) + + config.CompilePaths() + var compiledPaths []string + for pair := config.CompiledPaths.First(); pair != nil; pair = pair.Next() { + compiledPaths = append(compiledPaths, pair.Key()) + assert.True(t, pair.Value().CompiledKey.Match("/products/special")) + } + assert.Equal(t, paths, compiledPaths) +} + +func TestWiretapConfigurationYAMLRejectsInvalidFieldTypes(t *testing.T) { + for _, source := range []string{ + "mockMode: invalid\n", + "paths:\n /products:\n secure: invalid\n", + } { + t.Run(source, func(t *testing.T) { + var config WiretapConfiguration + require.Error(t, yaml.Unmarshal([]byte(source), &config)) + }) + } +} diff --git a/shared/error_test.go b/shared/error_test.go index bd76c4a..d8e6ea7 100644 --- a/shared/error_test.go +++ b/shared/error_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/pb33f/libopenapi-validator/errors" - "github.com/stretchr/testify/assert" + "github.com/pb33f/testify/assert" ) func sampleValidationErrors(messages ...string) []*WiretapValidationError { diff --git a/specs/conflicts_test.go b/specs/conflicts_test.go index c3c873b..aabad38 100644 --- a/specs/conflicts_test.go +++ b/specs/conflicts_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/pb33f/libopenapi" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" "github.com/pb33f/wiretap/shared" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestAnalyzeCrossSpecAmbiguous(t *testing.T) { diff --git a/specs/discovery_test.go b/specs/discovery_test.go index f6b3eeb..3a4e6b4 100644 --- a/specs/discovery_test.go +++ b/specs/discovery_test.go @@ -8,8 +8,8 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) func TestDiscoverSpecsFromDirectoryAndGlob(t *testing.T) { diff --git a/specs/report_console_test.go b/specs/report_console_test.go index 834e56a..d1fb26b 100644 --- a/specs/report_console_test.go +++ b/specs/report_console_test.go @@ -9,7 +9,7 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/assert" + "github.com/pb33f/testify/assert" ) func TestRenderConsoleUsesReadableConflictBlocks(t *testing.T) { diff --git a/validation/spec_router_test.go b/validation/spec_router_test.go index 7b79f45..772bca3 100644 --- a/validation/spec_router_test.go +++ b/validation/spec_router_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/pb33f/libopenapi" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/pb33f/testify/assert" + "github.com/pb33f/testify/require" ) func TestSpecRouterResolveSingleValidator(t *testing.T) { diff --git a/validation/validator_test.go b/validation/validator_test.go index ba38d3c..49e365d 100644 --- a/validation/validator_test.go +++ b/validation/validator_test.go @@ -13,7 +13,7 @@ import ( "github.com/pb33f/libopenapi" "github.com/pb33f/libopenapi/datamodel/high/v3" - "github.com/stretchr/testify/assert" + "github.com/pb33f/testify/assert" ) func TestNewValidator(t *testing.T) { From 69e1b2aad726dbc6ec75059a158a787fa4052c0d Mon Sep 17 00:00:00 2001 From: quobix Date: Wed, 7 Oct 2026 07:57:17 -0400 Subject: [PATCH 2/3] Upgrade libopenapi to v0.41.4 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b4defb3..309fd67 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598 github.com/pb33f/go-yaml v0.1.1 github.com/pb33f/harific v0.0.6 - github.com/pb33f/libopenapi v0.41.2 + github.com/pb33f/libopenapi v0.41.4 github.com/pb33f/libopenapi-validator v0.15.0 github.com/pb33f/ranch v0.9.0 github.com/pb33f/testify v0.1.1 diff --git a/go.sum b/go.sum index 38b418e..7e82533 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,8 @@ github.com/pb33f/jsonpath v0.8.4 h1:Yx7fxsKl8scgERL22WhKDs2c6gYNNUonPSWEG8Y194s= github.com/pb33f/jsonpath v0.8.4/go.mod h1:eO6mgdhw5RgzCxm/bXTi75VUs0/cCYJzdGjMCCUEI6M= github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641 h1:8D2syZhlMlHiB1bvm8o9Iapa72MhpgjeVaZvxN5rzfY= github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641/go.mod h1:oV64uhHNjEgvdiKALbOoXSQpt/to0HNTShFFjKzi5Mg= -github.com/pb33f/libopenapi v0.41.2 h1:7/KNzJJ0o5fC/tYxDYcHjziKfg0bkBpFUfI2UDbChAo= -github.com/pb33f/libopenapi v0.41.2/go.mod h1:mUldESjO6ownR1TCcywvoYp7e4v/bCdQyiiIqsgWne0= +github.com/pb33f/libopenapi v0.41.4 h1:8lwNho+cDC4Rsr3/ALSBxeft1dXU23WifW/Qp5pV5lI= +github.com/pb33f/libopenapi v0.41.4/go.mod h1:mUldESjO6ownR1TCcywvoYp7e4v/bCdQyiiIqsgWne0= github.com/pb33f/libopenapi-validator v0.15.0 h1:5wl7/tpyewqzZ7Y5/M9CZjojlaaK2DYKPZYGIvPq7SI= github.com/pb33f/libopenapi-validator v0.15.0/go.mod h1:P52RfZsY/+oWjRL52mpQ8Icwual6rtkJt1qOWdAe4eM= github.com/pb33f/ordered-map/v2 v2.3.2 h1:wDyaZ2Pv9QLh64X4utCeD5Zoi9nIv2aW3lwv172O5PQ= From 98af1d18e5d7d37b2606dde5a39cfbaa28653168 Mon Sep 17 00:00:00 2001 From: quobix Date: Sat, 17 Oct 2026 08:59:37 -0400 Subject: [PATCH 3/3] Update pb33f releases and protect concurrent mock generation --- go.mod | 21 ++++---- go.sum | 54 +++++++++---------- mock/mock_engine.go | 11 +++- mock/mock_engine_concurrency_test.go | 81 ++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 41 deletions(-) create mode 100644 mock/mock_engine_concurrency_test.go diff --git a/go.mod b/go.mod index 309fd67..9612cff 100644 --- a/go.mod +++ b/go.mod @@ -9,11 +9,11 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.3 github.com/json-iterator/go v1.1.12 - github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598 + github.com/pb33f/doctor v0.0.83 github.com/pb33f/go-yaml v0.1.1 github.com/pb33f/harific v0.0.6 - github.com/pb33f/libopenapi v0.41.4 - github.com/pb33f/libopenapi-validator v0.15.0 + github.com/pb33f/libopenapi v0.41.6 + github.com/pb33f/libopenapi-validator v0.16.1 github.com/pb33f/ranch v0.9.0 github.com/pb33f/testify v0.1.1 github.com/spf13/cobra v1.10.2 @@ -23,7 +23,7 @@ require ( require ( charm.land/bubbles/v2 v2.1.0 // indirect charm.land/bubbletea/v2 v2.0.7 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Masterminds/semver/v3 v3.5.0 // indirect github.com/a-h/templ v0.3.1020 // indirect github.com/alecthomas/chroma/v2 v2.27.0 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect @@ -31,7 +31,8 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect - github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641 // indirect + github.com/pb33f/jsonschema/v6 v6.0.3 // indirect + github.com/pb33f/libasyncapi v0.0.4 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/yuin/goldmark v1.8.2 // indirect github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc // indirect @@ -45,7 +46,7 @@ require ( charm.land/lipgloss/v2 v2.0.4 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad // indirect - github.com/buger/jsonparser v1.1.2 // indirect + github.com/buger/jsonparser v1.6.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/colorprofile v0.4.3 // indirect github.com/charmbracelet/ultraviolet v0.0.0-20260525132238-948f4557a654 // indirect @@ -58,8 +59,7 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 - github.com/go-openapi/jsonpointer v0.23.2 // indirect - github.com/go-openapi/swag/jsonname v0.26.1 // indirect + github.com/go-openapi/jsonpointer v1.0.2 // indirect github.com/go-stomp/stomp/v3 v3.1.3 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 github.com/hashicorp/golang-lru/v2 v2.0.7 @@ -76,7 +76,6 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/sagikazarmark/locafero v0.11.0 // indirect - github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect @@ -86,8 +85,8 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/net v0.56.0 // indirect - golang.org/x/sync v0.23.0 // indirect + golang.org/x/sync v0.24.0 // indirect golang.org/x/sys v0.46.0 // indirect - golang.org/x/text v0.38.0 // indirect + golang.org/x/text v0.42.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7e82533..a142474 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ charm.land/bubbletea/v2 v2.0.7 h1:7qw2tTAVar7m7klOPBYfTB0mniv/RuexsYwMRNxSeL0= charm.land/bubbletea/v2 v2.0.7/go.mod h1:DGW2q8gvzHnOpMpZTORs0aySVHCox5C+2Svk0fci1qs= charm.land/lipgloss/v2 v2.0.4 h1:lcPeVtcp23SNra7lHy8iYE4UC2aIipVQ47sbGyyxR5Q= charm.land/lipgloss/v2 v2.0.4/go.mod h1:0653x8epbZSzdDfO/XPS1a/uYPOBeSsCssOpJOqDzik= -github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= -github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE= +github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/a-h/templ v0.3.1020 h1:ypAT/L5ySWEnZ6Zft/5yfoWXYYkhFNvEFOeeqecg4tw= github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= @@ -24,8 +24,8 @@ github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad h1:3swAvbzgfaI github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad/go.mod h1:9+nBLYNWkvPcq9ep0owWUsPTLgL9ZXTsZWcCSVGGLJ0= github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= -github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk= -github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs= +github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q= @@ -67,12 +67,10 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-openapi/jsonpointer v0.23.2 h1:DK7R/3zAt4xTytxNkw7jARGPFI7rkaSsii58n8X45x0= -github.com/go-openapi/jsonpointer v0.23.2/go.mod h1:noUOckXtq7b4bVkqw0sbHKieq9uEZRN7p6EF/dalc4w= -github.com/go-openapi/swag/jsonname v0.26.1 h1:VReupaV6WxlAsCn0e4DUfgV6bPmINnPpyJDLqSfNPcE= -github.com/go-openapi/swag/jsonname v0.26.1/go.mod h1:OvdW6BoWoj33pTfi7x9vFrgmT+fk7aw0BRwvCE0YOuc= -github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= -github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/jsonpointer v1.0.2 h1:NbW7xT2b+l7x+JefiPGDsZWsrLk1ogrz4AHK1TTzMt8= +github.com/go-openapi/jsonpointer v1.0.2/go.mod h1:N0rI4MbNKD7xAFTiHtB+5Nhrg2j/wwYg7m7Fmb4/jk8= +github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho= +github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak= github.com/go-stomp/stomp/v3 v3.1.3 h1:5/wi+bI38O1Qkf2cc7Gjlw7N5beHMWB/BxpX+4p/MGI= github.com/go-stomp/stomp/v3 v3.1.3/go.mod h1:ztzZej6T2W4Y6FlD+Tb5n7HQP3/O5UNQiuC169pIp10= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= @@ -126,20 +124,22 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598 h1:DjkKy1l+Hy6sPFhNor4g97L0LR/3sj5EY6eL9Gmvvqw= -github.com/pb33f/doctor v0.0.82-0.20260928215936-a5a9b7e66598/go.mod h1:QnCkf+zudvwyO8uFfVv9WJOeRbFzojy6e/3qvnL3pkE= +github.com/pb33f/doctor v0.0.83 h1:YhGt/cHQzClSgL9VyPibsuQdxwr9F8WMzxPfKHnj6Wg= +github.com/pb33f/doctor v0.0.83/go.mod h1:J+Ox7dWjOtVv45A/Ruj38CV9e51HFi5SuGWySu90DKs= github.com/pb33f/go-yaml v0.1.1 h1:yWGmhVdwzionRnSc/hEJwcfq6PaZL2QdYzyReXBbX7Q= github.com/pb33f/go-yaml v0.1.1/go.mod h1:QvWdkHP5VjFYAeHMQUkaPQqREaQnBNOXmWzAjNrnSdo= github.com/pb33f/harific v0.0.6 h1:jRll6fYIg1YbHmt/uQwWQ2tGXsQFPOaosE7A+HHo/lA= github.com/pb33f/harific v0.0.6/go.mod h1:lJrqd81pq/OhthWTJQduRxidldufqIkMQTwE/XZWg+M= github.com/pb33f/jsonpath v0.8.4 h1:Yx7fxsKl8scgERL22WhKDs2c6gYNNUonPSWEG8Y194s= github.com/pb33f/jsonpath v0.8.4/go.mod h1:eO6mgdhw5RgzCxm/bXTi75VUs0/cCYJzdGjMCCUEI6M= -github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641 h1:8D2syZhlMlHiB1bvm8o9Iapa72MhpgjeVaZvxN5rzfY= -github.com/pb33f/libasyncapi v0.0.3-0.20260928174225-e79f2595d641/go.mod h1:oV64uhHNjEgvdiKALbOoXSQpt/to0HNTShFFjKzi5Mg= -github.com/pb33f/libopenapi v0.41.4 h1:8lwNho+cDC4Rsr3/ALSBxeft1dXU23WifW/Qp5pV5lI= -github.com/pb33f/libopenapi v0.41.4/go.mod h1:mUldESjO6ownR1TCcywvoYp7e4v/bCdQyiiIqsgWne0= -github.com/pb33f/libopenapi-validator v0.15.0 h1:5wl7/tpyewqzZ7Y5/M9CZjojlaaK2DYKPZYGIvPq7SI= -github.com/pb33f/libopenapi-validator v0.15.0/go.mod h1:P52RfZsY/+oWjRL52mpQ8Icwual6rtkJt1qOWdAe4eM= +github.com/pb33f/jsonschema/v6 v6.0.3 h1:TMIkE1xCmnF8Cy+anIBs+r4ASfGtwzfFxYsrrIn0wSU= +github.com/pb33f/jsonschema/v6 v6.0.3/go.mod h1:cYPShw+w1Jrs0YgpE2rk1FLdIAsKfWcotv/54G6ddFo= +github.com/pb33f/libasyncapi v0.0.4 h1:kurDGLmA0ZQ3g0fOpt1mz6CNufcsO1LxTzSgvniVCyM= +github.com/pb33f/libasyncapi v0.0.4/go.mod h1:4wGvNgmTAIwBManrs2LpD/Dfk0IFiJvOuP/k9oxRUxU= +github.com/pb33f/libopenapi v0.41.6 h1:W1X/5rOaAk3/Mjwrt+DHaiJO6buhruKWrbQ+pumONkA= +github.com/pb33f/libopenapi v0.41.6/go.mod h1:mUldESjO6ownR1TCcywvoYp7e4v/bCdQyiiIqsgWne0= +github.com/pb33f/libopenapi-validator v0.16.1 h1:XWEIFj7yU5hG6Nf/ItVL3ZNXL1lb8HIXypA/2dVe3z4= +github.com/pb33f/libopenapi-validator v0.16.1/go.mod h1:99hR+hRsOw8vg7UFL/72UxiMp+nud1O6G9N/qWLrMQA= github.com/pb33f/ordered-map/v2 v2.3.2 h1:wDyaZ2Pv9QLh64X4utCeD5Zoi9nIv2aW3lwv172O5PQ= github.com/pb33f/ordered-map/v2 v2.3.2/go.mod h1:1OhFrXu3OYw3kM+FXF+Ug3ugmmZ9LE8z0JfQMLvtV0w= github.com/pb33f/ranch v0.9.0 h1:3alq+6o/fedVx26a0TCir4To2IniAvFsgNHwt3I1tIY= @@ -160,8 +160,6 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc= github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= @@ -204,8 +202,8 @@ golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAf golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4= -golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ= +golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c= +golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -220,8 +218,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk= -golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= +golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -247,15 +245,15 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= -golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= +golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI= +golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8= -golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= +golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= +golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/mock/mock_engine.go b/mock/mock_engine.go index f924857..4d4580b 100644 --- a/mock/mock_engine.go +++ b/mock/mock_engine.go @@ -26,6 +26,7 @@ type ResponseMockEngine struct { doc *v3.Document validator validation.HttpValidator mockEngine *renderer.MockGenerator + mockMu sync.Mutex // protects the renderer's shared random generator pretty bool validationOpts *config.ValidationOptions hardValidation bool // when true, reject requests with validation errors @@ -297,6 +298,12 @@ func (rme *ResponseMockEngine) extractPreferred(request *http.Request) string { return request.Header.Get(helpers.Preferred) } +func (rme *ResponseMockEngine) generateMock(mediaType *v3.MediaType, preferred string) ([]byte, error) { + rme.mockMu.Lock() + defer rme.mockMu.Unlock() + return rme.mockEngine.GenerateMock(mediaType, preferred) +} + func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int, error) { // get path, not valid? return 404 @@ -320,7 +327,7 @@ func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int, if err != nil { mt, _ := rme.findBestMediaTypeMatch(operation, request, []string{"401"}) if mt != nil { - mock, mockErr := rme.mockEngine.GenerateMock(mt, rme.extractPreferred(request)) + mock, mockErr := rme.generateMock(mt, rme.extractPreferred(request)) if mockErr != nil { return rme.buildError( 500, @@ -404,7 +411,7 @@ func (rme *ResponseMockEngine) runWorkflow(request *http.Request) ([]byte, int, ), 415, nil } - mock, mockErr := rme.mockEngine.GenerateMock(mt, preferred) + mock, mockErr := rme.generateMock(mt, preferred) if mockErr != nil { return rme.buildError( 422, diff --git a/mock/mock_engine_concurrency_test.go b/mock/mock_engine_concurrency_test.go new file mode 100644 index 0000000..9dce615 --- /dev/null +++ b/mock/mock_engine_concurrency_test.go @@ -0,0 +1,81 @@ +// Copyright 2026 Princess B33f Heavy Industries / Dave Shanley +// SPDX-License-Identifier: AGPL + +package mock + +import ( + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "testing" + + "github.com/google/uuid" + "github.com/pb33f/libopenapi" + "github.com/pb33f/testify/require" +) + +func TestGenerateResponseConcurrentUUIDs(t *testing.T) { + const spec = `openapi: 3.0.3 +info: + title: Concurrent UUID mocks + version: 1.0.0 +components: + securitySchemes: + token: + type: http + scheme: bearer +paths: + /ids: + get: + security: + - token: [] + responses: + '200': &response + description: Generated ID + content: + application/json: + schema: + type: string + format: uuid + '401': *response +` + doc, err := libopenapi.NewDocument([]byte(spec)) + require.NoError(t, err) + model, err := doc.BuildV3Model() + require.NoError(t, err) + engine := NewMockEngine(&model.Model, false, true) + + checkResponse := func(t *testing.T, authorized bool) { + t.Helper() + request := httptest.NewRequest(http.MethodGet, "http://example.com/ids", nil) + request.Header.Set("Content-Type", "application/json") + if authorized { + request.Header.Set("Authorization", "Bearer test-token") + } + body, status, err := engine.GenerateResponse(request) + if authorized { + require.NoError(t, err) + require.Equal(t, http.StatusOK, status) + } else { + require.Error(t, err) + require.Equal(t, http.StatusUnauthorized, status) + } + var id string + require.NoError(t, json.Unmarshal(body, &id)) + _, err = uuid.Parse(id) + require.NoError(t, err) + } + + // Warm validation and schema caches before exercising the shared renderer. + checkResponse(t, true) + checkResponse(t, false) + for worker := range 8 { + t.Run(fmt.Sprintf("worker-%d", worker), func(t *testing.T) { + t.Parallel() + for request := range 32 { + checkResponse(t, (worker+request)%2 == 0) + } + }) + } +}