From ef5ebd446c8c3e024333d702d4f5d714d7de5887 Mon Sep 17 00:00:00 2001 From: ingleiv Johansen Date: Thu, 3 Oct 2024 14:06:39 +0200 Subject: [PATCH 1/4] Migrated to ktor 2, kotlin 2, JDK 21 --- .github/workflows/main.yml | 11 +-- Dockerfile | 3 +- pom.xml | 69 ++++++++++---- .../no/nav/navansatt/ActiveDirectoryClient.kt | 12 ++- .../kotlin/no/nav/navansatt/AxsysClient.kt | 11 ++- src/main/kotlin/no/nav/navansatt/Main.kt | 15 +-- .../kotlin/no/nav/navansatt/Norg2Client.kt | 11 +-- src/main/kotlin/no/nav/navansatt/Routes.kt | 31 +++--- .../no/nav/navansatt/discoverOidcMetadata.kt | 15 ++- .../kotlin/no/nav/navansatt/mainModule.kt | 74 +++++++-------- .../no/nav/navansatt/AxsysClientTest.kt | 21 ++-- src/test/kotlin/no/nav/navansatt/MockMain.kt | 4 +- .../kotlin/no/nav/navansatt/RoutesTest.kt | 95 ++++++++++--------- .../kotlin/no/nav/navansatt/mock/AxsysMock.kt | 21 ++-- .../no/nav/navansatt/mock/LdapServer.kt | 6 +- .../no/nav/navansatt/mock/MockServer.kt | 16 ++-- .../kotlin/no/nav/navansatt/mock/Norg2Mock.kt | 10 +- .../kotlin/no/nav/navansatt/mock/OidcMocks.kt | 8 +- 18 files changed, 231 insertions(+), 202 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4da79c4..1a53468 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,8 +2,6 @@ name: Build, push, and deploy on: push: - branches: - - main env: docker_image: docker.pkg.github.com/${{ github.repository }}/navansatt:${{ github.sha }} @@ -18,16 +16,17 @@ jobs: packages: "write" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/cache@v2 with: path: ~/.m2 key: "${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}" restore-keys: | ${{ runner.os }}-maven- - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v4 with: - java-version: 14 + distribution: temurin + java-version: 21 - name: Build shell: bash run: | @@ -43,7 +42,7 @@ jobs: deploy: permissions: contents: "read" - id-token: "write" + id-token: "write" name: Deploy to NAIS needs: build if: github.ref == 'refs/heads/main' diff --git a/Dockerfile b/Dockerfile index 27ff252..671c512 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# FROM navikt/java:14 -FROM eclipse-temurin:17-jre +FROM eclipse-temurin:21-jre RUN apt-get update && apt-get install -y \ curl \ diff --git a/pom.xml b/pom.xml index 8ae1d1f..381484f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,8 +10,8 @@ REST service for getting data about employees/NAV-ansatte - 1.4.21 - 1.5.1 + 2.0.20 + 2.3.12 1.0.1 @@ -47,6 +47,10 @@ kotlin-stdlib-jdk8 ${kotlin.version} + + io.ktor + ktor-server-core-jvm + io.ktor ktor-server-core @@ -57,27 +61,47 @@ io.ktor - ktor-server-netty + ktor-server-host-common-jvm + + + io.ktor + ktor-server-netty-jvm + + + io.ktor + ktor-server-locations-jvm + + + io.ktor + ktor-server-auth-jvm + + + io.ktor + ktor-server-auth-jwt-jvm + + + io.ktor + ktor-server-call-id-jvm io.ktor - ktor-locations + ktor-server-content-negotiation-jvm io.ktor - ktor-auth + ktor-server-status-pages-jvm io.ktor - ktor-auth-jwt + ktor-serialization-kotlinx-json-jvm io.ktor - ktor-serialization + ktor-client-apache-jvm io.ktor - ktor-client-apache + ktor-client-content-negotiation-jvm io.ktor @@ -85,7 +109,7 @@ io.ktor - ktor-metrics-micrometer + ktor-server-metrics-micrometer-jvm @@ -127,13 +151,13 @@ io.micrometer micrometer-registry-prometheus - 1.1.3 + 1.13.5 org.apache.commons commons-text - 1.10.0 + 1.11.0 @@ -141,7 +165,7 @@ ch.qos.logback logback-classic - 1.2.3 + 1.4.12 net.logstash.logback @@ -151,7 +175,7 @@ org.slf4j slf4j-api - 1.7.30 + 2.0.12 @@ -163,8 +187,8 @@ io.mockk - mockk - 1.10.5 + mockk-jvm + 1.13.12 test @@ -179,7 +203,7 @@ io.ktor - ktor-server-tests + ktor-server-tests-jvm test @@ -202,12 +226,12 @@ com.github.gantsign.maven ktlint-maven-plugin - 1.7.0 + 3.3.0 check-kotlin-code - check +