use of org.sonar.alm.client.github.config.GithubAppConfiguration in project sonarqube by SonarSource.
the class GithubGlobalSettingsValidatorTest method github_global_settings_validation_with_encrypted_key.
@Test
public void github_global_settings_validation_with_encrypted_key() {
String encryptedKey = "encrypted-key";
String decryptedKey = "decrypted-key";
AlmSettingDto almSettingDto = createNewGithubDto("clientId", "clientSecret", EXAMPLE_APP_ID, encryptedKey);
when(encryption.isEncrypted(encryptedKey)).thenReturn(true);
when(encryption.decrypt(encryptedKey)).thenReturn(decryptedKey);
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(decryptedKey).isEqualTo(configurationArgumentCaptor.getAllValues().get(0).getPrivateKey());
assertThat(configuration.getId()).isEqualTo(configurationArgumentCaptor.getAllValues().get(1).getId());
assertThat(decryptedKey).isEqualTo(configurationArgumentCaptor.getAllValues().get(1).getPrivateKey());
}
Aggregations