use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class BitbucketServerSettingsValidatorTest method validate_failure_on_bitbucket_server_api_error.
@Test
public void validate_failure_on_bitbucket_server_api_error() {
doThrow(new IllegalArgumentException("error")).when(bitbucketServerRestClient).validateUrl(anyString());
AlmSettingDto almSettingDto = createNewBitbucketDto("http://abc.com", "abc");
assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class BitbucketServerSettingsValidatorTest method validate_failure_on_incomplete_configuration.
@Test
public void validate_failure_on_incomplete_configuration() {
AlmSettingDto almSettingDto = createNewBitbucketDto(null, "abc");
assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class BitbucketServerSettingsValidatorTest method validate_success_with_encrypted_token.
@Test
public void validate_success_with_encrypted_token() {
String encryptedToken = "abc";
String decryptedToken = "decrypted-token";
AlmSettingDto almSettingDto = createNewBitbucketDto("http://abc.com", encryptedToken);
when(encryption.isEncrypted(encryptedToken)).thenReturn(true);
when(encryption.decrypt(encryptedToken)).thenReturn(decryptedToken);
underTest.validate(almSettingDto);
verify(bitbucketServerRestClient, times(1)).validateUrl("http://abc.com");
verify(bitbucketServerRestClient, times(1)).validateToken("http://abc.com", decryptedToken);
verify(bitbucketServerRestClient, times(1)).validateReadPermission("http://abc.com", decryptedToken);
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class GithubGlobalSettingsValidatorTest method github_validation_checks_invalid_appId.
@Test
public void github_validation_checks_invalid_appId() {
AlmSettingDto almSettingDto = createNewGithubDto("clientId", "clientSecret", "abc", null);
assertThatThrownBy(() -> underTest.validate(almSettingDto)).isInstanceOf(IllegalArgumentException.class).hasMessage("Invalid appId; For input string: \"abc\"");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class GithubGlobalSettingsValidatorTest method github_global_settings_validation.
@Test
public void github_global_settings_validation() {
AlmSettingDto almSettingDto = createNewGithubDto("clientId", "clientSecret", EXAMPLE_APP_ID, EXAMPLE_PRIVATE_KEY);
when(encryption.isEncrypted(any())).thenReturn(false);
GithubAppConfiguration configuration = underTest.validate(almSettingDto);
ArgumentCaptor<GithubAppConfiguration> configurationArgumentCaptor = ArgumentCaptor.forClass(GithubAppConfiguration.class);
verify(appClient).checkApiEndpoint(configurationArgumentCaptor.capture());
verify(appClient).checkAppPermissions(configurationArgumentCaptor.capture());
assertThat(configuration.getId()).isEqualTo(configurationArgumentCaptor.getAllValues().get(0).getId());
assertThat(configuration.getId()).isEqualTo(configurationArgumentCaptor.getAllValues().get(1).getId());
}
Aggregations