KTestify cucumber plugin HTTP client #54
Replies: 1 comment 1 reply
|
Hello @williamgarr. Excellent idea, here's the design I thought of, feel free to give me your feedback! Project structureRather than bolting HTTP onto the existing Kafka-shaped Key point: the HTTP response is stored as a plain Gherkin SyntaxBackgroundGiven HTTP endpoint
| endpointAlias | baseUrl | defaultHeaders |
| orders-api | http://localhost:8080/api | Content-Type=application/json |
Given HTTP bearer token
| endpointAlias | token |
| orders-api | {{ENV:API_TOKEN}} |ActionWhen HTTP request is sent
| endpointAlias | method | path | file | responseAlias |
| orders-api | POST | /orders/validate | order.json | validate-resp |
When HTTP request is sent
| endpointAlias | method | path | queryParams | responseAlias |
| orders-api | GET | /orders/{id} | id=ORD-001 | fetch-resp |ValidationThen expected HTTP response status
| responseAlias | statusCode |
| validate-resp | 200 |
Then expected HTTP response body from file
| responseAlias | file | excludedKeys |
| validate-resp | expected.json | timestamp,id |
And HTTP response header should match
| responseAlias | header | value |
| validate-resp | Content-Type | application/json |
# Eventually-consistent polling, mirrors "record should appear in topic"
Then HTTP endpoint should eventually return
| endpointAlias | method | path | expectedStatus | readTimeout |
| orders-api | GET | /orders/ORD-001/status | 200 | 30 |Configurationktestify.plugins.http {
connect-timeout = 10s
read-timeout = 30s ; overridable per-step via readTimeout column
poll-interval = 500ms
follow-redirects = true
default-headers { }
tls {
trust-all = false ; explicit opt-in only, for local/dev endpoints
}
}Notes, why this needs core work, not just a plugin
My first instinct was to just write the HTTP plugin with its own So instead I want to add a proper second contract to core, Net effect: I've written up the full implementation spec (core changes first, then the plugin). I will link the issues when I finished creating them :). What do you think ? |
Uh oh!
There was an error while loading. Please reload this page.
Hello, in my app I have a content chain of consumers/producers. But a part of the chain is triggered with API calls instead of Kafka.
Ideally I want to test it with the rest of the content chain in my KTestify cucumber setup.
The first workaround tooling I thought of was :
That could work but it is IMO a little dirty.
An elegant solution could be :
Hope you like the idea ;)
All reactions