Polish contribution

- Make commons-codec an optional dependency
 - Isolate knowledge of basic auth header to code that produces the
   -u option

Closes gh-120
This commit is contained in:
Andy Wilkinson
2015-09-16 17:39:24 -04:00
parent d329e2da5d
commit ce26bd4b1a
4 changed files with 35 additions and 31 deletions

View File

@@ -260,12 +260,15 @@ public class CurlRequestSnippetTests {
}
@Test
public void httpBasicAuthorizationHeader() throws IOException {
this.snippet.expectCurlRequest("get-request")
.withContents(codeBlock("bash").content("$ curl 'http://localhost/foo' -i -u 'user:secret'"));
new CurlRequestSnippet().document(new OperationBuilder("get-request", this.snippet.getOutputDirectory())
public void basicAuthCredentialsAreSuppliedUsingUserOption() throws IOException {
this.snippet.expectCurlRequest("basic-auth").withContents(
codeBlock("bash").content(
"$ curl 'http://localhost/foo' -i -u 'user:secret'"));
new CurlRequestSnippet().document(new OperationBuilder("basic-auth", this.snippet
.getOutputDirectory())
.request("http://localhost/foo")
.header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString("user:secret".getBytes()))
.header(HttpHeaders.AUTHORIZATION,
"Basic " + Base64Utils.encodeToString("user:secret".getBytes()))
.build());
}