From 82a65cd4ea8e0e2445474f765a83e4e4f4e7edac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wenzel?= Date: Tue, 31 Jan 2023 15:21:13 +0100 Subject: [PATCH] bump dependencies for spring boot and fabric8 --- .github/workflows/maven.yaml | 17 ++-- pom.xml | 10 +-- .../AdmissionReviewService.java | 4 +- .../admissionreview/AdmissionReviewTest.java | 81 ++++++++++--------- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index d0dc832..a7bdb29 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -11,25 +11,24 @@ jobs: strategy: matrix: kubernetes_version: - - "kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047" - - "kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6" - - "kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9" - - "kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729" - - "kindest/node:v1.18.19@sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c" + - "kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1" + - "kindest/node:v1.24.7@sha256:577c630ce8e509131eab1aea12c022190978dd2f745aac5eb1fe65c0807eb315" + - "kindest/node:v1.23.13@sha256:ef453bb7c79f0e3caba88d2067d4196f427794086a7d0df8df4f019d5e336b61" + - "kindest/node:v1.22.15@sha256:7d9708c4b0873f0fe2e171e2b1b7f45ae89482617778c1c875f1053d4cef2e41" steps: - uses: actions/checkout@v1 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 + java-version: 17 cache: 'maven' - - uses: helm/kind-action@v1.2.0 + - uses: helm/kind-action@v1.4.0 with: - version: "v0.11.1" + version: "v0.17.0" node_image: "${{ matrix.kubernetes_version }}" - name: "Kubernetes version" diff --git a/pom.xml b/pom.xml index 7b83375..c1504cd 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.6.12 + 2.7.8 @@ -22,9 +22,7 @@ UTF-8 UTF-8 17 - 6.1.1 - 1.2.8 - 2.16.0 + 6.4.0 @@ -59,7 +57,7 @@ com.github.ben-manes.caffeine caffeine - 3.1.1 + 3.1.2 @@ -107,7 +105,7 @@ maven-compiler-plugin 3.8.1 - 11 + 17 true -XDignore.symbol.file diff --git a/src/main/java/de/koudingspawn/vault/admissionreview/AdmissionReviewService.java b/src/main/java/de/koudingspawn/vault/admissionreview/AdmissionReviewService.java index 6fdfbd4..34ac672 100644 --- a/src/main/java/de/koudingspawn/vault/admissionreview/AdmissionReviewService.java +++ b/src/main/java/de/koudingspawn/vault/admissionreview/AdmissionReviewService.java @@ -8,6 +8,7 @@ import io.fabric8.kubernetes.api.model.admission.v1.AdmissionRequest; import io.fabric8.kubernetes.api.model.admission.v1.AdmissionResponse; import io.fabric8.kubernetes.api.model.admission.v1.AdmissionResponseBuilder; +import io.fabric8.kubernetes.client.utils.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -25,7 +26,8 @@ public AdmissionReviewService(VaultService vaultService) { public AdmissionResponse validate(AdmissionRequest admissionRequest) { try { - Vault vault = (Vault) admissionRequest.getObject(); + String s = Serialization.asYaml(admissionRequest.getObject()); + Vault vault = Serialization.unmarshal(s, Vault.class); vaultService.generateSecret(vault); } catch (ClassCastException ex) { log.error("Received Admission Request of invalid type!"); diff --git a/src/test/java/de/koudingspawn/vault/admissionreview/AdmissionReviewTest.java b/src/test/java/de/koudingspawn/vault/admissionreview/AdmissionReviewTest.java index 5013e7d..7fe1398 100644 --- a/src/test/java/de/koudingspawn/vault/admissionreview/AdmissionReviewTest.java +++ b/src/test/java/de/koudingspawn/vault/admissionreview/AdmissionReviewTest.java @@ -60,26 +60,27 @@ public void shouldFailWithInvalidRequest() throws Exception { SecretNotAccessibleException secretException = new SecretNotAccessibleException("Secret is not accessible"); Mockito.when(vaultService.generateSecret(any())).thenThrow(secretException); - mvc.perform(post("/validation/vault-crd").content("{\n" + - " \"apiVersion\": \"admission.k8s.io/v1\",\n" + - " \"kind\": \"AdmissionReview\",\n" + - " \"request\": {\n" + - " \"uid\": \"705ab4f5-6393-11e8-b7cc-42010a800002\",\n" + - " \"object\": {\n" + - " \"apiVersion\": \"koudingspawn.de/v1\",\n" + - " \"kind\": \"Vault\",\n" + - " \"metadata\": {\n" + - " \"name\": \"test-vault\",\n" + - " \"namespace\": \"default\"\n" + - " " + - "},\n" + - " \"spec\": {\n" + - " \"type\": \"KEYVALUE\",\n" + - " \"path\": \"secret/qweasd\"\n" + - " }\n" + - " }\n" + - " }\n" + - "}").contentType("application/json")) + mvc.perform(post("/validation/vault-crd").content(""" + { + "apiVersion": "admission.k8s.io/v1", + "kind": "AdmissionReview", + "request": { + "uid": "705ab4f5-6393-11e8-b7cc-42010a800002", + "object": { + "apiVersion": "koudingspawn.de/v1", + "kind": "Vault", + "metadata": { + "name": "test-vault", + "namespace": "default" + }, + "spec": { + "type": "KEYVALUE", + "path": "secret/qweasd" + } + } + } + } + """).contentType("application/json")) .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.response.uid").value("705ab4f5-6393-11e8-b7cc-42010a800002")) @@ -93,26 +94,26 @@ public void shouldReturnValidValue() throws Exception { VaultSecret vaultSecret = new VaultSecret(new HashMap<>(), "qweasd"); Mockito.when(vaultService.generateSecret(any())).thenReturn(vaultSecret); - mvc.perform(post("/validation/vault-crd").content("{\n" + - " \"apiVersion\": \"admission.k8s.io/v1\",\n" + - " \"kind\": \"AdmissionReview\",\n" + - " \"request\": {\n" + - " \"uid\": \"705ab4f5-6393-11e8-b7cc-42010a800002\",\n" + - " \"object\": {\n" + - " \"apiVersion\": \"koudingspawn.de/v1\",\n" + - " \"kind\": \"Vault\",\n" + - " \"metadata\": {\n" + - " \"name\": \"test-vault\",\n" + - " \"namespace\": \"default\"\n" + - " " + - "},\n" + - " \"spec\": {\n" + - " \"type\": \"KEYVALUE\",\n" + - " \"path\": \"secret/qweasd\"\n" + - " }\n" + - " }\n" + - " }\n" + - "}").contentType("application/json")) + mvc.perform(post("/validation/vault-crd").content(""" + { + "apiVersion": "admission.k8s.io/v1", + "kind": "AdmissionReview", + "request": { + "uid": "705ab4f5-6393-11e8-b7cc-42010a800002", + "object": { + "apiVersion": "koudingspawn.de/v1", + "kind": "Vault", + "metadata": { + "name": "test-vault", + "namespace": "default" + }, + "spec": { + "type": "KEYVALUE", + "path": "secret/qweasd" + } + } + } + }""").contentType("application/json")) .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.response.uid").value("705ab4f5-6393-11e8-b7cc-42010a800002"))