aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Giffon <eric.giffon@sonarsource.com>2024-02-06 11:12:32 +0100
committersonartech <sonartech@sonarsource.com>2024-02-07 20:02:50 +0000
commitf26bae81f1792e329c07f28a1739275d02e4f48a (patch)
tree990900d90bb7835b399a7b8fde4473bb2095e4b6
parent4a2eeb85b6d480da5f9b96305465e26d91c3a1aa (diff)
downloadsonarqube-f26bae81f1792e329c07f28a1739275d02e4f48a.tar.gz
sonarqube-f26bae81f1792e329c07f28a1739275d02e4f48a.zip
SONAR-20773 Update the update-center URL
-rw-r--r--server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java12
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java19
-rw-r--r--sonar-application/src/main/assembly/conf/sonar.properties2
3 files changed, 17 insertions, 16 deletions
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
index a0726e20501..48561139088 100644
--- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
+++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
@@ -38,21 +38,21 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer;
import org.sonar.updatecenter.common.UpdateCenterDeserializer.Mode;
/**
- * HTTP client to load data from the remote update center hosted at https://update.sonarsource.org.
+ * HTTP client to load data from the remote update center hosted at https://downloads.sonarsource.com/?prefix=sonarqube/update
*
* @since 2.4
*/
@Properties({
@Property(
key = UpdateCenterClient.URL_PROPERTY,
- defaultValue = "https://update.sonarsource.org/update-center.properties",
+ defaultValue = UpdateCenterClient.URL_DEFAULT_VALUE,
name = "Update Center URL",
category = "Update Center",
// hidden from UI
global = false),
@Property(
key = UpdateCenterClient.CACHE_TTL_PROPERTY,
- defaultValue = "3600000",
+ defaultValue = UpdateCenterClient.CACHE_TTL_DEFAULT_VALUE,
name = "Update Center cache time-to-live in milliseconds",
category = "Update Center",
// hidden from UI
@@ -61,8 +61,10 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer.Mode;
public class UpdateCenterClient {
private static final Logger LOG = LoggerFactory.getLogger(UpdateCenterClient.class);
- public static final String URL_PROPERTY = "sonar.updatecenter.url";
- public static final String CACHE_TTL_PROPERTY = "sonar.updatecenter.cache.ttl";
+ static final String URL_PROPERTY = "sonar.updatecenter.url";
+ static final String URL_DEFAULT_VALUE = "https://downloads.sonarsource.com/sonarqube/update/update-center.properties";
+ static final String CACHE_TTL_PROPERTY = "sonar.updatecenter.cache.ttl";
+ static final String CACHE_TTL_DEFAULT_VALUE = "3600000";
private final long periodInMilliseconds;
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
index 2820bd5fea4..3e5ff36921d 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
@@ -38,11 +38,10 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.sonar.server.plugins.UpdateCenterClient.*;
public class UpdateCenterClientTest {
- private static final String BASE_URL = "https://update.sonarsource.org";
- private static final String DEFAULT_CACHE_TTL = "3600000";
private UriReader reader = mock(UriReader.class);
private MapSettings settings = new MapSettings();
private UpdateCenterClient underTest;
@@ -50,17 +49,17 @@ public class UpdateCenterClientTest {
@Before
public void startServer() throws Exception {
reader = mock(UriReader.class);
- settings.setProperty(UpdateCenterClient.URL_PROPERTY, BASE_URL);
+ settings.setProperty(URL_PROPERTY, URL_DEFAULT_VALUE);
settings.setProperty(ProcessProperties.Property.SONAR_UPDATECENTER_ACTIVATE.getKey(), true);
- settings.setProperty(UpdateCenterClient.CACHE_TTL_PROPERTY, DEFAULT_CACHE_TTL);
+ settings.setProperty(CACHE_TTL_PROPERTY, CACHE_TTL_DEFAULT_VALUE);
underTest = new UpdateCenterClient(reader, settings.asConfig());
}
@Test
public void downloadUpdateCenter() throws URISyntaxException {
- when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("publicVersions=2.2,2.3");
+ when(reader.readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8)).thenReturn("publicVersions=2.2,2.3");
UpdateCenter plugins = underTest.getUpdateCenter().get();
- verify(reader, times(1)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
+ verify(reader, times(1)).readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8);
assertThat(plugins.getSonar().getVersions()).containsOnly(Version.create("2.2"), Version.create("2.3"));
assertThat(underTest.getLastRefreshDate()).isNotNull();
}
@@ -78,22 +77,22 @@ public class UpdateCenterClientTest {
@Test
public void cache_data() throws Exception {
- when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
+ when(reader.readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
underTest.getUpdateCenter();
underTest.getUpdateCenter();
- verify(reader, times(1)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
+ verify(reader, times(1)).readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8);
}
@Test
public void forceRefresh() throws Exception {
- when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
+ when(reader.readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
underTest.getUpdateCenter();
underTest.getUpdateCenter(true);
- verify(reader, times(2)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
+ verify(reader, times(2)).readString(new URI(URL_DEFAULT_VALUE), StandardCharsets.UTF_8);
}
@Test
diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties
index 1e28915db03..f8ba2026c2c 100644
--- a/sonar-application/src/main/assembly/conf/sonar.properties
+++ b/sonar-application/src/main/assembly/conf/sonar.properties
@@ -297,7 +297,7 @@
#--------------------------------------------------------------------------------------------------
# UPDATE CENTER
-# Update Center requires an internet connection to request https://update.sonarsource.org
+# Update Center requires an internet connection to request https://downloads.sonarsource.com/?prefix=sonarqube/update
# It is enabled by default.
#sonar.updatecenter.activate=true