diff --git a/src/main/java/org/jvnet/hudson/test/JenkinsRule.java b/src/main/java/org/jvnet/hudson/test/JenkinsRule.java index 43659bdba..8166bc22e 100644 --- a/src/main/java/org/jvnet/hudson/test/JenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/JenkinsRule.java @@ -105,6 +105,7 @@ import hudson.security.AbstractPasswordBasedSecurityRealm; import hudson.security.GroupDetails; import hudson.security.csrf.CrumbIssuer; +import hudson.slaves.Cloud; import hudson.slaves.ComputerConnector; import hudson.slaves.ComputerLauncher; import hudson.slaves.DumbSlave; @@ -180,6 +181,7 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.stream.Collectors; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletException; @@ -1426,6 +1428,23 @@ public V configRoundtrip(V view) throws Exception { return view; } + /** + * Performs a configuration round-trip testing for a cloud. + * The given cloud is added to the cloud list of Jenkins. + *

+ * If a cloud with the same name already exists, then this old one will be replaced by the given one. + */ + public C configRoundtrip(C cloud) throws Exception { + Cloud cloudConfig = jenkins.getCloud(cloud.name); + if (cloudConfig != null) { + jenkins.clouds.remove(cloudConfig); + } + jenkins.clouds.add(cloud); + jenkins.save(); + submit(createWebClient().goTo("configureClouds/").getFormByName("config")); + return (C)jenkins.getCloud(cloud.name); + } + /** * Asserts that the outcome of the build is a specific outcome.