HTTPRequest { public void bearerAuth(String token) { headers.put(HTTPHeaders.AUTHORIZATION, "Bearer " + token); } HTTPRequest(HTTPMethod method, String uri); void accept(ContentType contentType); void basicAuth(String user, String password); void bearerAuth(String token); void body(byte[] body, ContentType contentType); void body(String body, ContentType contentType); void form(Map<String, String> form); String requestURI(); final HTTPMethod method; final Map<String, String> params; final Map<String, String> headers; public String uri; public byte[] body; public ContentType contentType; public Map<String, String> form; public Duration connectTimeout; public Duration timeout; public Duration slowOperationThreshold; }
@Test void bearerAuth() { var request = new HTTPRequest(HTTPMethod.GET, "http: request.bearerAuth("token"); assertThat(request.headers).containsEntry(HTTPHeaders.AUTHORIZATION, "Bearer token"); }