Skip to content

Commit

Permalink
Merge commit 'f895d548c4a19dcc44706cea26f2e79afbd6eb7a'
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jul 13, 2023
2 parents 27498a1 + f895d54 commit 3c10367
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Feature: Basic HTTP consumer

Background:
Given the following HTTP interactions have been defined:
| method | path | query | headers | body | response | response content | response body |
| GET | /basic | | | | 200 | application/json | file: basic.json |
| GET | /with_params | a=1&b=2 | | | 200 | | |
| GET | /with_headers | | 'X-TEST: Compatibility' | | 200 | | |
| PUT | /basic | | | file: basic.json | 200 | | |
| PUT | /plain | | | file: text-body.xml | 200 | | |
| PUT | /xml | | | file: xml-body.xml | 200 | | |
| PUT | /bin | | | file: rat.jpg | 200 | | |
| PUT | /form | | | file: form-post-body.xml | 200 | | |
| PUT | /multipart | | | file: multipart-body.xml | 200 | | |
| No | method | path | query | headers | body | response | response content | response body |
| 1 | GET | /basic | | | | 200 | application/json | file: basic.json |
| 2 | GET | /with_params | a=1&b=2 | | | 200 | | |
| 3 | GET | /with_headers | | 'X-TEST: Compatibility' | | 200 | | |
| 4 | PUT | /basic | | | file: basic.json | 200 | | |
| 5 | PUT | /plain | | | file: text-body.xml | 200 | | |
| 6 | PUT | /xml | | | file: xml-body.xml | 200 | | |
| 7 | PUT | /bin | | | file: rat.jpg | 200 | | |
| 8 | PUT | /form | | | file: form-post-body.xml | 200 | | |
| 9 | PUT | /multipart | | | file: multipart-body.xml | 200 | | |

Scenario: When all requests are made to the mock server
When the mock server is started with interaction 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ Feature: Basic HTTP provider

Background:
Given the following HTTP interactions have been defined:
| method | path | query | headers | body | response | response headers | response content | response body |
| GET | /basic | | | | 200 | | application/json | file: basic.json |
| GET | /with_params | a=1&b=2 | | | 200 | | | |
| GET | /with_headers | | 'X-TEST: Compatibility' | | 200 | | | |
| PUT | /basic | | | file: basic.json | 200 | | | |
| GET | /basic | | | | 200 | 'X-TEST: Something' | application/json | file: basic.json |
| No | method | path | query | headers | body | response | response headers | response content | response body |
| 1 | GET | /basic | | | | 200 | | application/json | file: basic.json |
| 2 | GET | /with_params | a=1&b=2 | | | 200 | | | |
| 3 | GET | /with_headers | | 'X-TEST: Compatibility' | | 200 | | | |
| 4 | PUT | /basic | | | file: basic.json | 200 | | | |
| 5 | GET | /basic | | | | 200 | 'X-TEST: Something' | application/json | file: basic.json |
| 6 | GET | /plain | | | | 200 | | | file: text-body.xml |
| 7 | GET | /xml | | | | 200 | | | file: xml-body.xml |
| 8 | GET | /bin | | | | 200 | | | file: rat.jpg |
| 9 | GET | /form | | | | 200 | | | file: form-post-body.xml |
| 10 | GET | /multi | | | | 200 | | | file: multipart-body.xml |

Scenario: Verifying a simple HTTP request
Given a provider is started that returns the response from interaction 1
Expand Down Expand Up @@ -129,11 +134,92 @@ Feature: Basic HTTP provider
Then the verification will NOT be successful
And the verification results will contain a "Headers had differences" error

Scenario: Verifies the response body
Scenario: Response with plain text body (positive case)
Given a provider is started that returns the response from interaction 6
And a Pact file for interaction 6 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with plain text body (negative case)
Given a provider is started that returns the response from interaction 6, with the following changes:
| body |
| Hello Compatibility Suite! |
And a Pact file for interaction 6 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error

Scenario: Response with JSON body (positive case)
Given a provider is started that returns the response from interaction 1
And a Pact file for interaction 1 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with JSON body (negative case)
Given a provider is started that returns the response from interaction 1, with the following changes:
| body |
| JSON: { "one": 100, "two": "b" } |
And a Pact file for interaction 1 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error

Scenario: Response with XML body (positive case)
Given a provider is started that returns the response from interaction 7
And a Pact file for interaction 7 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with XML body (negative case)
Given a provider is started that returns the response from interaction 7, with the following changes:
| body |
| XML: <?xml version="1.0" encoding="UTF-8" ?><values><one>A</one></values> |
And a Pact file for interaction 7 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error

Scenario: Response with binary body (positive case)
Given a provider is started that returns the response from interaction 8
And a Pact file for interaction 8 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with binary body (negative case)
Given a provider is started that returns the response from interaction 8, with the following changes:
| body |
| file: spider.jpg |
And a Pact file for interaction 8 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error

Scenario: Response with form post body (positive case)
Given a provider is started that returns the response from interaction 9
And a Pact file for interaction 9 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with form post body (negative case)
Given a provider is started that returns the response from interaction 9, with the following changes:
| body |
| a=1&b=2&c=33&d=4 |
And a Pact file for interaction 9 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error

Scenario: Response with multipart body (positive case)
Given a provider is started that returns the response from interaction 10
And a Pact file for interaction 10 is to be verified
When the verification is run
Then the verification will be successful

Scenario: Response with multipart body (negative case)
Given a provider is started that returns the response from interaction 10, with the following changes:
| body |
| file: multipart2-body.xml |
And a Pact file for interaction 10 is to be verified
When the verification is run
Then the verification will NOT be successful
And the verification results will contain a "Body had differences" error
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Feature: Basic HTTP consumer

Background:
Given the following HTTP interactions have been defined:
| method | path | query | headers | body | matching rules |
| POST | /path | | | file: basic.json | regex-matcher-v2.json |
| POST | /path | | | file: basic.json | type-matcher-v2.json |
| GET | /aaa/100/ | | | | regex-matcher-path-v2.json |
| GET | /path | a=1&b=2&c=abc&d=true | | | regex-matcher-query-v2.json |
| GET | /path | | 'X-Test: 1000' | | regex-matcher-header-v2.json |
| No | method | path | query | headers | body | matching rules |
| 1 | POST | /path | | | file: basic.json | regex-matcher-v2.json |
| 2 | POST | /path | | | file: basic.json | type-matcher-v2.json |
| 3 | GET | /aaa/100/ | | | | regex-matcher-path-v2.json |
| 4 | GET | /path | a=1&b=2&c=abc&d=true | | | regex-matcher-query-v2.json |
| 5 | GET | /path | | 'X-Test: 1000' | | regex-matcher-header-v2.json |

Scenario: Supports a regex matcher (negative case)
When the mock server is started with interaction 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Feature: Basic HTTP provider

Background:
Given the following HTTP interactions have been defined:
| method | path | response | response headers | response content | response body | response matching rules |
| GET | /one | 200 | 'X-TEST: 1' | application/json | file: basic.json | regex-matcher-header-v2.json |
| GET | /two | 200 | | application/json | file: basic.json | type-matcher-v2.json |
| No | method | path | response | response headers | response content | response body | response matching rules |
| 1 | GET | /one | 200 | 'X-TEST: 1' | application/json | file: basic.json | regex-matcher-header-v2.json |
| 2 | GET | /two | 200 | | application/json | file: basic.json | type-matcher-v2.json |

Scenario: Supports matching rules for the response headers (positive case)
Given a provider is started that returns the response from interaction 1, with the following changes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<body>
<contentType>multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p</contentType>
<contents>
<contents eol="CRLF">
<![CDATA[
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: text/plain
Expand All @@ -11,8 +11,7 @@ This is the body of the message.
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--gc0p4Jq0M2Yt08jU534c0p--
]]>
</contents>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<body>
<contentType>multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p</contentType>
<contents>
<contents eol="CRLF">
<![CDATA[
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: text/plain
Expand Down

0 comments on commit 3c10367

Please sign in to comment.