From 0b83737cc7d8ee65dbbca013617339f20d6a32b2 Mon Sep 17 00:00:00 2001 From: Jim Marino Date: Wed, 3 Apr 2024 17:02:42 +0200 Subject: [PATCH] chore: Cleanup Hashicorp Vault package structure (#4082) Cleanup Hashicorp Vault package structure --- .../edc/vault/hashicorp/HashicorpVault.java | 5 +- .../hashicorp/HashicorpVaultExtension.java | 4 ++ .../eclipse/edc/vault/hashicorp/PemUtil.java | 61 ------------------- .../{ => client}/HashicorpVaultClient.java | 11 ++-- .../HashicorpVaultClientFallbackFactory.java | 4 +- .../{ => client}/HashicorpVaultSettings.java | 7 ++- .../HashicorpVaultTokenRenewTask.java | 21 ++++--- .../HashicorpVaultHealthCheck.java | 3 +- .../HashicorpVaultHealthExtension.java | 5 +- .../vault/hashicorp/{ => util}/PathUtil.java | 2 +- ...rg.eclipse.edc.spi.system.ServiceExtension | 2 +- .../vault/hashicorp/HashicorpVaultTest.java | 1 + ...shicorpVaultClientFallbackFactoryTest.java | 4 +- .../HashicorpVaultClientIntegrationTest.java | 2 +- .../HashicorpVaultClientTest.java | 2 +- .../HashicorpVaultSettingsTest.java | 8 +-- .../HashicorpVaultTokenRenewTaskTest.java | 3 +- .../HashicorpVaultHealthCheckTest.java | 3 +- .../hashicorp/{ => util}/PathUtilTest.java | 2 +- 19 files changed, 52 insertions(+), 98 deletions(-) delete mode 100644 extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PemUtil.java rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultClient.java (97%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultClientFallbackFactory.java (88%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultSettings.java (96%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultTokenRenewTask.java (90%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => health}/HashicorpVaultHealthCheck.java (94%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => health}/HashicorpVaultHealthExtension.java (91%) rename extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/{ => util}/PathUtil.java (94%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultClientFallbackFactoryTest.java (89%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultClientIntegrationTest.java (99%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultClientTest.java (99%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultSettingsTest.java (96%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => client}/HashicorpVaultTokenRenewTaskTest.java (98%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => health}/HashicorpVaultHealthCheckTest.java (97%) rename extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/{ => util}/PathUtilTest.java (97%) diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVault.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVault.java index b2fa8d3aac3..baba64ea978 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVault.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVault.java @@ -18,6 +18,7 @@ import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.result.Result; import org.eclipse.edc.spi.security.Vault; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,8 +44,8 @@ public HashicorpVault(@NotNull HashicorpVaultClient hashicorpVaultClient, @NotNu if (result.failed()) { monitor.debug("Failed to resolve secret '%s': %s".formatted(key, result.getFailureMessages())); return null; - } - + } + return result.getContent(); } diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultExtension.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultExtension.java index 29f05490a54..28429a29dd4 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultExtension.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultExtension.java @@ -26,6 +26,9 @@ import org.eclipse.edc.spi.system.ExecutorInstrumentation; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultSettings; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultTokenRenewTask; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; @@ -110,6 +113,7 @@ public void initialize(ServiceExtensionContext context) { monitor = context.getMonitor().withPrefix(NAME); settings = getSettings(context); tokenRenewalTask = new HashicorpVaultTokenRenewTask( + NAME, executorInstrumentation, hashicorpVaultClient(), settings.renewBuffer(), diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PemUtil.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PemUtil.java deleted file mode 100644 index 4a02b03c620..00000000000 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PemUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022 Mercedes-Benz Tech Innovation GmbH - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Mercedes-Benz Tech Innovation GmbH - Initial API and Implementation - * - */ - -package org.eclipse.edc.vault.hashicorp; - -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.bouncycastle.openssl.PEMParser; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.security.Provider; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -final class PemUtil { - - private static final Provider PROVIDER = new BouncyCastleProvider(); - private static final JcaX509CertificateConverter X509_CONVERTER = - new JcaX509CertificateConverter().setProvider(PROVIDER); - - private PemUtil() { - throw new IllegalStateException("Private constructor invocation disallowed"); - } - - public static X509Certificate readX509Certificate(@NotNull InputStream inputStream) { - try { - X509CertificateHolder x509CertificateHolder = parsePem(inputStream); - if (x509CertificateHolder == null) { - return null; - } - return X509_CONVERTER.getCertificate(x509CertificateHolder); - } catch (IOException | CertificateException e) { - throw new RuntimeException(e); - } - - } - - @SuppressWarnings("unchecked") - private static T parsePem(@NotNull InputStream inputStream) throws IOException { - try (Reader reader = new InputStreamReader(inputStream)) { - PEMParser pemParser = new PEMParser(reader); - return (T) pemParser.readObject(); - } - } -} diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClient.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClient.java similarity index 97% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClient.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClient.java index 4b9abde5298..82b78d0ab63 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClient.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClient.java @@ -13,7 +13,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -31,6 +31,7 @@ import org.eclipse.edc.vault.hashicorp.model.CreateEntryRequestPayload; import org.eclipse.edc.vault.hashicorp.model.CreateEntryResponsePayload; import org.eclipse.edc.vault.hashicorp.model.GetEntryResponsePayload; +import org.eclipse.edc.vault.hashicorp.util.PathUtil; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -70,10 +71,10 @@ public class HashicorpVaultClient { private final HttpUrl healthCheckUrl; private final Monitor monitor; - HashicorpVaultClient(@NotNull EdcHttpClient httpClient, - @NotNull ObjectMapper objectMapper, - @NotNull Monitor monitor, - @NotNull HashicorpVaultSettings settings) { + public HashicorpVaultClient(@NotNull EdcHttpClient httpClient, + @NotNull ObjectMapper objectMapper, + @NotNull Monitor monitor, + @NotNull HashicorpVaultSettings settings) { this.httpClient = httpClient; this.objectMapper = objectMapper; this.monitor = monitor; diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactory.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactory.java similarity index 88% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactory.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactory.java index 2e5c066f289..fd24f573e29 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactory.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactory.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import dev.failsafe.Fallback; import okhttp3.Request; @@ -28,7 +28,7 @@ */ public class HashicorpVaultClientFallbackFactory implements FallbackFactory { - private static final int[] NON_RETRYABLE_STATUS_CODES = {200, 204, 400, 403, 404, 405}; + private static final int[] NON_RETRYABLE_STATUS_CODES = { 200, 204, 400, 403, 404, 405 }; @Override public Fallback create(Request request) { diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettings.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettings.java similarity index 96% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettings.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettings.java index 9043bbea77e..18422c997b4 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettings.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettings.java @@ -12,14 +12,14 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import okhttp3.HttpUrl; import static java.util.Objects.requireNonNull; /** - * Value container for {@link HashicorpVaultExtension} settings. + * Settings for the {@link HashicorpVaultClient}. */ public class HashicorpVaultSettings { @@ -33,7 +33,8 @@ public class HashicorpVaultSettings { private long renewBuffer; private String secretPath; - private HashicorpVaultSettings() {} + private HashicorpVaultSettings() { + } public HttpUrl url() { return url; diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTask.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTask.java similarity index 90% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTask.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTask.java index a7e9472d0c3..3961ee89f1d 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTask.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTask.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.system.ExecutorInstrumentation; @@ -34,11 +34,12 @@ public class HashicorpVaultTokenRenewTask { private static final String INITIAL_TOKEN_RENEW_ERR_MSG_FORMAT = "Initial token renewal failed with reason: %s"; private static final String SCHEDULED_TOKEN_RENEWAL_ERR_MSG_FORMAT = "Scheduled token renewal failed: %s"; - @NotNull + private final String name; + private final ExecutorInstrumentation executorInstrumentation; - @NotNull + private final HashicorpVaultClient client; - @NotNull + private final Monitor monitor; private final long renewBuffer; private ScheduledExecutorService scheduledExecutorService; @@ -51,14 +52,16 @@ public class HashicorpVaultTokenRenewTask { * before the token expires and failed renewals can be retried in time. * * @param executorInstrumentation executor instrumentation used to initialize a {@link ScheduledExecutorService} - * @param client the HashicorpVaultClient - * @param renewBuffer the renewal buffer time in seconds - * @param monitor the monitor + * @param client the HashicorpVaultClient + * @param renewBuffer the renewal buffer time in seconds + * @param monitor the monitor */ - public HashicorpVaultTokenRenewTask(@NotNull ExecutorInstrumentation executorInstrumentation, + public HashicorpVaultTokenRenewTask(@NotNull String name, + @NotNull ExecutorInstrumentation executorInstrumentation, @NotNull HashicorpVaultClient client, long renewBuffer, @NotNull Monitor monitor) { + this.name = name; this.executorInstrumentation = executorInstrumentation; this.client = client; this.renewBuffer = renewBuffer; @@ -71,7 +74,7 @@ public HashicorpVaultTokenRenewTask(@NotNull ExecutorInstrumentation executorIns */ public void start() { if (!isRunning()) { - scheduledExecutorService = executorInstrumentation.instrument(Executors.newSingleThreadScheduledExecutor(), HashicorpVaultExtension.NAME); + scheduledExecutorService = executorInstrumentation.instrument(Executors.newSingleThreadScheduledExecutor(), name); scheduledExecutorService.execute(this::initialize); isRunning.set(true); } diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheck.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheck.java similarity index 94% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheck.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheck.java index 32b8389b628..d7ed25f2e4a 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheck.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheck.java @@ -13,13 +13,14 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.health; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.system.health.HealthCheckResult; import org.eclipse.edc.spi.system.health.LivenessProvider; import org.eclipse.edc.spi.system.health.ReadinessProvider; import org.eclipse.edc.spi.system.health.StartupStatusProvider; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; /** * Implements the healthcheck of the Hashicorp Vault. diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthExtension.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthExtension.java similarity index 91% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthExtension.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthExtension.java index 99efbc9a554..2301208024a 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthExtension.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthExtension.java @@ -13,7 +13,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.health; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; @@ -21,6 +21,7 @@ import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.spi.system.health.HealthCheckService; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; import static org.eclipse.edc.vault.hashicorp.HashicorpVaultExtension.VAULT_HEALTH_CHECK_ENABLED; import static org.eclipse.edc.vault.hashicorp.HashicorpVaultExtension.VAULT_HEALTH_CHECK_ENABLED_DEFAULT; @@ -51,7 +52,7 @@ public void initialize(ServiceExtensionContext context) { healthCheckService.addLivenessProvider(healthCheck); healthCheckService.addReadinessProvider(healthCheck); healthCheckService.addStartupStatusProvider(healthCheck); - monitor.info("Vault health check initialization complete"); + monitor.debug("Vault health check initialization complete"); } else { monitor.info("Vault health check disabled"); } diff --git a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PathUtil.java b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/util/PathUtil.java similarity index 94% rename from extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PathUtil.java rename to extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/util/PathUtil.java index f82a1e517d6..03e4033f51d 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/PathUtil.java +++ b/extensions/common/vault/vault-hashicorp/src/main/java/org/eclipse/edc/vault/hashicorp/util/PathUtil.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.util; public class PathUtil { diff --git a/extensions/common/vault/vault-hashicorp/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/extensions/common/vault/vault-hashicorp/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension index ddbc4f4566c..4774fc9f943 100644 --- a/extensions/common/vault/vault-hashicorp/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension +++ b/extensions/common/vault/vault-hashicorp/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension @@ -11,4 +11,4 @@ # Mercedes-Benz Tech Innovation GmbH - Initial ServiceExtension file # org.eclipse.edc.vault.hashicorp.HashicorpVaultExtension -org.eclipse.edc.vault.hashicorp.HashicorpVaultHealthExtension +org.eclipse.edc.vault.hashicorp.health.HashicorpVaultHealthExtension diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTest.java index cf6eda7ad1e..ddafeac4ffa 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTest.java @@ -16,6 +16,7 @@ import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.result.Result; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactoryTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactoryTest.java similarity index 89% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactoryTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactoryTest.java index f8d3820c527..a045388cc86 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientFallbackFactoryTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientFallbackFactoryTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import okhttp3.Request; import org.eclipse.edc.http.spi.FallbackFactories; @@ -22,7 +22,7 @@ class HashicorpVaultClientFallbackFactoryTest { - private static final int[] NON_RETRYABLE_STATUS_CODES = {200, 204, 400, 403, 404, 405}; + private static final int[] NON_RETRYABLE_STATUS_CODES = { 200, 204, 400, 403, 404, 405 }; @Test void create_shouldInitializeWithCorrectStatusCodes() { diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientIntegrationTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java similarity index 99% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientIntegrationTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java index 9be81ce1f24..6000e33b2e3 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientIntegrationTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientIntegrationTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.Json; diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientTest.java similarity index 99% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientTest.java index 00876fc28cc..015fed46479 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultClientTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultClientTest.java @@ -13,7 +13,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettingsTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettingsTest.java similarity index 96% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettingsTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettingsTest.java index 668c45d0f88..88ec1d862da 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultSettingsTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultSettingsTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import okhttp3.HttpUrl; import org.junit.jupiter.api.Test; @@ -87,7 +87,7 @@ void createSettings_withVaultTokenNull_shouldThrowException() { var throwable = assertThrows(Exception.class, () -> createSettings( URL, null, - HEALTH_CHECK_PATH, + HEALTH_CHECK_PATH, VAULT_TOKEN_TTL_DEFAULT, VAULT_TOKEN_RENEW_BUFFER_DEFAULT)); assertThat(throwable.getMessage()).isEqualTo("Vault token must not be null"); @@ -105,12 +105,12 @@ void createSettings_withVaultTokenTtlLessThan5_shouldThrowException() { } @ParameterizedTest - @ValueSource(longs = {VAULT_TOKEN_TTL_DEFAULT, VAULT_TOKEN_TTL_DEFAULT + 1}) + @ValueSource(longs = { VAULT_TOKEN_TTL_DEFAULT, VAULT_TOKEN_TTL_DEFAULT + 1 }) void createSettings_withVaultTokenRenewBufferEqualOrGreaterThanTtl_shouldThrowException(long value) { var throwable = assertThrows(Exception.class, () -> createSettings( URL, TOKEN, - HEALTH_CHECK_PATH, + HEALTH_CHECK_PATH, VAULT_TOKEN_TTL_DEFAULT, value)); assertThat(throwable.getMessage()).isEqualTo("Vault token renew buffer value must be less than ttl value"); diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTaskTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTaskTest.java similarity index 98% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTaskTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTaskTest.java index 1b9959f791f..7f0256a15ad 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultTokenRenewTaskTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/client/HashicorpVaultTokenRenewTaskTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.client; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.result.Result; @@ -38,6 +38,7 @@ class HashicorpVaultTokenRenewTaskTest { private final Monitor monitor = mock(); private final HashicorpVaultClient client = mock(); private final HashicorpVaultTokenRenewTask tokenRenewTask = new HashicorpVaultTokenRenewTask( + "Hashicorp Vault", ExecutorInstrumentation.noop(), client, RENEW_BUFFER, diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheckTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheckTest.java similarity index 97% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheckTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheckTest.java index ec439778b43..f139d6a669d 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/HashicorpVaultHealthCheckTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/health/HashicorpVaultHealthCheckTest.java @@ -13,10 +13,11 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.health; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.result.Result; +import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultClient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/PathUtilTest.java b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/util/PathUtilTest.java similarity index 97% rename from extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/PathUtilTest.java rename to extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/util/PathUtilTest.java index 3ae20c39a4f..5d9638eeb0d 100644 --- a/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/PathUtilTest.java +++ b/extensions/common/vault/vault-hashicorp/src/test/java/org/eclipse/edc/vault/hashicorp/util/PathUtilTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.vault.hashicorp; +package org.eclipse.edc.vault.hashicorp.util; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.ParameterizedTest;