Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/2607[#2607]: Align tool help for corepack
* https://github.com/devonfw/IDEasy/issues/2322[#2322]: Use a consistent IDEasy icon across all operating systems
* https://github.com/devonfw/IDEasy/issues/1209[#1209]: Improve confusing migration version message of `ide status`
* https://github.com/devonfw/IDEasy/issues/2714[#2714]: oc url-updater misses all versions since OpenShift 4.10

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/51?closed=1[milestone 2026.10.001].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class OcUrlUpdater extends WebsiteUrlUpdater {
private static final String DOWNLOAD_BASE_URL = "https://mirror.openshift.com";
private static final String VERSION_BASE_URL = "https://mirror.openshift.com";

private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d\\.\\d\\.\\d*)");
// Match only exact version directories (e.g. 4.22.19), skipping -rc folders and partial version prefixes.
private static final Pattern VERSION_PATTERN = Pattern.compile("(?<=href=\")(\\d+\\.\\d+\\.\\d+)(?![\\w.-])");

/**
* The Constructor.
Expand All @@ -22,6 +23,16 @@ public OcUrlUpdater() {
super(DOWNLOAD_BASE_URL, VERSION_BASE_URL);
}

/**
* Package-private constructor used for testing {@link OcUrlUpdater}.
*
* @param downloadBaseUrl mock URL used as download base.
* @param versionBaseUrl mock URL used as version base.
*/
OcUrlUpdater(String downloadBaseUrl, String versionBaseUrl) {
super(downloadBaseUrl, versionBaseUrl);
}

@Override
public String getTool() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.devonfw.tools.ide.url.tool.oc;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.any;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;

import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import com.devonfw.tools.ide.url.model.folder.UrlRepository;
import com.devonfw.tools.ide.url.updater.AbstractUrlUpdaterTest;
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
import com.github.tomakehurst.wiremock.junit5.WireMockTest;

/**
* Test of {@link OcUrlUpdater}.
*/
@WireMockTest
class OcUrlUpdaterTest extends AbstractUrlUpdaterTest {

/**
* Tests that {@link OcUrlUpdater} picks up versions with a multi-digit minor version number (e.g. 4.10.0, released after OpenShift 4.10) and skips
* release-candidate folders (e.g. 5.0.0-rc.0). Regression test for <a href="https://github.com/devonfw/IDEasy/issues/2714">#2714</a>.
*
* @param tempDir path to a temporary directory.
* @param wmRuntimeInfo the {@link WireMockRuntimeInfo}.
*/
@Test
void testOcUrlUpdaterPicksUpMultiDigitMinorVersions(@TempDir Path tempDir, WireMockRuntimeInfo wmRuntimeInfo) {

// arrange
stubFor(get(urlEqualTo("/pub/openshift-v4/clients/ocp/"))
.willReturn(aResponse()
.withStatus(200)
.withBody(readAndResolve(
PATH_INTEGRATION_TEST.resolve("OcUrlUpdater").resolve("ocp-index.html"),
wmRuntimeInfo))));

stubFor(any(urlMatching("/pub/openshift-v4/clients/ocp/[0-9.]+/openshift-client-.*"))
.willReturn(aResponse().withStatus(200).withBody(DOWNLOAD_CONTENT)));

UrlRepository urlRepository = UrlRepository.load(tempDir);
OcUrlUpdater updater = new OcUrlUpdater(
wmRuntimeInfo.getHttpBaseUrl(),
wmRuntimeInfo.getHttpBaseUrl());

// act
update(updater, urlRepository);

// assert
Path ocDir = tempDir.resolve("oc").resolve("oc");
// single-digit minor version still works
assertUrlVersionOsX64(ocDir.resolve("4.9.59"));
// multi-digit minor versions (the regression, released after OpenShift 4.10) are now picked up
assertUrlVersionOsX64(ocDir.resolve("4.10.0"));
assertUrlVersionOsX64(ocDir.resolve("4.22.19"));
// release-candidate folders must not be extracted as a bogus stable version
assertThat(ocDir.resolve("5.0.0")).doesNotExist();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head><title>Index of /pub/openshift-v4/clients/ocp/</title></head>
<body>
<h1>Index of /pub/openshift-v4/clients/ocp/</h1>
<pre>
<a href="../">../</a>
<a href="4.9.59/">4.9.59/</a>
<a href="4.10.0/">4.10.0/</a>
<a href="4.22.19/">4.22.19/</a>
<a href="5.0.0-rc.0/">5.0.0-rc.0/</a>
</pre>
</body>
</html>
Loading