Skip to content

Commit 51f7e1d

Browse files
committed
Add missing test cases for the US region
1 parent 7556a8f commit 51f7e1d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

lib/src/test/java/org/sonarsource/scanner/lib/internal/endpoint/ScannerEndpointResolverTest.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ void should_recognize_sonarqube_cloud_endpoint_passed_through_host_url() {
4949
assertThat(endpoint.getApiEndpoint()).isEqualTo("https://api.sonarcloud.io");
5050
}
5151

52+
@Test
53+
void should_recognize_sonarqube_cloud_us_endpoint_passed_through_host_url() {
54+
var props = Map.of(ScannerProperties.HOST_URL, "https://sonarqube.us");
55+
56+
var endpoint = ScannerEndpointResolver.resolveEndpoint(props);
57+
58+
assertThat(endpoint.isSonarQubeCloud()).isTrue();
59+
assertThat(endpoint.getWebEndpoint()).isEqualTo("https://sonarqube.us");
60+
assertThat(endpoint.getApiEndpoint()).isEqualTo("https://api.sonarqube.us");
61+
}
62+
5263
@Test
5364
void should_recognize_sonarqube_server_endpoint_with_path() {
5465
var props = Map.of(ScannerProperties.HOST_URL, "https://next.sonarqube.com/sonarqube");
@@ -108,7 +119,7 @@ void should_fail_if_region_and_custom_url_defined() {
108119
}
109120

110121
@Test
111-
void should_not_fail_if_region_and_url_consistent() {
122+
void should_not_fail_if_region_and_cloud_url_consistent() {
112123
var props = Map.of(
113124
ScannerProperties.SONARQUBE_CLOUD_URL, "https://sonarqube.us",
114125
ScannerProperties.SONAR_REGION, "us"
@@ -121,6 +132,20 @@ void should_not_fail_if_region_and_url_consistent() {
121132
assertThat(endpoint.getApiEndpoint()).isEqualTo("https://api.sonarqube.us");
122133
}
123134

135+
@Test
136+
void should_not_fail_if_region_and_host_url_consistent() {
137+
var props = Map.of(
138+
ScannerProperties.HOST_URL, "https://sonarqube.us",
139+
ScannerProperties.SONAR_REGION, "us"
140+
);
141+
142+
var endpoint = ScannerEndpointResolver.resolveEndpoint(props);
143+
144+
assertThat(endpoint.isSonarQubeCloud()).isTrue();
145+
assertThat(endpoint.getWebEndpoint()).isEqualTo("https://sonarqube.us");
146+
assertThat(endpoint.getApiEndpoint()).isEqualTo("https://api.sonarqube.us");
147+
}
148+
124149
@Test
125150
void should_fail_if_only_api_endpoint_defined() {
126151
var props = Map.of(ScannerProperties.API_BASE_URL, "https://api.preprod.sonarcloud.io");

0 commit comments

Comments
 (0)