use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class DeleteActionTest method fail_if_not_logged_in.
@Test
public void fail_if_not_logged_in() {
WebhookDto dto = webhookDbTester.insertGlobalWebhook();
userSession.anonymous();
TestRequest request = wsActionTester.newRequest().setParam(KEY_PARAM, dto.getUuid());
assertThatThrownBy(request::execute).isInstanceOf(UnauthorizedException.class);
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class DeleteActionTest method delete_a_project_webhook.
@Test
public void delete_a_project_webhook() {
ProjectDto project = componentDbTester.insertPrivateProjectDto();
WebhookDto dto = webhookDbTester.insertWebhook(project);
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
userSession.logIn().addProjectPermission(ADMIN, project);
TestResponse response = wsActionTester.newRequest().setParam(KEY_PARAM, dto.getUuid()).execute();
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
assertThat(reloaded).isEmpty();
int deliveriesCount = deliveryDao.countDeliveriesByWebhookUuid(dbSession, dto.getUuid());
assertThat(deliveriesCount).isZero();
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class ComponentCleanerServiceTest method delete_webhooks_from_projects.
@Test
public void delete_webhooks_from_projects() {
ProjectDto project1 = db.components().insertPrivateProjectDto();
WebhookDto webhook1 = db.webhooks().insertWebhook(project1);
db.webhookDelivery().insert(webhook1);
ProjectDto project2 = db.components().insertPrivateProjectDto();
WebhookDto webhook2 = db.webhooks().insertWebhook(project2);
db.webhookDelivery().insert(webhook2);
ProjectDto projectNotToBeDeleted = db.components().insertPrivateProjectDto();
WebhookDto webhook3 = db.webhooks().insertWebhook(projectNotToBeDeleted);
db.webhookDelivery().insert(webhook3);
ProjectDto projectDto1 = dbClient.projectDao().selectByUuid(dbSession, project1.getUuid()).get();
ProjectDto projectDto2 = dbClient.projectDao().selectByUuid(dbSession, project2.getUuid()).get();
mockResourceTypeAsValidProject();
underTest.delete(dbSession, asList(projectDto1, projectDto2));
assertThat(db.countRowsOfTable(db.getSession(), "webhooks")).isOne();
assertThat(db.countRowsOfTable(db.getSession(), "webhook_deliveries")).isOne();
}
Aggregations