Skip to content

Commit f6fa6e3

Browse files
committed
Squashed 'compatibility-suite/pact-compatibility-suite/' changes from 416f3a64d..cc76eac3c
cc76eac3c fix: Never coerce number values from strings when dealing with bodies b8e9a2aa0 Merge pull request #11 from pact-foundation/feat/use-consistent-fixture-headers 65f86c442 feat: use consistent fixture headers 870c4790f chore: Configure Renovate (#9) 4a3c411cd chore: add smartbear supported jira integration git-subtree-dir: compatibility-suite/pact-compatibility-suite git-subtree-split: cc76eac3ca649e863c9d28aad572605922545759
1 parent fa1f85f commit f6fa6e3

File tree

9 files changed

+142
-29
lines changed

9 files changed

+142
-29
lines changed

.github/renovate.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:best-practices"],
4+
"prHourlyLimit": 0,
5+
"prConcurrentLimit": 0,
6+
"automerge": true
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: SmartBear Supported Issue Label Added
2+
3+
on:
4+
issues:
5+
types:
6+
- labeled
7+
8+
jobs:
9+
call-workflow:
10+
uses: pact-foundation/.github/.github/workflows/smartbear-issue-label-added.yml@master
11+
secrets: inherit

features/V1/http_provider.feature

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ Feature: Basic HTTP provider
118118

119119
Scenario: Verifies the response status code
120120
Given a provider is started that returns the response from interaction 1, with the following changes:
121-
| status |
122-
| 400 |
121+
| response |
122+
| 400 |
123123
And a Pact file for interaction 1 is to be verified
124124
When the verification is run
125125
Then the verification will NOT be successful
126126
And the verification results will contain a "Response status did not match" error
127127

128128
Scenario: Verifies the response headers
129-
Given a provider is started that returns the response from interaction 1, with the following changes:
130-
| headers |
129+
Given a provider is started that returns the response from interaction 5, with the following changes:
130+
| response headers |
131131
| 'X-TEST: Compatibility' |
132132
And a Pact file for interaction 5 is to be verified
133133
When the verification is run
@@ -142,7 +142,7 @@ Feature: Basic HTTP provider
142142

143143
Scenario: Response with plain text body (negative case)
144144
Given a provider is started that returns the response from interaction 6, with the following changes:
145-
| body |
145+
| response body |
146146
| Hello Compatibility Suite! |
147147
And a Pact file for interaction 6 is to be verified
148148
When the verification is run
@@ -157,7 +157,7 @@ Feature: Basic HTTP provider
157157

158158
Scenario: Response with JSON body (negative case)
159159
Given a provider is started that returns the response from interaction 1, with the following changes:
160-
| body |
160+
| response body |
161161
| JSON: { "one": 100, "two": "b" } |
162162
And a Pact file for interaction 1 is to be verified
163163
When the verification is run
@@ -172,7 +172,7 @@ Feature: Basic HTTP provider
172172

173173
Scenario: Response with XML body (negative case)
174174
Given a provider is started that returns the response from interaction 7, with the following changes:
175-
| body |
175+
| response body |
176176
| XML: <?xml version="1.0" encoding="UTF-8" ?><values><one>A</one></values> |
177177
And a Pact file for interaction 7 is to be verified
178178
When the verification is run
@@ -187,7 +187,7 @@ Feature: Basic HTTP provider
187187

188188
Scenario: Response with binary body (negative case)
189189
Given a provider is started that returns the response from interaction 8, with the following changes:
190-
| body |
190+
| response body |
191191
| file: spider.jpg |
192192
And a Pact file for interaction 8 is to be verified
193193
When the verification is run
@@ -202,7 +202,7 @@ Feature: Basic HTTP provider
202202

203203
Scenario: Response with form post body (negative case)
204204
Given a provider is started that returns the response from interaction 9, with the following changes:
205-
| body |
205+
| response body |
206206
| a=1&b=2&c=33&d=4 |
207207
And a Pact file for interaction 9 is to be verified
208208
When the verification is run
@@ -217,7 +217,7 @@ Feature: Basic HTTP provider
217217

218218
Scenario: Response with multipart body (negative case)
219219
Given a provider is started that returns the response from interaction 10, with the following changes:
220-
| body |
220+
| response body |
221221
| file: multipart2-body.xml |
222222
And a Pact file for interaction 10 is to be verified
223223
When the verification is run

features/V2/http_provider.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Feature: Basic HTTP provider
1010

1111
Scenario: Supports matching rules for the response headers (positive case)
1212
Given a provider is started that returns the response from interaction 1, with the following changes:
13-
| headers |
14-
| 'X-TEST: 1000' |
13+
| response headers |
14+
| 'X-TEST: 1000' |
1515
And a Pact file for interaction 1 is to be verified
1616
When the verification is run
1717
Then the verification will be successful
1818

1919
Scenario: Supports matching rules for the response headers (negative case)
2020
Given a provider is started that returns the response from interaction 1, with the following changes:
21-
| headers |
21+
| response headers |
2222
| 'X-TEST: 123ABC' |
2323
And a Pact file for interaction 1 is to be verified
2424
When the verification is run
@@ -27,15 +27,15 @@ Feature: Basic HTTP provider
2727

2828
Scenario: Verifies the response body (positive case)
2929
Given a provider is started that returns the response from interaction 2, with the following changes:
30-
| body |
30+
| response body |
3131
| JSON: { "one": "100", "two": "b" } |
3232
And a Pact file for interaction 2 is to be verified
3333
When the verification is run
3434
Then the verification will be successful
3535

3636
Scenario: Verifies the response body (negative case)
3737
Given a provider is started that returns the response from interaction 2, with the following changes:
38-
| body |
38+
| response body |
3939
| JSON: { "one": 100, "two": "b" } |
4040
And a Pact file for interaction 2 is to be verified
4141
When the verification is run

features/V3/matching_rules.feature

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,31 @@ Feature: V3 era Matching Rules
6565
When the requests are compared to the expected one
6666
Then the comparison should be OK
6767

68+
Scenario: Supports a number type matcher where it is acceptable to coerce values from string form
69+
Given an expected request configured with the following:
70+
| query | headers | matching rules |
71+
| a=1234 | 'X-A: 1234' | number-type-matcher-v3.json |
72+
And the following requests are received:
73+
| query | headers | desc |
74+
| a=100 | 'X-A: 100' | Integer number |
75+
| a=100.2 | 'X-A: 100.4' | Floating point number |
76+
When the requests are compared to the expected one
77+
Then the comparison should be OK
78+
6879
Scenario: Supports a number type matcher (negative case)
6980
Given an expected request configured with the following:
7081
| body | matching rules |
7182
| file: basic.json | number-type-matcher-v3.json |
7283
And the following requests are received:
73-
| body | desc |
74-
| JSON: { "one": true, "two": "b" } | Boolean |
75-
| JSON: { "one": "100X01", "two": "b" } | String |
84+
| body | desc |
85+
| JSON: { "one": true, "two": "b" } | Boolean |
86+
| JSON: { "one": "100X01", "two": "b" } | String |
87+
| JSON: { "one": "100", "two": "b" } | Number in string form is not acceptable in bodies |
7688
When the requests are compared to the expected one
7789
Then the comparison should NOT be OK
7890
And the mismatches will contain a mismatch with error "$.one" -> "Expected true (Boolean) to be a number"
7991
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100X01' (String) to be a number"
92+
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100' (String) to be a number"
8093

8194
Scenario: Supports an integer type matcher, no digits after the decimal point (positive case)
8295
Given an expected request configured with the following:
@@ -85,7 +98,16 @@ Feature: V3 era Matching Rules
8598
And the following requests are received:
8699
| body | desc |
87100
| JSON: { "one": 100, "two": "b" } | Integer number |
88-
| JSON: { "one": "100", "two": "b" } | String representation of an integer |
101+
When the requests are compared to the expected one
102+
Then the comparison should be OK
103+
104+
Scenario: Supports an integer type matcher where it is acceptable to coerce values from string form
105+
Given an expected request configured with the following:
106+
| query | headers | matching rules |
107+
| a=1234 | 'X-A: 1234' | number-type-matcher-v3.json |
108+
And the following requests are received:
109+
| query | headers | desc |
110+
| a=100 | 'X-A: 100' | Integer number |
89111
When the requests are compared to the expected one
90112
Then the comparison should be OK
91113

@@ -94,15 +116,17 @@ Feature: V3 era Matching Rules
94116
| body | matching rules |
95117
| file: basic.json | integer-type-matcher-v3.json |
96118
And the following requests are received:
97-
| body | desc |
98-
| JSON: { "one": [], "two": "b" } | Array |
99-
| JSON: { "one": 100.1, "two": "b" } | Floating point number |
100-
| JSON: { "one": "100X01", "two": "b" } | Not a string representation of an integer |
119+
| body | desc |
120+
| JSON: { "one": [], "two": "b" } | Array |
121+
| JSON: { "one": 100.1, "two": "b" } | Floating point number |
122+
| JSON: { "one": "100X01", "two": "b" } | String |
123+
| JSON: { "one": "100", "two": "b" } | String representation of an integer is not acceptable in bodies |
101124
When the requests are compared to the expected one
102125
Then the comparison should NOT be OK
103126
And the mismatches will contain a mismatch with error "$.one" -> "Expected [] (Array) to be an integer"
104127
And the mismatches will contain a mismatch with error "$.one" -> "Expected 100.1 (Decimal) to be an integer"
105128
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100X01' (String) to be an integer"
129+
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100' (String) to be an integer"
106130

107131
Scenario: Supports an decimal type matcher, must have significant digits after the decimal point (positive case)
108132
Given an expected request configured with the following:
@@ -111,7 +135,6 @@ Feature: V3 era Matching Rules
111135
And the following requests are received:
112136
| body | desc |
113137
| JSON: { "one": 100.1234, "two": "b" } | Floating point number |
114-
| JSON: { "one": "100.1234", "two": "b" } | String representation of a floating point number |
115138
When the requests are compared to the expected one
116139
Then the comparison should be OK
117140

@@ -120,15 +143,27 @@ Feature: V3 era Matching Rules
120143
| body | matching rules |
121144
| file: basic.json | decimal-type-matcher-v3.json |
122145
And the following requests are received:
123-
| body | desc |
124-
| JSON: { "one": null, "two": "b" } | Null |
125-
| JSON: { "one": 100, "two": "b" } | Integer number |
126-
| JSON: { "one": "100X01", "two": "b" } | Not a string representation of an decimal number |
146+
| body | desc |
147+
| JSON: { "one": null, "two": "b" } | Null |
148+
| JSON: { "one": 100, "two": "b" } | Integer number |
149+
| JSON: { "one": "100X01", "two": "b" } | String value |
150+
| JSON: { "one": "100.1234", "two": "b" } | String representation of a floating point number is not acceptable in bodies |
127151
When the requests are compared to the expected one
128152
Then the comparison should NOT be OK
129153
And the mismatches will contain a mismatch with error "$.one" -> "Expected null (Null) to be a decimal number"
130154
And the mismatches will contain a mismatch with error "$.one" -> "Expected 100 (Integer) to be a decimal number"
131155
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100X01' (String) to be a decimal number"
156+
And the mismatches will contain a mismatch with error "$.one" -> "Expected '100.1234' (String) to be a decimal number"
157+
158+
Scenario: Supports a decimal type matcher where it is acceptable to coerce values from string form
159+
Given an expected request configured with the following:
160+
| query | headers | matching rules |
161+
| a=1234.0 | 'X-A: 1234.0' | number-type-matcher-v3.json |
162+
And the following requests are received:
163+
| query | headers | desc |
164+
| a=100.2 | 'X-A: 100.4' | Floating point number |
165+
When the requests are compared to the expected one
166+
Then the comparison should be OK
132167

133168
Scenario: Supports a null matcher (positive case)
134169
Given an expected request configured with the following:

features/V4/http_provider.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Feature: HTTP provider
99

1010
Scenario: Verifying a pending HTTP interaction
1111
Given a provider is started that returns the response from interaction 1, with the following changes:
12-
| body |
12+
| response body |
1313
| file: basic2.json |
1414
And a Pact file for interaction 1 is to be verified, but is marked pending
1515
When the verification is run

fixtures/decimal-type-matcher-v3.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@
77
"match": "decimal"
88
}
99
]
10+
},
11+
"query": {
12+
"a": {
13+
"combine": "AND",
14+
"matchers": [
15+
{
16+
"match": "decimal"
17+
}
18+
]
19+
}
20+
},
21+
"header": {
22+
"X-A": {
23+
"combine": "AND",
24+
"matchers": [
25+
{
26+
"match": "decimal"
27+
}
28+
]
29+
}
1030
}
1131
}
1232
}

fixtures/integer-type-matcher-v3.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,25 @@
88
}
99
]
1010
}
11+
},
12+
"query": {
13+
"a": {
14+
"combine": "AND",
15+
"matchers": [
16+
{
17+
"match": "integer"
18+
}
19+
]
20+
}
21+
},
22+
"header": {
23+
"X-A": {
24+
"combine": "AND",
25+
"matchers": [
26+
{
27+
"match": "integer"
28+
}
29+
]
30+
}
1131
}
1232
}

fixtures/number-type-matcher-v3.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,25 @@
88
}
99
]
1010
}
11+
},
12+
"query": {
13+
"a": {
14+
"combine": "AND",
15+
"matchers": [
16+
{
17+
"match": "number"
18+
}
19+
]
20+
}
21+
},
22+
"header": {
23+
"X-A": {
24+
"combine": "AND",
25+
"matchers": [
26+
{
27+
"match": "number"
28+
}
29+
]
30+
}
1131
}
1232
}

0 commit comments

Comments
 (0)