Polish "Include cookies in request snippets"
See gh-336 Closes gh-302 Closes gh-303 Closes gh-304
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -254,12 +254,11 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
@Test
|
||||
public void requestWithCookies() throws IOException {
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content("$ curl 'http://localhost/foo' -i" +
|
||||
" --cookie 'name1=value1;name2=value2'"));
|
||||
.withContents(codeBlock("bash").content("$ curl 'http://localhost/foo' -i"
|
||||
+ " --cookie 'name1=value1;name2=value2'"));
|
||||
new CurlRequestSnippet()
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.cookie("name1", "value1")
|
||||
.cookie("name2", "value2").build());
|
||||
.cookie("name1", "value1").cookie("name2", "value2").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,9 +268,10 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ "'metadata={\"description\": \"foo\"}'";
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new CurlRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new CurlRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("metadata", "{\"description\": \"foo\"}".getBytes()).build());
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -302,8 +302,8 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -318,9 +318,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -332,7 +332,7 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils
|
||||
.encodeToString("user:secret".getBytes()))
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -255,12 +255,11 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
@Test
|
||||
public void requestWithCookies() throws IOException {
|
||||
this.snippets.expectHttpieRequest().withContents(
|
||||
codeBlock("bash").content("$ http GET 'http://localhost/foo'" +
|
||||
" 'Cookie:name1=value1' 'Cookie:name2=value2'"));
|
||||
codeBlock("bash").content("$ http GET 'http://localhost/foo'"
|
||||
+ " 'Cookie:name1=value1' 'Cookie:name2=value2'"));
|
||||
new HttpieRequestSnippet()
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.cookie("name1", "value1")
|
||||
.cookie("name2", "value2").build());
|
||||
.cookie("name1", "value1").cookie("name2", "value2").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,9 +269,10 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ " 'metadata'@<(echo '{\"description\": \"foo\"}')");
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new HttpieRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpieRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("metadata", "{\"description\": \"foo\"}".getBytes()).build());
|
||||
}
|
||||
|
||||
@@ -288,9 +288,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -304,8 +304,8 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -320,9 +320,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -334,7 +334,7 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils
|
||||
.encodeToString("user:secret".getBytes()))
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
.row("`X-Test`", "one").row("`Accept`", "two")
|
||||
.row("`Accept-Encoding`", "three")
|
||||
.row("`Accept-Language`", "four").row("`Cache-Control`", "five")
|
||||
.row("`Connection`", "six").row("`Cookie`", "seven"));
|
||||
.row("`Connection`", "six"));
|
||||
new RequestHeadersSnippet(
|
||||
Arrays.asList(headerWithName("X-Test").description("one"),
|
||||
headerWithName("Accept").description("two"),
|
||||
@@ -63,8 +63,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
headerWithName("Cache-Control").description("five"),
|
||||
headerWithName(
|
||||
"Connection")
|
||||
.description("six"),
|
||||
headerWithName("Cookie").description("seven")))
|
||||
.description("six")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.request(
|
||||
@@ -73,15 +72,9 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
.header("Accept", "*/*")
|
||||
.header("Accept-Encoding",
|
||||
"gzip, deflate")
|
||||
.header("Accept-Language",
|
||||
"en-US,en;q=0.5")
|
||||
.header("Cache-Control",
|
||||
"max-age=0")
|
||||
.header("Connection",
|
||||
"keep-alive")
|
||||
.header("Cookie",
|
||||
"cookie1=cookieVal1; cookie2=cookieVal2")
|
||||
.build());
|
||||
.header("Accept-Language", "en-US,en;q=0.5")
|
||||
.header("Cache-Control", "max-age=0")
|
||||
.header("Connection", "keep-alive").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +143,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
.header("X-Test", "test")
|
||||
.header("Accept-Encoding",
|
||||
"gzip, deflate")
|
||||
.header("Accept", "*/*").build());
|
||||
.header("Accept", "*/*").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,9 +90,7 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
|
||||
new HttpRequestSnippet()
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.cookie("name1", "value1")
|
||||
.cookie("name2", "value2")
|
||||
.build());
|
||||
.cookie("name1", "value1").cookie("name2", "value2").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,8 +140,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/foo").method("POST").content(content).build());
|
||||
@@ -154,8 +152,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet()
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
@@ -168,8 +166,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet()
|
||||
.document(this.operationBuilder.request("http://localhost/foo?b=bravo")
|
||||
@@ -182,8 +180,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/foo?b=bravo").method("POST")
|
||||
@@ -196,8 +194,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.POST, "/foo?b=bravo&a=alpha")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/foo?b=bravo&a=alpha").method("POST")
|
||||
@@ -251,8 +249,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
String content = "Hello, world";
|
||||
this.snippets.expectHttpRequest()
|
||||
.withContents(httpRequest(RequestMethod.PUT, "/foo")
|
||||
.header(HttpHeaders.HOST, "localhost").content(content).header(
|
||||
HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
.header(HttpHeaders.HOST, "localhost").content(content)
|
||||
.header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length));
|
||||
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/foo").method("PUT").content(content).build());
|
||||
@@ -284,7 +282,7 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -310,8 +308,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.param("a", "apple", "avocado").param("b", "banana")
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
.param("a", "apple", "avocado").param("b", "banana")
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -347,9 +345,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", "<< data >>".getBytes())
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.build());
|
||||
.part("image", "<< data >>".getBytes())
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user