Ensure that query string is not duplicated when parameters overlap
Closes gh-286
This commit is contained in:
@@ -95,6 +95,47 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
.request("http://localhost/foo?param=value").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithTotallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"request-with-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo?param=value' -i"));
|
||||
new CurlRequestSnippet().document(operationBuilder(
|
||||
"request-with-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?param=value")
|
||||
.param("param", "value").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithPartiallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo?a=alpha&b=bravo' -i"));
|
||||
new CurlRequestSnippet().document(operationBuilder(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").param("a", "alpha")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithDisjointQueryStringAndParameters() throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo?a=alpha&b=bravo' -i"));
|
||||
new CurlRequestSnippet().document(operationBuilder(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").param("b", "bravo")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithQueryStringWithNoValue() throws IOException {
|
||||
this.snippet.expectCurlRequest("request-with-query-string-with-no-value")
|
||||
@@ -172,25 +213,42 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithQueryStringAndParameter() throws IOException {
|
||||
this.snippet.expectCurlRequest("post-request-with-query-string-and-parameter")
|
||||
public void postRequestWithDisjointQueryStringAndParameter() throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"post-request-with-disjoint-query-string-and-parameter")
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ curl 'http://localhost/foo?a=alpha' -i -X POST -d 'b=bravo'"));
|
||||
new CurlRequestSnippet()
|
||||
.document(operationBuilder("post-request-with-query-string-and-parameter")
|
||||
new CurlRequestSnippet().document(
|
||||
operationBuilder("post-request-with-disjoint-query-string-and-parameter")
|
||||
.request("http://localhost/foo?a=alpha").method("POST")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithOverlappingQueryStringAndParameters() throws IOException {
|
||||
public void postRequestWithTotallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"post-request-with-overlapping-query-string-and-parameters")
|
||||
"post-request-with-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ curl 'http://localhost/foo?a=alpha&b=bravo' -i -X POST"));
|
||||
new CurlRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha&b=bravo").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithPartiallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectCurlRequest(
|
||||
"post-request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ curl 'http://localhost/foo?a=alpha' -i -X POST -d 'b=bravo'"));
|
||||
new CurlRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-overlapping-query-string-and-parameters")
|
||||
"post-request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@@ -96,6 +96,47 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
.request("http://localhost/foo?param=value").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithTotallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"request-with-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http GET 'http://localhost/foo?param=value'"));
|
||||
new HttpieRequestSnippet().document(operationBuilder(
|
||||
"request-with-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?param=value")
|
||||
.param("param", "value").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithPartiallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http GET 'http://localhost/foo?a=alpha&b=bravo'"));
|
||||
new HttpieRequestSnippet().document(operationBuilder(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").param("a", "alpha")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithDisjointQueryStringAndParameters() throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http GET 'http://localhost/foo?a=alpha&b=bravo'"));
|
||||
new HttpieRequestSnippet().document(operationBuilder(
|
||||
"request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").param("b", "bravo")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestWithQueryStringWithNoValue() throws IOException {
|
||||
this.snippet.expectHttpieRequest("request-with-query-string-with-no-value")
|
||||
@@ -173,25 +214,42 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithQueryStringAndParameter() throws IOException {
|
||||
this.snippet.expectHttpieRequest("post-request-with-query-string-and-parameter")
|
||||
public void postRequestWithDisjointQueryStringAndParameter() throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"post-request-with-disjoint-query-string-and-parameter")
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ http --form POST 'http://localhost/foo?a=alpha' 'b=bravo'"));
|
||||
new HttpieRequestSnippet()
|
||||
.document(operationBuilder("post-request-with-query-string-and-parameter")
|
||||
new HttpieRequestSnippet().document(
|
||||
operationBuilder("post-request-with-disjoint-query-string-and-parameter")
|
||||
.request("http://localhost/foo?a=alpha").method("POST")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithOverlappingQueryStringAndParameters() throws IOException {
|
||||
public void postRequestWithTotallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"post-request-with-overlapping-query-string-and-parameters")
|
||||
"post-request-with-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http POST 'http://localhost/foo?a=alpha&b=bravo'"));
|
||||
new HttpieRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha&b=bravo").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithPartiallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
this.snippet
|
||||
.expectHttpieRequest(
|
||||
"post-request-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ http --form POST 'http://localhost/foo?a=alpha' 'b=bravo'"));
|
||||
new HttpieRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-overlapping-query-string-and-parameters")
|
||||
"post-request-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@@ -102,6 +102,34 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.request("http://localhost/foo?bar").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithPartiallyOverlappingQueryStringAndParameters() throws IOException {
|
||||
this.snippet
|
||||
.expectHttpRequest(
|
||||
"get-with-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(httpRequest(RequestMethod.GET, "/foo?a=alpha&b=bravo")
|
||||
.header(HttpHeaders.HOST, "localhost"));
|
||||
|
||||
new HttpRequestSnippet().document(operationBuilder(
|
||||
"get-with-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha").param("a", "alpha")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithTotallyOverlappingQueryStringAndParameters() throws IOException {
|
||||
this.snippet
|
||||
.expectHttpRequest(
|
||||
"get-with-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(httpRequest(RequestMethod.GET, "/foo?a=alpha&b=bravo")
|
||||
.header(HttpHeaders.HOST, "localhost"));
|
||||
|
||||
new HttpRequestSnippet().document(operationBuilder(
|
||||
"get-with-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?a=alpha&b=bravo")
|
||||
.param("a", "alpha").param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithContent() throws IOException {
|
||||
String content = "Hello, world";
|
||||
@@ -128,6 +156,59 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.param("a", "alpha").content(content).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithContentAndDisjointQueryStringAndParameters()
|
||||
throws IOException {
|
||||
String content = "Hello, world";
|
||||
this.snippet
|
||||
.expectHttpRequest(
|
||||
"post-request-with-content-and-disjoint-query-string-and-parameters")
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-content-and-disjoint-query-string-and-parameters")
|
||||
.request("http://localhost/foo?b=bravo").method("POST")
|
||||
.param("a", "alpha").content(content).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithContentAndPartiallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
String content = "Hello, world";
|
||||
this.snippet
|
||||
.expectHttpRequest(
|
||||
"post-request-with-content-and-partially-overlapping-query-string-and-parameters")
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-content-and-partially-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?b=bravo").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").content(content)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithContentAndTotallyOverlappingQueryStringAndParameters()
|
||||
throws IOException {
|
||||
String content = "Hello, world";
|
||||
this.snippet
|
||||
.expectHttpRequest(
|
||||
"post-request-with-content-and-totally-overlapping-query-string-and-parameters")
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(operationBuilder(
|
||||
"post-request-with-content-and-totally-overlapping-query-string-and-parameters")
|
||||
.request("http://localhost/foo?b=bravo&a=alpha").method("POST")
|
||||
.param("a", "alpha").param("b", "bravo").content(content)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postRequestWithCharset() throws IOException {
|
||||
String japaneseContent = "\u30b3\u30f3\u30c6\u30f3\u30c4";
|
||||
|
||||
Reference in New Issue
Block a user