Search in sources :

Example 6 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class GithubGlobalSettingsValidatorTest method github_validation_checks_missing_clientSecret.

@Test
public void github_validation_checks_missing_clientSecret() {
    AlmSettingDto almSettingDto = createNewGithubDto("clientId", null, EXAMPLE_APP_ID, null);
    assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class).hasMessage("Missing Client Secret");
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 7 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class GitlabGlobalSettingsValidatorTest method validate_success_with_encrypted_token.

@Test
public void validate_success_with_encrypted_token() {
    String encryptedToken = "personal-access-token";
    String decryptedToken = "decrypted-token";
    AlmSettingDto almSettingDto = new AlmSettingDto().setUrl("https://gitlab.com/api").setPersonalAccessToken(encryptedToken);
    when(encryption.isEncrypted(encryptedToken)).thenReturn(true);
    when(encryption.decrypt(encryptedToken)).thenReturn(decryptedToken);
    underTest.validate(almSettingDto);
    verify(gitlabHttpClient, times(1)).checkUrl(almSettingDto.getUrl());
    verify(gitlabHttpClient, times(1)).checkToken(almSettingDto.getUrl(), decryptedToken);
    verify(gitlabHttpClient, times(1)).checkReadPermission(almSettingDto.getUrl(), decryptedToken);
    verify(gitlabHttpClient, times(1)).checkWritePermission(almSettingDto.getUrl(), decryptedToken);
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 8 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class GitlabGlobalSettingsValidatorTest method validate_fail_url_not_set.

@Test
public void validate_fail_url_not_set() {
    AlmSettingDto almSettingDto = new AlmSettingDto().setUrl(null).setPersonalAccessToken("personal-access-token");
    assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class).hasMessage("Your Gitlab global configuration is incomplete.");
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 9 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class GitlabGlobalSettingsValidatorTest method validate_fail_pat_not_set.

@Test
public void validate_fail_pat_not_set() {
    AlmSettingDto almSettingDto = new AlmSettingDto().setUrl("https://gitlab.com/api").setPersonalAccessToken(null);
    assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class).hasMessage("Your Gitlab global configuration is incomplete.");
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Example 10 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class AzureDevOpsValidatorTest method validate_givenHttpClientNotThrowingException_doesNotThrowException.

@Test(expected = Test.None.class)
public void validate_givenHttpClientNotThrowingException_doesNotThrowException() {
    AlmSettingDto dto = createMockDto();
    underTest.validate(dto);
}
Also used : AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto) Test(org.junit.Test)

Aggregations

AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)217 Test (org.junit.Test)175 UserDto (org.sonar.db.user.UserDto)113 TestRequest (org.sonar.server.ws.TestRequest)48 ProjectDto (org.sonar.db.project.ProjectDto)40 NotFoundException (org.sonar.server.exceptions.NotFoundException)37 DbSession (org.sonar.db.DbSession)36 WebService (org.sonar.api.server.ws.WebService)31 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)28 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)28 Rule (org.junit.Rule)28 Mockito.mock (org.mockito.Mockito.mock)28 DbTester (org.sonar.db.DbTester)28 UserSessionRule (org.sonar.server.tester.UserSessionRule)28 WsActionTester (org.sonar.server.ws.WsActionTester)28 Encryption (org.sonar.api.config.internal.Encryption)27 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)27 ComponentFinder (org.sonar.server.component.ComponentFinder)26 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)25 ProjectAlmSettingDto (org.sonar.db.alm.setting.ProjectAlmSettingDto)25