Update dependency org.jenkins-ci:jenkins to v2.1413.v65a_1fb_5a_dd02 (#27389)

* Update dependency org.jenkins-ci:jenkins to v2.1413.v65a_1fb_5a_dd02

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Reset system properties on every DefaultConfidentialStoreTest

Remove the test execution order dependency that was exposed by:

* https://github.com/jenkinsci/jenkins/pull/27389

* Split dependencyNotInstalled test into a separate test class

Simpler than identifying the state that is retained between tests.

* Reuse shared PluginWrapper test support

Co-authored-by: MarkEWaite <156685+MarkEWaite@users.noreply.github.com>

* Use AfterEach instead of BeforeEach to clear system properties

https://github.com/jenkinsci/jenkins/pull/27389#discussion_r4121913093

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MarkEWaite <156685+MarkEWaite@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-03 12:08:08 +01:00
1 parent 76b50a4b46
commit 7328235680
5 files changed
+163 -126

No files matched your search

@@ -0,0 +1,27 @@
package hudson;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import org.junit.jupiter.api.Test;
/**
* Split from PluginWrapperTest to isolate dependencyNotInstalled.
*
* The upgrade to Apache Maven Surefire 3.6.0 changed the execution
* order of the tests and that change caused dependencyNotInstalled to
* fail. Rather than locate the test ordering issue in the existing
* PluginWrapperTest, this takes the easy route and defines a new test
* class for the failing test.
*/
class PluginWrapper2Test extends PluginWrapperTestSupport {
@Test
void dependencyNotInstalled() {
PluginWrapper pw = pluginWrapper("dependee").deps("dependency:42").buildLoaded();
final IOException ex = assertThrows(IOException.class, pw::resolvePluginDependencies);
assertContains(ex, "Failed to load: Dependee (dependee 42)", "Plugin is missing: dependency (42)");
}
}
@@ -1,54 +1,23 @@
package hudson;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import hudson.remoting.Callable;
import hudson.remoting.Which;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import jenkins.model.Jenkins;
import jenkins.util.URLClassLoader2;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.Issue;
import org.mockito.stubbing.Answer;
class PluginWrapperTest {
private static Locale loc;
@BeforeAll
static void before() {
Jenkins.VERSION = "2.0"; // Some value needed - tests will overwrite if necessary
loc = Locale.getDefault();
Locale.setDefault(new Locale("en", "GB"));
}
@AfterAll
static void after() {
if (loc != null) {
Locale.setDefault(loc);
}
}
class PluginWrapperTest extends PluginWrapperTestSupport {
@Test
void dependencyTest() {
@@ -76,14 +45,6 @@ class PluginWrapperTest {
assertContains(ex, "Failed to load: Fake (fake 42)", "Jenkins (3.0) or higher required");
}
@Test
void dependencyNotInstalled() {
PluginWrapper pw = pluginWrapper("dependee").deps("dependency:42").buildLoaded();
final IOException ex = assertThrows(IOException.class, pw::resolvePluginDependencies);
assertContains(ex, "Failed to load: Dependee (dependee 42)", "Plugin is missing: dependency (42)");
}
@Test
void dependencyOutdated() {
pluginWrapper("dependency").version("3").buildLoaded();
@@ -123,91 +84,6 @@ class PluginWrapperTest {
e2size - e1size, is(1));
}
private void assertContains(Throwable ex, String... patterns) {
String msg = ex.getMessage();
for (String pattern : patterns) {
assertThat(msg, containsString(pattern));
}
}
private PluginWrapperBuilder pluginWrapper(String name) {
return new PluginWrapperBuilder(name);
}
// per test
private final HashMap<String, PluginWrapper> plugins = new HashMap<>();
private final PluginManager pm = mock(PluginManager.class);
{
when(pm.getPlugin(any(String.class))).thenAnswer((Answer<PluginWrapper>) invocation -> plugins.get(invocation.getArguments()[0]));
}
private final class PluginWrapperBuilder {
private final String name;
private String version = "42";
private String requiredCoreVersion = "1.0";
private final List<PluginWrapper.Dependency> deps = new ArrayList<>();
private final List<PluginWrapper.Dependency> optDeps = new ArrayList<>();
private ClassLoader cl = null;
private PluginWrapperBuilder(String name) {
this.name = Objects.requireNonNull(name);
}
public PluginWrapperBuilder version(String version) {
this.version = version;
return this;
}
public PluginWrapperBuilder requiredCoreVersion(String requiredCoreVersion) {
this.requiredCoreVersion = requiredCoreVersion;
return this;
}
public PluginWrapperBuilder classloader(ClassLoader classloader) {
this.cl = classloader;
return this;
}
public PluginWrapperBuilder deps(String... deps) {
for (String dep : deps) {
this.deps.add(new PluginWrapper.Dependency(dep));
}
return this;
}
private PluginWrapper buildLoaded() {
PluginWrapper pw = build();
plugins.put(name, pw);
return pw;
}
private PluginWrapper buildFailed() {
PluginWrapper pw = build();
PluginWrapper.NOTICE.addPlugin(pw);
return pw;
}
private PluginWrapper build() {
Manifest manifest = new Manifest();
Attributes attributes = manifest.getMainAttributes();
attributes.putValue("Short-Name", name);
attributes.putValue("Long-Name", Character.toTitleCase(name.charAt(0)) + name.substring(1));
attributes.putValue("Jenkins-Version", requiredCoreVersion);
attributes.putValue("Plugin-Version", version);
return new PluginWrapper(
pm,
new File("/tmp/" + name + ".jpi"),
manifest,
null,
cl,
new File("/tmp/" + name + ".jpi.disabled"),
deps,
optDeps
);
}
}
@Issue("JENKINS-52665")
@Test
void isSnapshot() {
@@ -0,0 +1,124 @@
package hudson;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import jenkins.model.Jenkins;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.mockito.stubbing.Answer;
abstract class PluginWrapperTestSupport {
private static Locale loc;
@BeforeAll
static void before() {
Jenkins.VERSION = "2.0"; // Some value needed - tests will overwrite if necessary
loc = Locale.getDefault();
Locale.setDefault(new Locale("en", "GB"));
}
@AfterAll
static void after() {
if (loc != null) {
Locale.setDefault(loc);
}
}
protected final void assertContains(Throwable ex, String... patterns) {
String msg = ex.getMessage();
for (String pattern : patterns) {
assertThat(msg, containsString(pattern));
}
}
protected final PluginWrapperBuilder pluginWrapper(String name) {
return new PluginWrapperBuilder(name);
}
// per test
private final HashMap<String, PluginWrapper> plugins = new HashMap<>();
private final PluginManager pm = mock(PluginManager.class);
{
when(pm.getPlugin(any(String.class))).thenAnswer((Answer<PluginWrapper>) invocation -> plugins.get(invocation.getArguments()[0]));
}
protected final class PluginWrapperBuilder {
private final String name;
private String version = "42";
private String requiredCoreVersion = "1.0";
private final List<PluginWrapper.Dependency> deps = new ArrayList<>();
private final List<PluginWrapper.Dependency> optDeps = new ArrayList<>();
private ClassLoader cl = null;
private PluginWrapperBuilder(String name) {
this.name = Objects.requireNonNull(name);
}
public PluginWrapperBuilder version(String version) {
this.version = version;
return this;
}
public PluginWrapperBuilder requiredCoreVersion(String requiredCoreVersion) {
this.requiredCoreVersion = requiredCoreVersion;
return this;
}
public PluginWrapperBuilder classloader(ClassLoader classloader) {
this.cl = classloader;
return this;
}
public PluginWrapperBuilder deps(String... deps) {
for (String dep : deps) {
this.deps.add(new PluginWrapper.Dependency(dep));
}
return this;
}
protected PluginWrapper buildLoaded() {
PluginWrapper pw = build();
plugins.put(name, pw);
return pw;
}
protected PluginWrapper buildFailed() {
PluginWrapper pw = build();
PluginWrapper.NOTICE.addPlugin(pw);
return pw;
}
protected PluginWrapper build() {
Manifest manifest = new Manifest();
Attributes attributes = manifest.getMainAttributes();
attributes.putValue("Short-Name", name);
attributes.putValue("Long-Name", Character.toTitleCase(name.charAt(0)) + name.substring(1));
attributes.putValue("Jenkins-Version", requiredCoreVersion);
attributes.putValue("Plugin-Version", version);
return new PluginWrapper(
pm,
new File("/tmp/" + name + ".jpi"),
manifest,
null,
cl,
new File("/tmp/" + name + ".jpi.disabled"),
deps,
optDeps
);
}
}
}
@@ -15,6 +15,7 @@ import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.security.SecureRandom;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -25,6 +26,15 @@ class DefaultConfidentialStoreTest {
private final SecureRandom sr = new SecureRandom();
private static String masterKeyFileAbsolutePath = null;
private static String masterKeyReadonlySystemPropertyName = null;
@AfterEach
public void resetSystemProperties() {
System.clearProperty(DefaultConfidentialStore.MASTER_KEY_FILE_SYSTEM_PROPERTY);
System.clearProperty(DefaultConfidentialStore.MASTER_KEY_READONLY_SYSTEM_PROPERTY_NAME);
}
@Test
void roundtrip() throws Exception {
File tmp = new File(tmpRule, "tmp"); // let ConfidentialStore create a directory
+1 -1
View File
@@ -28,7 +28,7 @@ THE SOFTWARE.
<parent>
<groupId>org.jenkins-ci</groupId>
<artifactId>jenkins</artifactId>
<version>2.1397.v033314c396ee</version>
<version>2.1413.v65a_1fb_5a_dd02</version>
<relativePath />
</parent>