use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class SettingsEncryptionTest method testEncryptedProperty.
/**
* SONAR-2084
* SONAR-4061
*/
@Test
public void testEncryptedProperty() throws Exception {
SonarScanner build = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setProperty("sonar.secretKeyPath", pathToValidSecretKey()).setProperty("sonar.login", "admin").setProperty("sonar.password", // wrong password
"{aes}wrongencryption==").setProperty("encryptedProperty", "{aes}9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
BuildResult result = orchestrator.executeBuildQuietly(build);
assertThat(result.getStatus()).isNotEqualTo(0);
assertThat(result.getLogs()).contains("Fail to decrypt the property sonar.password. Please check your secret key");
build = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setProperty("sonar.secretKeyPath", pathToValidSecretKey()).setProperty("sonar.login", "{aes}evRHXHsEyPr5RjEuxUJcHA==").setProperty("sonar.password", "{aes}evRHXHsEyPr5RjEuxUJcHA==").setProperty("encryptedProperty", "{aes}9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
// no error
orchestrator.executeBuild(build);
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class TempFolderTest method should_create_in_temp_folder.
// SONAR-4748
@Test
public void should_create_in_temp_folder() throws IOException {
File projectDir = ItUtils.projectDir("shared/xoo-sample");
BuildResult result = scan();
assertThat(result.getLogs()).doesNotContain("Creating temp directory:");
assertThat(result.getLogs()).doesNotContain("Creating temp file:");
result = scan("sonar.createTempFiles", "true");
assertThat(result.getLogs()).contains("Creating temp directory: " + projectDir.getCanonicalPath() + File.separator + ".sonar" + File.separator + ".sonartmp" + File.separator + "sonar-it");
assertThat(result.getLogs()).contains("Creating temp file: " + projectDir.getCanonicalPath() + File.separator + ".sonar" + File.separator + ".sonartmp" + File.separator + "sonar-it");
// Verify temp folder is deleted after analysis
assertThat(new File(projectDir, ".sonar/.sonartmp/sonar-it")).doesNotExist();
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class MultiLanguageTest method test_sonar_runner_inspection.
/**
* SONAR-926
* SONAR-5069
*/
@Test
public void test_sonar_runner_inspection() {
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line.xml"));
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line-xoo2.xml"));
orchestrator.getServer().provisionProject("multi-language-sample", "multi-language-sample");
orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo", "one-issue-per-line");
orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo2", "one-issue-per-line-xoo2");
SonarScanner build = SonarScanner.create().setProjectDir(ItUtils.projectDir("analysis/xoo-multi-languages"));
BuildResult result = orchestrator.executeBuild(build);
// 4 files: 1 .xoo, 1.xoo2, 2 .measures
assertThat(result.getLogs()).contains("4 files indexed");
assertThat(result.getLogs()).contains("Quality profile for xoo: one-issue-per-line");
assertThat(result.getLogs()).contains("Quality profile for xoo2: one-issue-per-line-xoo2");
// modules
Map<String, Double> measures = getMeasuresAsDoubleByMetricKey(orchestrator, "multi-language-sample", "files", "violations");
assertThat(measures.get("files")).isEqualTo(2);
assertThat(measures.get("violations")).isEqualTo(26);
assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo", "violations")).isEqualTo(13);
assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo2", "violations")).isEqualTo(13);
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class PermissionTest method scanner_can_authenticate_with_authentication_token.
@Test
public void scanner_can_authenticate_with_authentication_token() {
createUserWithProvisioningAndScanPermissions();
String tokenName = "For test";
WsUserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateWsRequest().setLogin(A_LOGIN).setName(tokenName));
SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
sampleProject.setProperties("sonar.login", generateWsResponse.getToken(), "sonar.password", "");
BuildResult buildResult = orchestrator.executeBuild(sampleProject);
assertThat(buildResult.isSuccess()).isTrue();
userTokensWsClient.revoke(new RevokeWsRequest().setLogin(A_LOGIN).setName(tokenName));
}
use of com.sonar.orchestrator.build.BuildResult in project sonarqube by SonarSource.
the class QualityGateTest method conditions_on_multiple_metric_types.
@Test
public void conditions_on_multiple_metric_types() throws IOException {
QualityGate allTypes = qgClient().create("AllMetricTypes");
qgClient().createCondition(NewCondition.create(allTypes.id()).metricKey("ncloc").operator("GT").warningThreshold("10"));
qgClient().createCondition(NewCondition.create(allTypes.id()).metricKey("duplicated_lines_density").operator("GT").warningThreshold("20"));
qgClient().setDefault(allTypes.id());
try {
SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample")).setProperty("sonar.cpd.xoo.minimumLines", "2").setProperty("sonar.cpd.xoo.minimumTokens", "5");
BuildResult buildResult = orchestrator.executeBuild(build);
verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_WARN);
Measure alertStatus = getGateStatusMeasure();
assertThat(alertStatus.getValue()).isEqualTo("WARN");
String qualityGateDetailJson = ItUtils.getMeasure(orchestrator, PROJECT_KEY, "quality_gate_details").getValue();
assertThat(QualityGateDetails.parse(qualityGateDetailJson).getConditions()).extracting(QualityGateDetails.Conditions::getMetric, QualityGateDetails.Conditions::getOp, QualityGateDetails.Conditions::getWarning).contains(tuple("ncloc", "GT", "10"), tuple("duplicated_lines_density", "GT", "20"));
} finally {
qgClient().unsetDefault();
qgClient().destroy(allTypes.id());
}
}
Aggregations