Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inexact matchers are expecting exact match in 2.x.x branch #281

Closed
jasonltaylor opened this issue Mar 10, 2023 · 5 comments
Closed

inexact matchers are expecting exact match in 2.x.x branch #281

jasonltaylor opened this issue Mar 10, 2023 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jasonltaylor
Copy link

Software versions

  • OS: Ubuntu Linux
  • Consumer Pact library: Pact Go v2.0.0-beta.17.0.20221222235702-6e805a539d1b
  • Provider Pact library: Pact Go v2.0.0-beta.17.0.20221222235702-6e805a539d1b
  • Golang Version: go version go1.19.2 linux/amd64
  • Golang environment:
    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/home/dev/.cache/go-build"
    GOENV="/home/dev/.config/go/env"
    GOEXE=""
    GOEXPERIMENT=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOINSECURE=""
    GOMODCACHE="/home/dev/go/pkg/mod"
    GONOPROXY="github.hpe.com"
    GONOSUMDB="github.hpe.com"
    GOOS="linux"
    GOPATH="/home/dev/go"
    GOPRIVATE="github.hpe.com"
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/usr/local/go"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
    GOVCS=""
    GOVERSION="go1.19.2"
    GCCGO="gccgo"
    GOAMD64="v1"
    AR="ar"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD="/home/dev/ws/sc-authz/go.mod"
    GOWORK=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4109696144=/tmp/go-build -gno-record-gcc-switches"

Expected behaviour

The inexact machers (e.g. regex, like, etc) should allow inexact matches. For example,

Header("Authorization", Like("Bearer 1234"))

should accept "Bearer 4321".

Actual behaviour

Fails when inexact:

consumer_v2_test.go:106:
        Pact Verification Failed for: TestConsumerV2_Match

                Diff:
2023/03/10 16:16:52 [INFO] pact validation failed, errors: 
                        Mismatch with header 'Authorization': Expected 'Bearer 1234' to be equal to 'Bearer 4321'
:                       expected:        Bearer 1234
                        actual:          Bearer 4321

and v3:

consumer_v3_test.go:86:
        Pact Verification Failed for: TestConsumerV3

                Diff:
2023/03/10 16:16:52 [INFO] pact validation failed, errors: 
                        Mismatch with header 'Authorization': Expected 'Bearer 1234' to be equal to 'Bearer 4321'
:                       expected:        Bearer 1234
                        actual:          Bearer 4321

Steps to reproduce

Update sample test code to pass a non-exact match:

$ git diff
diff --git a/examples/consumer_v2_test.go b/examples/consumer_v2_test.go
index b800920..b569940 100644
--- a/examples/consumer_v2_test.go
+++ b/examples/consumer_v2_test.go
@@ -196,7 +193,7 @@ var rawTest = func(query string) func(config consumer.MockServerConfig) error {
                // of application/json. If you don't explicitly set the content-type, you
                // will get a mismatch during Verification.
                req.Header.Set("Content-Type", "application/json")
-               req.Header.Set("Authorization", "Bearer 1234")
+               req.Header.Set("Authorization", "Bearer 4321")

Relevent log files

Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).

@mefellows mefellows added bug Indicates an unexpected problem or unintended behavior triage labels May 8, 2023
@github-actions
Copy link

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-1034). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

@mefellows
Copy link
Member

I have tested this with the latest version, and the tests pass. Mind checking you have the latest FFI installed (should be 0.4.3 at the time of this posting)?

@mefellows
Copy link
Member

I've also just bumped the version of the FFI in the latest to 0.4.4 which also contains a (not entirely complete) fix for #230

@jasonltaylor
Copy link
Author

verified with FFI 0.4.5

@mefellows
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants