use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class UpdateActionTest method fail_if_url_is_not_valid.
@Test
public void fail_if_url_is_not_valid() {
ProjectDto project = componentDbTester.insertPrivateProjectDto();
WebhookDto dto = webhookDbTester.insertWebhook(project);
userSession.logIn().addProjectPermission(ADMIN, project);
TestRequest request = wsActionTester.newRequest().setParam("webhook", dto.getUuid()).setParam("name", NAME_WEBHOOK_EXAMPLE_001).setParam("url", "htp://www.wrong-protocol.com/");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class UpdateActionTest method update_a_project_webhook_with_all_fields.
@Test
public void update_a_project_webhook_with_all_fields() {
ProjectDto project = componentDbTester.insertPrivateProjectDto();
WebhookDto dto = webhookDbTester.insertWebhook(project);
userSession.logIn().addProjectPermission(ADMIN, project);
TestResponse response = wsActionTester.newRequest().setParam("webhook", dto.getUuid()).setParam("name", NAME_WEBHOOK_EXAMPLE_001).setParam("url", URL_WEBHOOK_EXAMPLE_001).setParam("secret", "a_new_secret").execute();
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
assertThat(reloaded).isPresent();
assertThat(reloaded.get().getName()).isEqualTo(NAME_WEBHOOK_EXAMPLE_001);
assertThat(reloaded.get().getUrl()).isEqualTo(URL_WEBHOOK_EXAMPLE_001);
assertThat(reloaded.get().getProjectUuid()).isEqualTo(dto.getProjectUuid());
assertThat(reloaded.get().getSecret()).isEqualTo("a_new_secret");
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class UpdateActionTest method fail_if_credential_in_url_is_have_a_wrong_format.
@Test
public void fail_if_credential_in_url_is_have_a_wrong_format() {
ProjectDto project = componentDbTester.insertPrivateProjectDto();
WebhookDto dto = webhookDbTester.insertWebhook(project);
userSession.logIn().addProjectPermission(ADMIN, project);
TestRequest request = wsActionTester.newRequest().setParam("webhook", dto.getUuid()).setParam("name", NAME_WEBHOOK_EXAMPLE_001).setParam("url", "http://:www.wrong-protocol.com/");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class UpdateActionTest 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("webhook", dto.getUuid()).setParam("name", NAME_WEBHOOK_EXAMPLE_001).setParam("url", URL_WEBHOOK_EXAMPLE_001);
assertThatThrownBy(request::execute).isInstanceOf(UnauthorizedException.class);
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class UpdateActionTest method update_a_global_webhook.
@Test
public void update_a_global_webhook() {
WebhookDto dto = webhookDbTester.insertGlobalWebhook();
userSession.logIn().addPermission(ADMINISTER);
TestResponse response = wsActionTester.newRequest().setParam("webhook", dto.getUuid()).setParam("name", NAME_WEBHOOK_EXAMPLE_001).setParam("url", URL_WEBHOOK_EXAMPLE_001).setParam("secret", "a_new_secret").execute();
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
assertThat(reloaded).isPresent();
assertThat(reloaded.get().getName()).isEqualTo(NAME_WEBHOOK_EXAMPLE_001);
assertThat(reloaded.get().getUrl()).isEqualTo(URL_WEBHOOK_EXAMPLE_001);
assertThat(reloaded.get().getProjectUuid()).isNull();
assertThat(reloaded.get().getSecret()).isEqualTo("a_new_secret");
}
Aggregations