Skip to content

Commit ebf64f6

Browse files
authored
fx/requestHeaderAssertWithFlags (#135)
* fix: headers can now be asserted with flags
1 parent eb233ff commit ebf64f6

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

tzatziki-http/src/main/java/com/decathlon/tzatziki/steps/HttpSteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ private void mockserver_has_received(Guard guard, Comparison comparison, String
435435
List<Interaction> expectedInteractions = Mapper.readAsAListOf(expectedInteractionsStr, Interaction.class);
436436
List<Interaction> recordedInteractions = expectedInteractions
437437
.stream()
438-
.map(interaction -> interaction.request.toHttpRequestIn(objects, uri, false).clone().withBody((Body<?>) null))
438+
.map(interaction -> interaction.request.toHttpRequestIn(objects, uri, false).clone().withHeaders(Collections.emptyList()).withBody((Body<?>) null))
439439
.map(MockFaster::retrieveRequestResponses)
440440
.flatMap(Collection::stream)
441441
.collect(toMap(e -> e.getHttpRequest().getLogCorrelationId(), identity(), (h1, h2) -> h1))

tzatziki-http/src/test/resources/com/decathlon/tzatziki/steps/http.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,33 @@ Feature: to interact with an http service and setup mocks
12211221
| mocksRange |
12221222
| 2-150 |
12231223
| 151-250 |
1224+
1225+
Scenario: Interactions can also be matched with flags
1226+
Given that posting on "http://backend/simpleApi" will return a status OK_200
1227+
When we post on "http://backend/simpleApi" a Request:
1228+
"""
1229+
headers:
1230+
X-Request-ID: '12345'
1231+
"""
1232+
And we post on "http://backend/simpleApi"
1233+
Then the interaction on "http://backend/simpleApi" was:
1234+
"""
1235+
request:
1236+
method: POST
1237+
headers:
1238+
X-Request-ID: ?notNull
1239+
"""
1240+
And the interaction on "http://backend/simpleApi" was only:
1241+
"""
1242+
- request:
1243+
method: POST
1244+
headers:
1245+
X-Request-ID: ?notNull
1246+
- request:
1247+
method: POST
1248+
headers:
1249+
X-Request-ID: null
1250+
"""
12241251

12251252
@ignore @run-manually
12261253
Scenario Template: Mocks from other tests should be considered as unhandled requests

0 commit comments

Comments
 (0)