use of okhttp3.mockwebserver.RecordedRequest in project sonarqube by SonarSource.
the class HttpConnectorTest method send_user_agent.
@Test
public void send_user_agent() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder().url(serverUrl).userAgent("Maven Plugin/2.3").build();
underTest.call(new GetRequest("api/issues/search"));
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("User-Agent")).isEqualTo("Maven Plugin/2.3");
}
use of okhttp3.mockwebserver.RecordedRequest in project sonarqube by SonarSource.
the class HttpConnectorTest method use_access_token.
/**
* Access token replaces the couple {login,password} and is sent through
* the login field
*/
@Test
public void use_access_token() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder().url(serverUrl).token("theToken").build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theToken", ""));
}
use of okhttp3.mockwebserver.RecordedRequest in project sonarqube by SonarSource.
the class HttpConnectorTest method use_basic_authentication.
@Test
public void use_basic_authentication() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder().url(serverUrl).credentials("theLogin", "thePassword").build();
GetRequest request = new GetRequest("api/issues/search");
underTest.call(request);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo(basic("theLogin", "thePassword"));
}
use of okhttp3.mockwebserver.RecordedRequest in project sonarqube by SonarSource.
the class WebhookCallerImplTest method send_posts_payload_to_http_server.
@Test
public void send_posts_payload_to_http_server() throws Exception {
Webhook webhook = new Webhook(PROJECT_UUID, CE_TASK_UUID, "my-webhook", server.url("/ping").toString());
server.enqueue(new MockResponse().setBody("pong").setResponseCode(201));
WebhookDelivery delivery = newSender().call(webhook, PAYLOAD);
assertThat(delivery.getHttpStatus().get()).isEqualTo(201);
assertThat(delivery.getDurationInMs().get()).isGreaterThanOrEqualTo(0);
assertThat(delivery.getError()).isEmpty();
assertThat(delivery.getAt()).isEqualTo(NOW);
assertThat(delivery.getWebhook()).isSameAs(webhook);
assertThat(delivery.getPayload()).isSameAs(PAYLOAD);
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
assertThat(recordedRequest.getPath()).isEqualTo("/ping");
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo(PAYLOAD.getJson());
assertThat(recordedRequest.getHeader("User-Agent")).isEqualTo("SonarQube/6.2");
assertThat(recordedRequest.getHeader("Content-Type")).isEqualTo("application/json; charset=utf-8");
assertThat(recordedRequest.getHeader("X-SonarQube-Project")).isEqualTo(PAYLOAD.getProjectKey());
}
use of okhttp3.mockwebserver.RecordedRequest in project zipkin by openzipkin.
the class HttpBulkSpanIndexerTest method doesntWriteSpanId.
@Test
public void doesntWriteSpanId() throws Exception {
es.enqueue(new MockResponse());
indexer.add("test_zipkin_http-2016-10-01", TestObjects.LOTS_OF_SPANS[0], (Long) null);
indexer.execute(callback);
callback.get();
RecordedRequest request = es.takeRequest();
assertThat(request.getBody().readByteString().utf8()).doesNotContain("\"_id\"");
}
Aggregations