Search in sources :

Example 1 with CreateRequest

use of org.sonarqube.ws.client.users.CreateRequest in project sonarlint-core by SonarSource.

the class ConnectedDeveloperIssueDownloadTest method prepare.

@BeforeClass
public static void prepare() throws IOException {
    var adminWsClient = newAdminWsClient(ORCHESTRATOR);
    adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
    sonarUserHome = temp.newFolder().toPath();
    engine = new ConnectedSonarLintEngineImpl(ConnectedGlobalConfiguration.builder().setConnectionId("orchestrator").setSonarLintUserHome(sonarUserHome).setExtraProperties(new HashMap<>()).build());
    engine.update(endpointParams(ORCHESTRATOR), sqHttpClient(), null);
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Sample Xoo");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "SonarLint IT Xoo");
    engine.updateProject(endpointParams(ORCHESTRATOR), sqHttpClient(), PROJECT_KEY, false, LONG_BRANCH, null);
    // main branch
    analyzeProject("sample-xoo-v1");
    // short living branch
    analyzeProject("sample-xoo-v1", "sonar.branch.name", SHORT_BRANCH);
    // long living branch
    analyzeProject("sample-xoo-v1", "sonar.branch.name", LONG_BRANCH);
    // Second analysis with less issues to have closed issues on the branch
    analyzeProject("sample-xoo-v2", "sonar.branch.name", LONG_BRANCH);
    // Mark a few issues as closed WF and closed FP on the branch
    var issueSearchResponse = adminWsClient.issues().search(new SearchRequest().setStatuses(asList("OPEN")).setTypes(asList("CODE_SMELL")).setComponentKeys(asList(PROJECT_KEY)).setBranch(LONG_BRANCH));
    wfIssue = issueSearchResponse.getIssues(0);
    fpIssue = issueSearchResponse.getIssues(1);
    // Change severity and type
    overridenSeverityIssue = issueSearchResponse.getIssues(2);
    overridenTypeIssue = issueSearchResponse.getIssues(3);
    adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(wfIssue.getKey()).setTransition("wontfix"));
    adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(fpIssue.getKey()).setTransition("falsepositive"));
    adminWsClient.issues().setSeverity(new SetSeverityRequest().setIssue(overridenSeverityIssue.getKey()).setSeverity("BLOCKER"));
    adminWsClient.issues().setType(new SetTypeRequest().setIssue(overridenTypeIssue.getKey()).setType("BUG"));
    // Ensure an hostpot has been reported on server side
    if (ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(8, 2)) {
        assertThat(adminWsClient.hotspots().search(new org.sonarqube.ws.client.hotspots.SearchRequest().setProjectKey(PROJECT_KEY).setBranch(LONG_BRANCH)).getHotspotsList()).isNotEmpty();
    } else {
        assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("SECURITY_HOTSPOT")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
    }
}
Also used : SearchRequest(org.sonarqube.ws.client.issues.SearchRequest) HashMap(java.util.HashMap) CreateRequest(org.sonarqube.ws.client.users.CreateRequest) SetSeverityRequest(org.sonarqube.ws.client.issues.SetSeverityRequest) ConnectedSonarLintEngineImpl(org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl) SetTypeRequest(org.sonarqube.ws.client.issues.SetTypeRequest) DoTransitionRequest(org.sonarqube.ws.client.issues.DoTransitionRequest) BeforeClass(org.junit.BeforeClass)

Example 2 with CreateRequest

use of org.sonarqube.ws.client.users.CreateRequest in project sonarlint-core by SonarSource.

the class ConnectedModeTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    adminWsClient = newAdminWsClient(ORCHESTRATOR);
    sonarUserHome = temp.newFolder().toPath();
    adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA, "Sample Java");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_PACKAGE, "Sample Java Package");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_HOTSPOT, "Sample Java Hotspot");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_EMPTY, "Sample Java Empty");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_MARKDOWN, "Sample Java Markdown");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_PHP, "Sample PHP");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVASCRIPT, "Sample Javascript");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_CUSTOM, "Sample Java Custom");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_PYTHON, "Sample Python");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_WEB, "Sample Web");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_JAVA_CUSTOM_SENSOR, "Sample Java Custom");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_GLOBAL_EXTENSION, "Sample Global Extension");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_RUBY, "Sample Ruby");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_KOTLIN, "Sample Kotlin");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_SCALA, "Sample Scala");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_XML, "Sample XML");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA, "java", "SonarLint IT Java");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_PACKAGE, "java", "SonarLint IT Java Package");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_HOTSPOT, "java", "SonarLint IT Java Hotspot");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_EMPTY, "java", "SonarLint IT Java Empty");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_MARKDOWN, "java", "SonarLint IT Java Markdown");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_PHP, "php", "SonarLint IT PHP");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVASCRIPT, "js", "SonarLint IT Javascript");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_CUSTOM, "java", "SonarLint IT Java Custom");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_PYTHON, "py", "SonarLint IT Python");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_WEB, "web", "SonarLint IT Web");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_JAVA_CUSTOM_SENSOR, "java", "SonarLint IT Custom Sensor");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_RUBY, "ruby", "SonarLint IT Ruby");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_KOTLIN, "kotlin", "SonarLint IT Kotlin");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_SCALA, "scala", "SonarLint IT Scala");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_XML, "xml", "SonarLint IT XML");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_GLOBAL_EXTENSION, "cobol", "SonarLint IT Global Extension");
    // Build project to have bytecode
    ORCHESTRATOR.executeBuild(MavenBuild.create(new File("projects/sample-java/pom.xml")).setGoals("clean compile"));
}
Also used : CreateRequest(org.sonarqube.ws.client.users.CreateRequest) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with CreateRequest

use of org.sonarqube.ws.client.users.CreateRequest in project sonarlint-core by SonarSource.

the class CommercialAnalyzerTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    adminWsClient = newAdminWsClient(ORCHESTRATOR);
    adminWsClient.settings().set(new SetRequest().setKey("sonar.forceAuthentication").setValue("true"));
    sonarUserHome = temp.newFolder().toPath();
    removeGroupPermission("anyone", "scan");
    adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_C, "Sample C");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_COBOL, "Sample Cobol");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_TSQL, "Sample TSQL");
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY_APEX, "Sample APEX");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_C, "c", "SonarLint IT C");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_COBOL, "cobol", "SonarLint IT Cobol");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_TSQL, "tsql", "SonarLint IT TSQL");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY_APEX, "apex", "SonarLint IT APEX");
}
Also used : SetRequest(org.sonarqube.ws.client.settings.SetRequest) CreateRequest(org.sonarqube.ws.client.users.CreateRequest) BeforeClass(org.junit.BeforeClass)

Example 4 with CreateRequest

use of org.sonarqube.ws.client.users.CreateRequest in project sonarlint-core by SonarSource.

the class ConnectedCommunityIssueDownloadTest method prepare.

@BeforeClass
public static void prepare() {
    var adminWsClient = newAdminWsClient(ORCHESTRATOR);
    adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Sample Xoo");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "SonarLint IT Xoo");
    analyzeProject("sample-xoo-v1");
    // Second analysis with less issues to have closed issues
    analyzeProject("sample-xoo-v2");
    // Mark a few issues as closed WF and closed FP
    var issueSearchResponse = adminWsClient.issues().search(new SearchRequest().setStatuses(asList("OPEN")).setTypes(asList("CODE_SMELL")).setComponentKeys(asList(PROJECT_KEY)));
    wfIssue = issueSearchResponse.getIssues(0);
    fpIssue = issueSearchResponse.getIssues(1);
    // Change severity and type
    overridenSeverityIssue = issueSearchResponse.getIssues(2);
    overridenTypeIssue = issueSearchResponse.getIssues(3);
    adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(wfIssue.getKey()).setTransition("wontfix"));
    adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(fpIssue.getKey()).setTransition("falsepositive"));
    adminWsClient.issues().setSeverity(new SetSeverityRequest().setIssue(overridenSeverityIssue.getKey()).setSeverity("BLOCKER"));
    adminWsClient.issues().setType(new SetTypeRequest().setIssue(overridenTypeIssue.getKey()).setType("BUG"));
    // Ensure an hostpot has been reported on server side
    if (ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(8, 2)) {
        assertThat(adminWsClient.hotspots().search(new org.sonarqube.ws.client.hotspots.SearchRequest().setProjectKey(PROJECT_KEY)).getHotspotsList()).isNotEmpty();
    } else {
        assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("SECURITY_HOTSPOT")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
    }
}
Also used : SearchRequest(org.sonarqube.ws.client.issues.SearchRequest) CreateRequest(org.sonarqube.ws.client.users.CreateRequest) SetSeverityRequest(org.sonarqube.ws.client.issues.SetSeverityRequest) SetTypeRequest(org.sonarqube.ws.client.issues.SetTypeRequest) DoTransitionRequest(org.sonarqube.ws.client.issues.DoTransitionRequest) BeforeClass(org.junit.BeforeClass)

Example 5 with CreateRequest

use of org.sonarqube.ws.client.users.CreateRequest in project sonarlint-core by SonarSource.

the class TaintVulnerabilitiesDownloadTest method prepare.

@Before
public void prepare() throws Exception {
    var adminWsClient = newAdminWsClient(ORCHESTRATOR);
    adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
    ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Java With Taint Vulnerabilities");
    ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "java", "SonarLint Taint Java");
    analyzeMavenProject(PROJECT_KEY);
    // Ensure a vulnerability has been reported on server side
    assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("VULNERABILITY")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
    sonarUserHome = temp.newFolder().toPath();
    engine = new ConnectedSonarLintEngineImpl(ConnectedGlobalConfiguration.builder().setConnectionId("orchestrator").setSonarLintUserHome(sonarUserHome).setLogOutput((msg, level) -> logs.add(msg)).setExtraProperties(new HashMap<>()).build());
}
Also used : SearchRequest(org.sonarqube.ws.client.issues.SearchRequest) HashMap(java.util.HashMap) CreateRequest(org.sonarqube.ws.client.users.CreateRequest) ConnectedSonarLintEngineImpl(org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl) Before(org.junit.Before)

Aggregations

CreateRequest (org.sonarqube.ws.client.users.CreateRequest)5 BeforeClass (org.junit.BeforeClass)4 SearchRequest (org.sonarqube.ws.client.issues.SearchRequest)3 HashMap (java.util.HashMap)2 DoTransitionRequest (org.sonarqube.ws.client.issues.DoTransitionRequest)2 SetSeverityRequest (org.sonarqube.ws.client.issues.SetSeverityRequest)2 SetTypeRequest (org.sonarqube.ws.client.issues.SetTypeRequest)2 ConnectedSonarLintEngineImpl (org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl)2 File (java.io.File)1 Before (org.junit.Before)1 SetRequest (org.sonarqube.ws.client.settings.SetRequest)1