diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 4e0774d5..26918e15 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -2,6 +2,6 @@ io.jenkins.tools.incrementals git-changelist-maven-extension - 1.8 + 1.10 diff --git a/pom.xml b/pom.xml index 8634e786..6b6ef4cc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.plugins plugin - 5.17 + 5.18 io.jenkins.plugins @@ -16,9 +16,8 @@ 999999-SNAPSHOT - 2.479 - ${jenkins.baseline}.3 - true + 2.504 + ${jenkins.baseline}.1 Max Low @@ -104,10 +103,8 @@ - software.amazon.awssdk - sso - - 2.31.26 + io.jenkins.plugins.aws-java-sdk2 + aws-java-sdk2-sso test @@ -130,36 +127,20 @@ structs - org.jenkins-ci.plugins.workflow - workflow-api - - - org.jenkins-ci.plugins.workflow - workflow-api - tests - test + org.jenkins-ci.plugins.workflow + workflow-api - org.jenkins-ci.plugins.workflow - workflow-step-api - tests - test + org.jenkins-ci.plugins.workflow + workflow-api + tests + test - org.jenkins-ci.test - docker-fixtures - 200.v22a_e8766731c + org.jenkins-ci.plugins.workflow + workflow-step-api + tests test - - - com.fasterxml.jackson.core - jackson-databind - - - commons-io - commons-io - - org.jenkins-ci.plugins @@ -172,6 +153,12 @@ test + + org.jenkins-ci.plugins + ssh-slaves + tests + test + org.jenkins-ci.plugins jdk-tool @@ -278,7 +265,7 @@ io.jenkins.tools.bom bom-${jenkins.baseline}.x - 4710.v016f0a_07e34d + 5015.vb_52d36583443 import pom @@ -295,6 +282,29 @@ guice-assistedinject 6.0.0 + + + org.jenkins-ci.plugins + ssh-slaves + 3.1071.v0d059c7b_c555 + + + org.jenkins-ci.plugins + ssh-slaves + tests + 3.1071.v0d059c7b_c555 + + + org.jenkins-ci.plugins.workflow + workflow-api + 1380.ve03e7a_63d139 + + + org.jenkins-ci.plugins.workflow + workflow-api + tests + 1380.ve03e7a_63d139 + diff --git a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/MockBlobStoreTest.java b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/MockBlobStoreTest.java index 29de0fbe..8aab5724 100644 --- a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/MockBlobStoreTest.java +++ b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/MockBlobStoreTest.java @@ -25,11 +25,13 @@ package io.jenkins.plugins.artifact_manager_jclouds; import org.jenkinsci.plugins.workflow.ArtifactManagerTest; +import static org.junit.Assume.assumeFalse; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.BuildWatcher; import org.jvnet.hudson.test.JenkinsRule; +import org.testcontainers.DockerClientFactory; public class MockBlobStoreTest { @@ -41,8 +43,9 @@ public class MockBlobStoreTest { @Test public void smokes() throws Exception { - ArtifactManagerTest.artifactArchiveAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false, null); - ArtifactManagerTest.artifactStashAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false, null); + assumeFalse("Does not work when Dockerized since the mock server is inaccessible from the container", DockerClientFactory.instance().isDockerAvailable()); + ArtifactManagerTest.artifactArchiveAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false); + ArtifactManagerTest.artifactStashAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false); } } diff --git a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/AbstractIntegrationTest.java b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/AbstractIntegrationTest.java index 6d3ff0b5..dd51ff69 100644 --- a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/AbstractIntegrationTest.java +++ b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/AbstractIntegrationTest.java @@ -29,7 +29,7 @@ public abstract class AbstractIntegrationTest { protected static final String CONTAINER_PREFIX = "ci/"; @BeforeClass - public static void assumeDocker() throws Exception { + public static void assumeDocker() { // Beyond just isDockerAvailable, verify the OS: try { Assume.assumeThat("expect to run Docker on Linux containers", DockerClientFactory.instance().client().infoCmd().exec().getOsType(), is("linux")); @@ -54,7 +54,7 @@ protected static ArtifactManagerFactory getArtifactManagerFactory(Boolean delete protected static void _artifactArchiveAndDelete(JenkinsRule jenkinsRule) throws Throwable { createBucketWithAwsClient("artifact-archive-and-delete"); - ArtifactManagerTest.artifactArchiveAndDelete(jenkinsRule, getArtifactManagerFactory(true, null), true, null); + ArtifactManagerTest.artifactArchiveAndDelete(jenkinsRule, getArtifactManagerFactory(true, null), true); } protected static void createBucketWithAwsClient(String bucketName) throws IOException { @@ -66,12 +66,12 @@ protected static void createBucketWithAwsClient(String bucketName) throws IOExce protected static void _artifactArchive(JenkinsRule jenkinsRule) throws Throwable { createBucketWithAwsClient("artifact-archive"); assertThat(client().headBucket(HeadBucketRequest.builder().bucket("artifact-archive").build()).sdkHttpResponse().isSuccessful(), is(true)); - ArtifactManagerTest.artifactArchive(jenkinsRule, getArtifactManagerFactory(null, null), true, null); + ArtifactManagerTest.artifactArchive(jenkinsRule, getArtifactManagerFactory(null, null), true); } protected static void _artifactStashAndDelete(JenkinsRule jenkinsRule) throws Throwable { createBucketWithAwsClient("artifact-stash-and-delete"); - ArtifactManagerTest.artifactStashAndDelete(jenkinsRule, getArtifactManagerFactory(null, true), true, null); + ArtifactManagerTest.artifactStashAndDelete(jenkinsRule, getArtifactManagerFactory(null, true), true); } protected static void _canCreateBucket(JenkinsRule r) throws Throwable { @@ -84,7 +84,7 @@ protected static void _canCreateBucket(JenkinsRule r) throws Throwable { protected static void _artifactStash(JenkinsRule jenkinsRule) throws Throwable { createBucketWithAwsClient("artifact-stash"); - ArtifactManagerTest.artifactStash(jenkinsRule, getArtifactManagerFactory(null, null), true, null); + ArtifactManagerTest.artifactStash(jenkinsRule, getArtifactManagerFactory(null, null), true); } @Test diff --git a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/JCloudsArtifactManagerTest.java b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/JCloudsArtifactManagerTest.java index 6ddf842b..0ddb7272 100644 --- a/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/JCloudsArtifactManagerTest.java +++ b/src/test/java/io/jenkins/plugins/artifact_manager_jclouds/s3/JCloudsArtifactManagerTest.java @@ -28,8 +28,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.junit.Assume.*; import java.io.IOException; @@ -41,7 +41,6 @@ import org.apache.commons.io.output.NullOutputStream; import org.jclouds.rest.internal.InvokeHttpMethod; import org.jenkinsci.plugins.workflow.ArtifactManagerTest; -import org.jenkinsci.test.acceptance.docker.fixtures.JavaContainer; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; @@ -52,10 +51,6 @@ import org.jvnet.hudson.test.TestBuilder; import com.cloudbees.hudson.plugins.folder.Folder; -import com.cloudbees.plugins.credentials.CredentialsScope; -import com.cloudbees.plugins.credentials.SystemCredentialsProvider; -import com.cloudbees.plugins.credentials.domains.Domain; -import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; import org.htmlunit.WebResponse; import hudson.ExtensionList; @@ -67,10 +62,9 @@ import hudson.model.FreeStyleProject; import hudson.model.Item; import hudson.model.Run; +import hudson.model.Slave; import hudson.model.TaskListener; -import hudson.plugins.sshslaves.SSHLauncher; import hudson.remoting.Which; -import hudson.slaves.DumbSlave; import hudson.tasks.ArtifactArchiver; import io.jenkins.plugins.aws.global_configuration.CredentialsAwsGlobalConfiguration; import java.io.Serializable; @@ -104,6 +98,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.services.s3.S3Client; +import test.ssh_agent.OutboundAgent; public class JCloudsArtifactManagerTest extends S3AbstractTest { @@ -133,42 +128,36 @@ protected ArtifactManagerFactory getArtifactManagerFactory(Boolean deleteArtifac @Test public void agentPermissions() throws Exception { - var image = ArtifactManagerTest.prepareImage(); // TODO simplify to use Testcontainers directly - assumeNotNull(image); System.err.println("verifying that while the master can connect to S3, a Dockerized agent cannot"); - try (JavaContainer container = image.start(JavaContainer.class).start()) { - SystemCredentialsProvider.getInstance().getDomainCredentialsMap().put(Domain.global(), Collections.singletonList(new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM, "test", null, "test", "test"))); - DumbSlave agent = new DumbSlave("assumptions", "/home/test/slave", new SSHLauncher(container.ipBound(22), container.port(22), "test")); - Jenkins.get().addNode(agent); + try (var outboundAgent = new OutboundAgent()) { + var connectionDetails = outboundAgent.start(); + assumeThat("cannot test this without Docker", connectionDetails, notNullValue()); + OutboundAgent.createAgent(j, "remote", connectionDetails); + var agent = (Slave) j.jenkins.getNode("remote"); j.waitOnline(agent); - try { - agent.getChannel().call(new LoadS3Credentials()); - fail("did not expect to be able to connect to S3 from a Dockerized agent"); // or AssumptionViolatedException? - } catch (SdkClientException x) { - System.err.println("a Dockerized agent was unable to connect to S3, as expected: " + x); - } + assertThrows("did not expect to be able to connect to S3 from a Dockerized agent", SdkClientException.class, () -> agent.getChannel().call(new LoadS3Credentials())); } } @Test public void artifactArchive() throws Exception { // To demo class loading performance: loggerRule.record(SlaveComputer.class, Level.FINEST); - ArtifactManagerTest.artifactArchive(j, getArtifactManagerFactory(null, null), true, null); + ArtifactManagerTest.artifactArchive(j, getArtifactManagerFactory(null, null), true); } @Test public void artifactArchiveAndDelete() throws Exception { - ArtifactManagerTest.artifactArchiveAndDelete(j, getArtifactManagerFactory(true, null), true, null); + ArtifactManagerTest.artifactArchiveAndDelete(j, getArtifactManagerFactory(true, null), true); } @Test public void artifactStash() throws Exception { - ArtifactManagerTest.artifactStash(j, getArtifactManagerFactory(null, null), true, null); + ArtifactManagerTest.artifactStash(j, getArtifactManagerFactory(null, null), true); } @Test public void artifactStashAndDelete() throws Exception { - ArtifactManagerTest.artifactStashAndDelete(j, getArtifactManagerFactory(null, true), true, null); + ArtifactManagerTest.artifactStashAndDelete(j, getArtifactManagerFactory(null, true), true); } private static final class LoadS3Credentials extends MasterToSlaveCallable {