use of org.sonar.alm.client.github.GithubGlobalSettingsValidator 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.alm.client.github.GithubGlobalSettingsValidator 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());
}
Aggregations