Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to Java 21 #226

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Validate Gradle wrapper
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

- name: Validate Gradle wrapper
Expand Down
27 changes: 0 additions & 27 deletions Dockerfile

This file was deleted.

17 changes: 3 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
}

sonarqube {
Expand Down Expand Up @@ -115,7 +115,7 @@ testing {
targets {
all {
testTask.configure {
mustRunAfter(tasks.named("dockerBuild"))
mustRunAfter(tasks.bootBuildImage)
testLogging.exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
testLogging.showStandardStreams = true
}
Expand All @@ -125,17 +125,6 @@ testing {
}
}

tasks.create<Exec>("dockerBuild") {
mustRunAfter(tasks.test)
executable("docker")
args(listOf("build", "-t", "${registry}/${project.name}:${project.version}", "-t", "${registry}/${project.name}:latest", "."))
}

tasks.create<Exec>("dockerBuildPush") {
executable("docker")
args(listOf("buildx", "build", "--platform", "linux/amd64,linux/arm64", "-t", "${registry}/${project.name}:${project.version}", "--push", "."))
}

tasks.withType<BootBuildImage> {
mustRunAfter(tasks.test)
imageName.value("${registry}/${project.name}:${project.version}")
Expand All @@ -157,7 +146,7 @@ tasks.withType<BootBuildImage> {

tasks.check {
dependsOn(tasks.test)
dependsOn(tasks.named("dockerBuild"))
dependsOn(tasks.bootBuildImage)
dependsOn(testing.suites.named("integrationTest"))
dependsOn(tasks.jacocoTestReport)
}
Expand Down
6 changes: 3 additions & 3 deletions src/integrationTest/java/io/jaconi/morp/ProxyIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void testKeycloak() {
var step1 = containerSetup.getWebTestClient().get()
.uri("/upstream/tenant1/test")
.accept(MediaType.TEXT_HTML)
.header("host", "morp:8081")
.header("host", "morp:8080")
.exchange()
.expectStatus().is3xxRedirection()
.expectHeader().location("/oauth2/authorization/tenant1")
Expand Down Expand Up @@ -114,7 +114,7 @@ void testKeycloak() {
var step5 = containerSetup.getWebTestClient().get()
.uri(step4.getResponseHeaders().getLocation())
.cookie(SESSION_COOKIE, session)
.header("host", "morp:8081")
.header("host", "morp:8080")
.exchange()
.expectStatus().is3xxRedirection()
.expectHeader().location("/upstream/tenant1/test")
Expand All @@ -129,7 +129,7 @@ void testKeycloak() {
var step6 = containerSetup.getWebTestClient().get()
.uri(step5.getResponseHeaders().getLocation().getPath())
.accept(MediaType.TEXT_HTML)
.header("host", "morp:8081")
.header("host", "morp:8080")
.cookie(SESSION_COOKIE, session)
.header("x-tenant-id", "tenant1")
.exchange()
Expand Down
13 changes: 6 additions & 7 deletions src/integrationTest/java/io/jaconi/morp/SeleniumIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ static class Config {


// we start Chrome for each test to ensure a clean state (i.e. cookies etc)
// screen recording not working on ARM Mac due to missing ARM image of vnc-recorder
@Container
public final BrowserWebDriverContainer<?> chrome = new BrowserWebDriverContainer<>(ArmUtil.select("seleniarm/standalone-chromium:107.0", "selenium/standalone-chrome:107.0"))
public final BrowserWebDriverContainer<?> chrome = new BrowserWebDriverContainer<>(ArmUtil.select("seleniarm/standalone-chromium:latest", "selenium/standalone-chrome:latest"))
.withNetwork(containerSetup.getNetwork())
.withNetworkAliases("chrome")
.withCapabilities(new ChromeOptions())
Expand Down Expand Up @@ -83,8 +82,8 @@ void tearDown() {

@ParameterizedTest
@CsvSource({
"tenant1, morp:8081, /upstream/tenant1, /test",
"tenant1, tenant1-morp:8081, /upstream, /test"
"tenant1, morp:8080, /upstream/tenant1, /test",
"tenant1, tenant1-morp:8080, /upstream, /test"
})
void testWithKeycloak(String tenant, String host, String prefix, String path) throws MalformedURLException {

Expand All @@ -105,7 +104,7 @@ void testWithKeycloak(String tenant, String host, String prefix, String path) th
// assert that we ended up in the right place
URL url = new URL(driver.getCurrentUrl());
assertThat(url.getHost()).isEqualTo(StringUtils.substringBefore(host, ":"));
assertThat(url.getPort()).isEqualTo(8081);
assertThat(url.getPort()).isEqualTo(8080);
assertThat(url.getPath()).isEqualTo(prefix + path);

assertThat(driver.findElement(By.id("test")).getText()).isEqualTo("Hello from mockserver");
Expand All @@ -128,8 +127,8 @@ void testWithKeycloak(String tenant, String host, String prefix, String path) th

@ParameterizedTest
@CsvSource({
"tenant2, morp:8081, /upstream/tenant2, /test",
"tenant2, tenant2-morp:8081, /upstream, /test"
"tenant2, morp:8080, /upstream/tenant2, /test",
"tenant2, tenant2-morp:8080, /upstream, /test"
})
void testWithOkta(String tenant, String host, String prefix, String path) {

Expand Down
30 changes: 15 additions & 15 deletions src/integrationTest/java/io/jaconi/morp/TestContainerSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import org.testcontainers.lifecycle.Startables;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.DockerLoggerFactory;
import reactor.netty.http.client.HttpClient;
Expand Down Expand Up @@ -54,29 +55,28 @@ public TestContainerSetup() {

// setup mockserver (as protected upstream)
var tag = "mockserver-%s".formatted(MockServerClient.class.getPackage().getImplementationVersion());
this.mockserver = new MockServerContainer(DockerImageName.parse("mockserver/mockserver").withTag(tag))
DockerImageName mockServerImage = DockerImageName.parse("mockserver/mockserver").withTag(tag);
this.mockserver = new MockServerContainer(mockServerImage)
.withNetwork(network)
.withNetworkAliases("upstream");
.withNetworkAliases("upstream")
.withLogConsumer(new Slf4jLogConsumer(DockerLoggerFactory.getLogger(mockServerImage.asCanonicalNameString())));

// setup morp as auth proxy for upstream
this.morp = new GenericContainer<>(DockerImageName.parse("ghcr.io/jaconi-io/morp:latest"))
DockerImageName morpImage = DockerImageName.parse("ghcr.io/jaconi-io/morp:latest");
this.morp = new GenericContainer<>(morpImage)
.withNetwork(network)
.withNetworkAliases("morp", "tenant1-morp", "tenant2-morp")
.withExposedPorts(8081, 8082)
.withExposedPorts(8080, 8081)
.withEnv("SPRING_PROFILES_ACTIVE", "test")
.withFileSystemBind(
"./src/integrationTest/resources/morp/application.yaml",
"/workspace/config/application.yaml",
BindMode.READ_ONLY)
.waitingFor(new HttpWaitStrategy()
.forPort(8082)
.forPort(8081)
.forPath("/actuator/health/readiness")
.withStartupTimeout(Duration.ofMinutes(5)));

// start the containers
keycloak.start();
mockserver.withLogConsumer(new Slf4jLogConsumer(DockerLoggerFactory.getLogger(mockserver.getDockerImageName())))
.start();
.withStartupTimeout(Duration.ofMinutes(5)))
.withLogConsumer(new Slf4jLogConsumer(DockerLoggerFactory.getLogger(morpImage.asCanonicalNameString())));

// for local development convenience, bind mount the git-ignored 'secret.properties' (if it exists)
if (Files.exists(Path.of("./secret.properties"))) {
Expand All @@ -92,8 +92,8 @@ public TestContainerSetup() {
.filter(e -> e.getKey().startsWith("MORP_"))
.forEach(e -> morp.withEnv(e.getKey(), e.getValue()));

morp.withLogConsumer(new Slf4jLogConsumer(DockerLoggerFactory.getLogger(morp.getDockerImageName())))
.start();
// start the containers
Startables.deepStart(keycloak, mockserver, morp).join();

// create client to control mockserver (running as container)
mockServerClient = new MockServerClient(mockserver.getHost(), mockserver.getServerPort());
Expand All @@ -103,11 +103,11 @@ public TestContainerSetup() {
.wiretap(true) // hex dump wiretap
.compress(true);
webTestClient = WebTestClient.bindToServer(new ReactorClientHttpConnector(httpClient))
.baseUrl("http://localhost:" + morp.getMappedPort(8081))
.baseUrl("http://localhost:" + morp.getMappedPort(8080))
.build();

managementTestClient = WebTestClient.bindToServer(new ReactorClientHttpConnector(httpClient))
.baseUrl("http://localhost:" + morp.getMappedPort(8082))
.baseUrl("http://localhost:" + morp.getMappedPort(8081))
.build();
}

Expand Down
7 changes: 0 additions & 7 deletions src/integrationTest/resources/morp/application.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# keycloak is running on 8080 so we need different ports for Morp here
server:
port: 8081
management:
server:
port: 8082

# Routing config
spring:
cloud:
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/jaconi/morp/MorpApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisabledInAotMode
class MorpApplicationTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisabledInAotMode
class MorpReactiveOAuth2UserServiceTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisabledInAotMode
class MorpReactiveOidcUserServiceTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.when;

@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisabledInAotMode
class RegistrationResolverTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;

@SpringBootTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisabledInAotMode
class TenantAwareClientRegistrationRepositoryTest {

Expand Down