Serghei Iakovlev
03/12/2023, 1:43 AM"response": {
...
"headers": {
"Last-Modified": "Sun, 12 Mar 2023 01:21:35 GMT"
},
...
"matchingRules": {
"$.headers.Last-Modified": {
"match": "regex",
"regex": "^[A-Za-z]{3},\\s\\d{2}\\s[A-Za-z]{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\sGMT$"
},
...
}
}
...
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
I think the regular expression is correct, since I have tested it many times using various tools:
# The date and time format used in the Last-Modified header according to
# RFC 7231 is described in section 7.1.1.1.
#
# Examples:
#
# Last-Modified: Mon, 12 Feb 1996 11:36:28 GMT
# Last-Modified: Sat, 11 Mar 2023 21:56:41 GMT
#
LAST_MODIFIED_REGEX = r'^[A-Za-z]{3},\s\d{2}\s[A-Za-z]{3}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT$'
But when I try to verify it, it somehow compares for an exact match, without using a regular expression:
Pending Failures:
1) Verifying a pact between ProductServiceClient and ProductService Given there is a product with ID 1 - a request for a product
1.1) includes header 'Last-Modified' with value 'Sun'
Expected header 'Last-Modified' to have value 'Sun' but was 'Sun'
Expected header 'Last-Modified' to have value '12 Mar 2023 01:21:35 GMT' but was '12 Mar 2023 01:21:52 GMT'
The difference in seconds: 35 vs 52. And it fails because in pact I have
• “Sun, 12 Mar 2023 0121*35* GMT”
but providers returns
• “Sun, 12 Mar 2023 0121*52* GMT”
I use the same approach ( using regular expression test) for other headers like ETag, Content-Type and they are fine, verification passes as expected. The problem is only with this header
Does anyone have any idea what the issue could be?
Of course, I can create the required date on the provider side using request to /_pact/provider_states. However, in this case all my efforts will be to provide an exact match, and I would like to use the pattern hereTimothy Jones
03/12/2023, 2:53 AM,. Looks like a bug in pact-reference, probably. What provider verification are you using?Timothy Jones
03/12/2023, 2:55 AMTimothy Jones
03/12/2023, 2:55 AMSerghei Iakovlev
03/12/2023, 7:41 AMSerghei Iakovlev
03/12/2023, 7:43 AMSerghei Iakovlev
03/12/2023, 8:17 AMTimothy Jones
03/12/2023, 8:18 AMTimothy Jones
03/12/2023, 8:19 AMTimothy Jones
03/12/2023, 8:20 AMMatt (pactflow.io / pact-js / pact-go)