use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class UpdateAzureActionTest method update.
@Test
public void update() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertAzureAlmSetting();
ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("personalAccessToken", "10987654321").setParam("url", AZURE_URL).execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple(almSettingDto.getKey(), AZURE_URL, "10987654321"));
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class UpdateAzureActionTest method update_with_new_key.
@Test
public void update_with_new_key() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertAzureAlmSetting();
ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("newKey", "Azure Server - Infra Team").setParam("personalAccessToken", "0123456789").setParam("url", AZURE_URL).execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple("Azure Server - Infra Team", AZURE_URL, "0123456789"));
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class UpdateAzureActionTest method update_without_pat.
@Test
public void update_without_pat() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertAzureAlmSetting();
ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", AZURE_URL).execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple(almSettingDto.getKey(), AZURE_URL, almSettingDto.getDecryptedPersonalAccessToken(encryption)));
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class UpdateGithubActionTest method update_without_private_key_nor_client_secret.
@Test
public void update_without_private_key_nor_client_secret() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertGitHubAlmSetting();
ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", "https://github.enterprise-unicorn.com/").setParam("appId", "54321").setParam("clientId", "client_1234").execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, AlmSettingDto::getAppId, s -> s.getDecryptedPrivateKey(encryption), AlmSettingDto::getClientId, s -> s.getDecryptedClientSecret(encryption)).containsOnly(tuple(almSettingDto.getKey(), "https://github.enterprise-unicorn.com", "54321", almSettingDto.getDecryptedPrivateKey(encryption), "client_1234", almSettingDto.getDecryptedClientSecret(encryption)));
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class DefaultConfigurationTest method accessingMultiValuedPropertiesShouldBeConsistentWithDeclaration.
@Test
public void accessingMultiValuedPropertiesShouldBeConsistentWithDeclaration() {
Configuration config = new DefaultConfiguration(new PropertyDefinitions(System2.INSTANCE, Arrays.asList(PropertyDefinition.builder("single").multiValues(false).build(), PropertyDefinition.builder("multiA").multiValues(true).build())), new Encryption(null), ImmutableMap.of("single", "foo", "multiA", "a,b", "notDeclared", "c,d")) {
};
assertThat(config.get("multiA")).hasValue("a,b");
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Access to the multi-values/property set property 'multiA' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
logTester.clear();
assertThat(config.getStringArray("single")).containsExactly("foo");
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Property 'single' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.");
logTester.clear();
assertThat(config.get("notDeclared")).hasValue("c,d");
assertThat(config.getStringArray("notDeclared")).containsExactly("c", "d");
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
}
Aggregations