Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin-rest-api] Add ability to set an empty string as HTTP request body #4621

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/modules/plugins/pages/plugin-rest-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ WARNING: No HTTP request header is set in the case of binary content.
Given request body: $content
----

.Alias syntax
[source,gherkin]
----
Given request body:`$content`
----

* `$content` - HTTP request body.

.Set textual HTTP request body
Expand All @@ -324,6 +330,12 @@ When I set request headers:
When I execute HTTP POST request for resource with relative URL `/upload/png`
----

.Set an ampty string as HTTP request body
[source,gherkin]
----
Given request body:``
----

=== Prepare multipart HTTP request

Sets https://tools.ietf.org/html/rfc7578[multipart] request entity that will be used while executing HTTP requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.apache.hc.core5.util.Timeout;
import org.jbehave.core.annotations.Alias;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.When;
import org.jbehave.core.model.ExamplesTable;
Expand Down Expand Up @@ -73,6 +74,7 @@ public HttpRequestSteps(HttpTestContext httpTestContext, HttpRequestExecutor htt
* @param content HTTP request body
*/
@Given("request body: $content")
@Alias("request body:`$content`")
public void request(DataWrapper content)
{
Object data = content.data();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ Then `${responseCode}` is equal to `200`
When I save JSON element value from `${json-context}` by JSON path `$.data` to scenario variable `data`
Then `${data}` matches `data:application/octet-stream;base64.*`

Scenario: Verify step "Given request body:`$content`" (HTTP request body is an empty string)
Given request body:``
When I execute HTTP POST request for resource with relative URL `/post`
Then `${responseCode}` is equal to `200`
When I save JSON element value from `${json-context}` by JSON path `$.data` to scenario variable `data`
Then `${data}` is equal to ``

Scenario: Verify step "Given form data request:$parameters"
Given form data request:
|name |value |
Expand Down
Loading