use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.
the class ListActionTest method obfuscate_credentials_in_webhook_URLs.
@Test
public void obfuscate_credentials_in_webhook_URLs() {
String url = "http://foo:barouf@toto/bop";
String expectedUrl = "http://***:******@toto/bop";
WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa", t -> t.setUrl(url)), null, null);
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
webhookDbTester.insert(newGlobalWebhook("bbb", t -> t.setUrl(url)), null, null);
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
assertThat(elements).hasSize(2).extracting(Webhooks.ListResponseElement::getUrl).containsOnly(expectedUrl);
}
use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.
the class ListActionTest method list_global_webhooks_if_project_key_param_missing.
@Test
public void list_global_webhooks_if_project_key_param_missing() {
WebhookDto dto1 = webhookDbTester.insertGlobalWebhook();
WebhookDto dto2 = webhookDbTester.insertGlobalWebhook();
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList()).extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl).contains(tuple(dto1.getName(), dto1.getUrl()), tuple(dto2.getName(), dto2.getUrl()));
}
use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.
the class ListActionTest method list_global_webhooks.
@Test
public void list_global_webhooks() {
WebhookDto dto1 = webhookDbTester.insertGlobalWebhook();
WebhookDto dto2 = webhookDbTester.insertGlobalWebhook();
// insert a project-specific webhook, that should not be returned when listing global webhooks
webhookDbTester.insertWebhook(componentDbTester.insertPrivateProjectDto());
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList()).extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl).containsExactlyInAnyOrder(tuple(dto1.getName(), dto1.getUrl()), tuple(dto2.getName(), dto2.getUrl()));
}
use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.
the class ListActionTest method list_project_webhooks_when_project_key_param_is_provided.
@Test
public void list_project_webhooks_when_project_key_param_is_provided() {
ProjectDto project1 = componentDbTester.insertPrivateProjectDto();
userSession.logIn().addProjectPermission(ADMIN, project1);
WebhookDto dto1 = webhookDbTester.insertWebhook(project1);
WebhookDto dto2 = webhookDbTester.insertWebhook(project1);
ListResponse response = wsActionTester.newRequest().setParam(PROJECT_KEY_PARAM, project1.getKey()).executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList()).extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl).contains(tuple(dto1.getName(), dto1.getUrl()), tuple(dto2.getName(), dto2.getUrl()));
}
use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.
the class ListActionTest method list_webhooks_and_their_latest_delivery.
@Test
public void list_webhooks_and_their_latest_delivery() {
WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa"), null, null);
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
WebhookDto webhook2 = webhookDbTester.insert(newGlobalWebhook("bbb"), null, null);
webhookDeliveryDbTester.insert(newDto("WH2-DELIVERY-1-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH2-DELIVERY-2-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
assertThat(elements.size()).isEqualTo(2);
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
assertThat(elements.get(0).getLatestDelivery()).isNotNull();
assertThat(elements.get(0).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH1-DELIVERY-2-UUID");
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid());
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb");
assertThat(elements.get(1).getLatestDelivery()).isNotNull();
assertThat(elements.get(1).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH2-DELIVERY-2-UUID");
}
Aggregations