Skip to content

Commit f4eef04

Browse files
committed
Update Orchestrator to support SQ 8.6 (enforce authentication)
1 parent dd3013c commit f4eef04

6 files changed

+21
-16
lines changed

its/tests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>org.sonarsource.orchestrator</groupId>
2626
<artifactId>sonar-orchestrator</artifactId>
27-
<version>3.31.0.2646</version>
27+
<version>3.34.0.2692</version>
2828
<scope>test</scope>
2929
</dependency>
3030
<dependency>

its/tests/src/test/java/its/CommercialAnalyzerTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class CommercialAnalyzerTest extends AbstractConnectedTest {
6060

6161
@ClassRule
6262
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
63+
.defaultForceAuthentication()
6364
.setSonarVersion(SONAR_VERSION)
6465
.setEdition(Edition.ENTERPRISE)
6566
.restoreProfileAtStartup(FileLocation.ofClasspath("/c-sonarlint.xml"))

its/tests/src/test/java/its/ConnectedFileMatchingTest.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class ConnectedFileMatchingTest extends AbstractConnectedTest {
5858

5959
@ClassRule
6060
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
61+
.defaultForceAuthentication()
6162
.setSonarVersion(SONAR_VERSION)
6263
.addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", ItUtils.javaVersion))
6364
.build();
@@ -74,7 +75,7 @@ public class ConnectedFileMatchingTest extends AbstractConnectedTest {
7475
private static Path sonarUserHome;
7576

7677
private ConnectedSonarLintEngine engine;
77-
private List<String> logs = new ArrayList<>();
78+
private final List<String> logs = new ArrayList<>();
7879

7980
@BeforeClass
8081
public static void prepare() {
@@ -146,6 +147,7 @@ private ServerConfiguration getServerConfig() {
146147
.build();
147148
}
148149

150+
@Override
149151
protected ConnectedAnalysisConfiguration createAnalysisConfiguration(String projectKey, String projectDirName, String filePath, String... properties) throws IOException {
150152
Path projectDir = Paths.get("projects/" + projectDirName).toAbsolutePath();
151153
List<ClientInputFile> filesToAnalyze = clientTools.collectAllFiles(projectDir)
@@ -164,6 +166,9 @@ protected ConnectedAnalysisConfiguration createAnalysisConfiguration(String proj
164166
private static void analyzeMavenProject(String projectDirName) {
165167
Path projectDir = Paths.get("projects/" + projectDirName).toAbsolutePath();
166168
Path pom = projectDir.resolve("pom.xml");
167-
ORCHESTRATOR.executeBuild(MavenBuild.create(pom.toFile()).setCleanPackageSonarGoals());
169+
ORCHESTRATOR.executeBuild(MavenBuild.create(pom.toFile())
170+
.setCleanPackageSonarGoals()
171+
.setProperty("sonar.login", com.sonar.orchestrator.container.Server.ADMIN_LOGIN)
172+
.setProperty("sonar.password", com.sonar.orchestrator.container.Server.ADMIN_PASSWORD));
168173
}
169174
}

its/tests/src/test/java/its/ConnectedModeExcludeByVersionTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static void beforeClass() {
6262

6363
@Rule
6464
public Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
65+
.defaultForceAuthentication()
6566
.setSonarVersion(SONAR_VERSION)
6667
.addPlugin(MavenLocation.of("org.sonarsource.python", "sonar-python-plugin", "1.9.0.2010")).build();
6768

@@ -74,7 +75,7 @@ public static void beforeClass() {
7475
private static Path sonarUserHome;
7576

7677
private ConnectedSonarLintEngine engine;
77-
private List<String> logs = new ArrayList<>();
78+
private final List<String> logs = new ArrayList<>();
7879

7980
@Before
8081
public void prepare() throws Exception {

its/tests/src/test/java/its/ConnectedModeRequirementsTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class ConnectedModeRequirementsTest extends AbstractConnectedTest {
6666

6767
@ClassRule
6868
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv().setSonarVersion(SONAR_VERSION)
69+
.defaultForceAuthentication()
6970
.addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", ItUtils.javaVersion))
7071
.addPlugin(MavenLocation.of("org.sonarsource.php", "sonar-php-plugin", ItUtils.phpVersion))
7172
.addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", ItUtils.javascriptVersion))

its/tests/src/test/java/its/ConnectedModeTest.java

+9-12
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.sonarqube.ws.client.WsClient;
6565
import org.sonarqube.ws.client.WsRequest;
6666
import org.sonarqube.ws.client.WsResponse;
67-
import org.sonarqube.ws.client.permissions.RemoveGroupRequest;
6867
import org.sonarqube.ws.client.qualityprofiles.ActivateRuleRequest;
6968
import org.sonarqube.ws.client.qualityprofiles.SearchRequest;
7069
import org.sonarqube.ws.client.settings.ResetRequest;
@@ -74,8 +73,8 @@
7473
import org.sonarsource.sonarlint.core.NodeJsHelper;
7574
import org.sonarsource.sonarlint.core.WsHelperImpl;
7675
import org.sonarsource.sonarlint.core.client.api.common.Language;
77-
import org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults;
7876
import org.sonarsource.sonarlint.core.client.api.common.TextRange;
77+
import org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults;
7978
import org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration;
8079
import org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine;
8180
import org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine.State;
@@ -119,6 +118,7 @@ private static String javaRuleKey(String key) {
119118

120119
@ClassRule
121120
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
121+
.defaultForceAuthentication()
122122
.setSonarVersion(SONAR_VERSION)
123123
.addPlugin(MavenLocation.of("org.sonarsource.java", "sonar-java-plugin", ItUtils.javaVersion))
124124
.addPlugin(MavenLocation.of("org.sonarsource.python", "sonar-python-plugin", ItUtils.pythonVersion))
@@ -310,8 +310,7 @@ public void updateNoAuth() {
310310
fail("Exception expected");
311311
} catch (Exception e) {
312312
assertThat(e).hasMessage("Not authorized. Please check server credentials.");
313-
}
314-
finally {
313+
} finally {
315314
adminWsClient.settings().set(new SetRequest().setKey("sonar.forceAuthentication").setValue("false"));
316315
}
317316
}
@@ -486,7 +485,8 @@ public void canFetchHotspot() throws InvalidProtocolBufferException {
486485
SonarLintWsClient slClient = new SonarLintWsClient(getServerConfig());
487486
SecurityHotspotsService securityHotspotsService = new SecurityHotspotsService(slClient);
488487

489-
Optional<RemoteHotspot> remoteHotspot = securityHotspotsService.fetch(new GetSecurityHotspotRequestParams(getFirstHotspotKey(slClient, PROJECT_KEY_JAVA_HOTSPOT), PROJECT_KEY_JAVA_HOTSPOT));
488+
Optional<RemoteHotspot> remoteHotspot = securityHotspotsService
489+
.fetch(new GetSecurityHotspotRequestParams(getFirstHotspotKey(slClient, PROJECT_KEY_JAVA_HOTSPOT), PROJECT_KEY_JAVA_HOTSPOT));
490490

491491
assertThat(remoteHotspot).isNotEmpty();
492492
RemoteHotspot actualHotspot = remoteHotspot.get();
@@ -826,16 +826,13 @@ private ServerConfiguration getServerConfig(boolean redirect) {
826826
.build();
827827
}
828828

829-
private static void removeGroupPermission(String groupName, String permission) {
830-
adminWsClient.permissions().removeGroup(new RemoveGroupRequest()
831-
.setGroupName(groupName)
832-
.setPermission(permission));
833-
}
834-
835829
private static void analyzeMavenProject(String projectDirName) {
836830
Path projectDir = Paths.get("projects/" + projectDirName).toAbsolutePath();
837831
Path pom = projectDir.resolve("pom.xml");
838-
ORCHESTRATOR.executeBuild(MavenBuild.create(pom.toFile()).setCleanPackageSonarGoals());
832+
ORCHESTRATOR.executeBuild(MavenBuild.create(pom.toFile())
833+
.setCleanPackageSonarGoals()
834+
.setProperty("sonar.login", com.sonar.orchestrator.container.Server.ADMIN_LOGIN)
835+
.setProperty("sonar.password", com.sonar.orchestrator.container.Server.ADMIN_PASSWORD));
839836
}
840837

841838
}

0 commit comments

Comments
 (0)