use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class UpdateGitlabActionTest method update_with_url.
@Test
public void update_with_url() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertGitlabAlmSetting();
ws.newRequest().setParam("key", almSettingDto.getKey()).setParam("url", GITLAB_URL).setParam("personalAccessToken", "10987654321").execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple(almSettingDto.getKey(), GITLAB_URL, "10987654321"));
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class DefaultConfigurationTest method accessingPropertySetPropertiesShouldBeConsistentWithDeclaration.
@Test
public void accessingPropertySetPropertiesShouldBeConsistentWithDeclaration() {
Configuration config = new DefaultConfiguration(new PropertyDefinitions(System2.INSTANCE, Arrays.asList(PropertyDefinition.builder("props").fields(PropertyFieldDefinition.build("foo1").name("Foo1").build(), PropertyFieldDefinition.build("foo2").name("Foo2").build()).build())), new Encryption(null), ImmutableMap.of("props", "1,2", "props.1.foo1", "a", "props.1.foo2", "b")) {
};
assertThat(config.get("props")).hasValue("1,2");
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Access to the multi-values/property set property 'props' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
logTester.clear();
assertThat(config.getStringArray("props")).containsExactly("1", "2");
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class DefaultConfigurationTest method getDefaultValues.
@Test
public void getDefaultValues() {
Configuration config = new DefaultConfiguration(new PropertyDefinitions(System2.INSTANCE, Arrays.asList(PropertyDefinition.builder("single").multiValues(false).defaultValue("default").build(), PropertyDefinition.builder("multiA").multiValues(true).defaultValue("foo,bar").build())), new Encryption(null), ImmutableMap.of()) {
};
assertThat(config.get("multiA")).hasValue("foo,bar");
assertThat(config.getStringArray("multiA")).containsExactly("foo", "bar");
assertThat(config.get("single")).hasValue("default");
assertThat(config.getStringArray("single")).containsExactly("default");
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class GenericCoverageSensorTest method loadAllReportPaths.
@Test
public void loadAllReportPaths() {
Map<String, String> settings = new HashMap<>();
settings.put(GenericCoverageSensor.REPORT_PATHS_PROPERTY_KEY, "report.xml,report2.xml");
PropertyDefinitions defs = new PropertyDefinitions(System2.INSTANCE, GenericCoverageSensor.properties());
DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), settings);
Set<String> reportPaths = new GenericCoverageSensor(config).loadReportPaths();
assertThat(reportPaths).containsOnly("report.xml", "report2.xml");
}
use of org.sonar.api.config.internal.Encryption in project sonarqube by SonarSource.
the class AlmSettingDaoTest method update.
@Test
public void update() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto almSettingDto = newGithubAlmSettingDto();
underTest.insert(dbSession, almSettingDto);
almSettingDto.setPrivateKey("updated private key");
almSettingDto.setAppId("updated app id");
almSettingDto.setUrl("updated url");
almSettingDto.setPersonalAccessToken("updated pat");
almSettingDto.setKey("updated key");
system2.setNow(NOW + 1);
underTest.update(dbSession, almSettingDto, false);
AlmSettingDto result = underTest.selectByUuid(dbSession, A_UUID).get();
assertThat(result).extracting(AlmSettingDto::getUuid, AlmSettingDto::getKey, AlmSettingDto::getRawAlm, AlmSettingDto::getUrl, AlmSettingDto::getAppId, s -> almSettingDto.getDecryptedPrivateKey(encryption), s -> almSettingDto.getDecryptedPersonalAccessToken(encryption), AlmSettingDto::getCreatedAt, AlmSettingDto::getUpdatedAt).containsExactly(A_UUID, almSettingDto.getKey(), ALM.GITHUB.getId(), almSettingDto.getUrl(), almSettingDto.getAppId(), almSettingDto.getDecryptedPrivateKey(encryption), almSettingDto.getDecryptedPersonalAccessToken(encryption), NOW, NOW + 1);
}
Aggregations