diff --git a/pom.xml b/pom.xml index 7ea33af..a897326 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 5.24 + 5.25 @@ -29,6 +29,7 @@ ${jenkins.baseline}.3 Max false + false @@ -71,7 +72,7 @@ org.testcontainers - testcontainers + junit-jupiter 1.21.3 test diff --git a/src/test/java/org/jenkinsci/plugins/reverse_proxy_auth/docker/PlanetExpressTest.java b/src/test/java/org/jenkinsci/plugins/reverse_proxy_auth/docker/PlanetExpressTest.java index cf972d8..17d6ba5 100644 --- a/src/test/java/org/jenkinsci/plugins/reverse_proxy_auth/docker/PlanetExpressTest.java +++ b/src/test/java/org/jenkinsci/plugins/reverse_proxy_auth/docker/PlanetExpressTest.java @@ -2,60 +2,60 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.StringContains.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import hudson.Functions; import hudson.tasks.MailAddressResolver; import hudson.util.Secret; import org.jenkinsci.plugins.reverse_proxy_auth.ReverseProxySecurityRealm; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.RealJenkinsRule; +import org.jvnet.hudson.test.junit.jupiter.RealJenkinsExtension; import org.springframework.security.ldap.userdetails.LdapUserDetails; import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; /** * Tests the plugin when logging in to rroemhild/test-openldap */ -public class PlanetExpressTest { +@Testcontainers(disabledWithoutDocker = true) +class PlanetExpressTest { - static final String TEST_IMAGE = + private static final String TEST_IMAGE = "ghcr.io/rroemhild/docker-test-openldap:v2.5.0@sha256:3470e15c60119a1c0392cc162cdce71edfb42b55affdc69da574012f956317cd"; - static final String DN = "dc=planetexpress,dc=com"; - static final String MANAGER_DN = "cn=admin,dc=planetexpress,dc=com"; - static final String MANAGER_SECRET = "GoodNewsEveryone"; + private static final String DN = "dc=planetexpress,dc=com"; + private static final String MANAGER_DN = "cn=admin,dc=planetexpress,dc=com"; + private static final String MANAGER_SECRET = "GoodNewsEveryone"; - @BeforeClass - public static void requiresDocker() { - assumeTrue(DockerClientFactory.instance().isDockerAvailable()); - } - - @BeforeClass - public static void linuxOnly() { - assumeFalse( - "Windows CI builders now have Docker installed…but it does not support Linux images", - Functions.isWindows() && System.getenv("JENKINS_URL") != null); - } + @RegisterExtension + private final RealJenkinsExtension extension = new RealJenkinsExtension(); @SuppressWarnings("rawtypes") - @Rule - public GenericContainer container = new GenericContainer(TEST_IMAGE).withExposedPorts(10389); + @Container + private final GenericContainer container = new GenericContainer(TEST_IMAGE).withExposedPorts(10389); - @Rule - public RealJenkinsRule rr = new RealJenkinsRule(); + @BeforeAll + static void setUp() { + assumeTrue(DockerClientFactory.instance().isDockerAvailable()); + assumeFalse( + Functions.isWindows() && System.getenv("JENKINS_URL") != null, + "Windows CI builders now have Docker installed…but it does not support Linux images"); + } @Test - public void login() throws Throwable { + void login() throws Throwable { String server = container.getHost() + ":" + container.getFirstMappedPort(); - rr.then(new Login(server)); + extension.then(new Login(server)); } - private static class Login implements RealJenkinsRule.Step { + private static class Login implements RealJenkinsExtension.Step { + private final String server; Login(String server) {