use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ValidateActionTest method bitbucketcloud_validation_checks_with_encrypted_secret.
@Test
public void bitbucketcloud_validation_checks_with_encrypted_secret() {
String decryptedSecret = "decrypted-secret";
AlmSettingDto almSetting = insertAlmSetting(db.almSettings().insertBitbucketCloudAlmSetting());
when(encryption.isEncrypted(any())).thenReturn(true);
when(encryption.decrypt(any())).thenReturn(decryptedSecret);
ws.newRequest().setParam("key", almSetting.getKey()).execute();
verify(bitbucketCloudRestClient).validate(almSetting.getClientId(), decryptedSecret, almSetting.getAppId());
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ValidateActionTest method bitbucketcloud_validation_check_fails.
@Test
public void bitbucketcloud_validation_check_fails() {
AlmSettingDto almSetting = insertAlmSetting(db.almSettings().insertBitbucketCloudAlmSetting());
when(encryption.isEncrypted(any())).thenReturn(false);
doThrow(IllegalArgumentException.class).when(bitbucketCloudRestClient).validate(any(), any(), any());
TestRequest request = ws.newRequest().setParam("key", almSetting.getKey());
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ValidateActionTest method github_validation_checks.
@Test
public void github_validation_checks() {
AlmSettingDto almSetting = insertAlmSetting(db.almSettings().insertGitHubAlmSetting(settings -> settings.setClientId("clientId").setClientSecret("clientSecret")));
when(encryption.isEncrypted(any())).thenReturn(false);
ws.newRequest().setParam("key", almSetting.getKey()).execute();
ArgumentCaptor<AlmSettingDto> almSettingDtoArgumentCaptor = ArgumentCaptor.forClass(AlmSettingDto.class);
verify(githubGlobalSettingsValidator).validate(almSettingDtoArgumentCaptor.capture());
assertThat(almSettingDtoArgumentCaptor.getAllValues()).hasSize(1);
assertThat(almSettingDtoArgumentCaptor.getValue().getClientId()).isEqualTo(almSetting.getClientId());
assertThat(almSettingDtoArgumentCaptor.getValue().getDecryptedClientSecret(encryption)).isEqualTo(almSetting.getDecryptedClientSecret(encryption));
assertThat(almSettingDtoArgumentCaptor.getValue().getAlm()).isEqualTo(almSetting.getAlm());
assertThat(almSettingDtoArgumentCaptor.getValue().getAppId()).isEqualTo(almSetting.getAppId());
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ValidateActionTest method github_validation_checks_with_encrypted_secret.
@Test
public void github_validation_checks_with_encrypted_secret() {
String secret = "encrypted-secret";
String decryptedSecret = "decrypted-secret";
AlmSettingDto almSetting = insertAlmSetting(db.almSettings().insertGitHubAlmSetting(settings -> settings.setClientId("clientId").setClientSecret(secret)));
when(encryption.isEncrypted(secret)).thenReturn(true);
when(encryption.decrypt(secret)).thenReturn(decryptedSecret);
ws.newRequest().setParam("key", almSetting.getKey()).execute();
ArgumentCaptor<AlmSettingDto> almSettingDtoArgumentCaptor = ArgumentCaptor.forClass(AlmSettingDto.class);
verify(githubGlobalSettingsValidator).validate(almSettingDtoArgumentCaptor.capture());
assertThat(almSettingDtoArgumentCaptor.getAllValues()).hasSize(1);
assertThat(almSettingDtoArgumentCaptor.getValue().getClientId()).isEqualTo(almSetting.getClientId());
assertThat(almSettingDtoArgumentCaptor.getValue().getDecryptedClientSecret(encryption)).isEqualTo(decryptedSecret);
assertThat(almSettingDtoArgumentCaptor.getValue().getAlm()).isEqualTo(almSetting.getAlm());
assertThat(almSettingDtoArgumentCaptor.getValue().getAppId()).isEqualTo(almSetting.getAppId());
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ValidateActionTest method gitlab_validation_checks.
@Test
public void gitlab_validation_checks() {
AlmSettingDto almSetting = insertAlmSetting(db.almSettings().insertGitlabAlmSetting());
when(encryption.isEncrypted(any())).thenReturn(false);
ws.newRequest().setParam("key", almSetting.getKey()).execute();
verify(gitlabSettingsValidator).validate(any(AlmSettingDto.class));
}
Aggregations