Add test asserting that outdated dependencies of detached plugins are updated
@@ -31,7 +31,6 @@ import hudson.PluginManager;
import hudson.PluginManagerUtil;
import hudson.PluginWrapper;
import hudson.util.VersionNumber;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -87,7 +86,7 @@ public class LoadDetachedPluginsTest {
@Issue("JENKINS-48604")
@Test
@LocalData
- public void upgradeFromJenkins2WithDependency() {
+ public void upgradeFromJenkins2WithNewerDependency() {
VersionNumber since = new VersionNumber("2.0");
rr.then(r -> {
List<DetachedPlugin> detachedPlugins = ClassicPluginStrategy.getDetachedPlugins(since);
@@ -98,7 +97,25 @@ public class LoadDetachedPluginsTest {
Plugin scriptSecurity = r.jenkins.getPlugin("script-security");
assertThat("Script-security should be installed", scriptSecurity, notNullValue());
assertThat("Dependencies of detached plugins should not be downgraded",
- scriptSecurity.getWrapper().getVersionNumber(), greaterThan(new VersionNumber("1.18.1")));
+ scriptSecurity.getWrapper().getVersionNumber(), equalTo(new VersionNumber("1.34")));
+ assertNoFailedPlugins(r);
+ });
+ }
+
+ @Test
+ @LocalData
+ public void upgradeFromJenkins2WithOlderDependency() {
+ VersionNumber since = new VersionNumber("2.0");
+ rr.then(r -> {
+ List<DetachedPlugin> detachedPlugins = ClassicPluginStrategy.getDetachedPlugins(since);
+ assertThat("Plugins have been detached since the pre-upgrade version",
+ detachedPlugins.size(), greaterThan(1));
+ assertThat("Plugins detached between the pre-upgrade version and the current version should be installed",
+ getInstalledDetachedPlugins(r, detachedPlugins).size(), equalTo(detachedPlugins.size()));
+ Plugin scriptSecurity = r.jenkins.getPlugin("script-security");
+ assertThat("Script-security should be installed", scriptSecurity, notNullValue());
+ assertThat("Dependencies of detached plugins should be upgraded to the required version",
+ scriptSecurity.getWrapper().getVersionNumber(), equalTo(new VersionNumber("1.18.1")));
assertNoFailedPlugins(r);
});
}
