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

Header matching fails due to terminating on comma #353

Closed
alexeits opened this issue Jan 2, 2024 · 3 comments
Closed

Header matching fails due to terminating on comma #353

alexeits opened this issue Jan 2, 2024 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@alexeits
Copy link

alexeits commented Jan 2, 2024

Given the following pact JSON:

"headers": {
"Content-Type": "application/json",
"Set-Cookie": "auth=fake-token; HttpOnly"
},
"body": {},
"matchingRules": {
"$.headers.Content-Type": {
  "match": "regex",
  "regex": "^application\\/json(;|$)"
},
"$.headers.Set-Cookie": {
  "match": "regex",
  "regex": "^auth=[^;]+;.*\\s[Hh]ttp[Oo]nly(?:;|$)"
}

Complete JSON: agent-desktop-impersonation_tokens.json

and the provider responding with:

auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDQyMTczMDQsImlhdCI6MTcwNDIxMDEwNCwiYWN0aXZhdGVkQXQiOiIyMDI0LTAxLTAyVDE1OjQxOjQ1Ljg0NVoiLCJ1c2VySWQiOiJleGFtcGxlVXNlcklkIiwib3JnSWQiOiJleGFtcGxlT3JnSWQiLCJyb2xlSWRzIjpbImFnZW50Il0sInNhZ2FuVXNlciI6ImFkbWluQGV4YW1wbGUub3JnIiwic2Vzc2lvbiI6eyJpZCI6IkY2QklCd2xtUXNTckJvQ01CX0pEZXcifX0.kNXCzxDQjGEmEwEAoLC1JLLUYPTQjWgHheLlhEPlOc0; Path=/; Expires=Tue, 02 Jan 2024 17:41:44 GMT; Max-Age=7198; HttpOnly

which matches the Set-Cookie regex: https://regex101.com/r/bTjvJT/1,

the verification fails with:

1) Verifying a pact between agent-desktop and impersonation_tokens Given agent user exists - start impersonation
    1.1) includes header 'Set-Cookie' with value 'auth=fake-token; HttpOnly'
           Expected header 'Set-Cookie' to have value 'auth=fake-token; HttpOnly' but was 'auth=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDQyMTczMDQsImlhdCI6MTcwNDIxMDEwNCwiYWN0aXZhdGVkQXQiOiIyMDI0LTAxLTAyVDE1OjQxOjQ1Ljg0NVoiLCJ1c2VySWQiOiJleGFtcGxlVXNlcklkIiwib3JnSWQiOiJleGFtcGxlT3JnSWQiLCJyb2xlSWRzIjpbImFnZW50Il0sInNhZ2FuVXNlciI6ImFkbWluQGV4YW1wbGUub3JnIiwic2Vzc2lvbiI6eyJpZCI6IkY2QklCd2xtUXNTckJvQ01CX0pEZXcifX0.kNXCzxDQjGEmEwEAoLC1JLLUYPTQjWgHheLlhEPlOc0; Path=/; Expires=Tue'

Notice that the match is terminated on the comma after "Tue".

@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jan 17, 2024
@YOU54F
Copy link
Member

YOU54F commented Jun 9, 2024

This should be resolved in libpact_ffi-v0.4.13 or higher.

Please let us know if this is still an issue

@YOU54F YOU54F closed this as completed Jun 9, 2024
@alexeits
Copy link
Author

@YOU54F: I confirm that it's resolved. We are currently on 0.4.16 and no longer see this issue.

@YOU54F
Copy link
Member

YOU54F commented Jun 10, 2024

appreciate the confirmation @alexeits!

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

3 participants