diff --git a/integrations/oci/authentication/instance/pom.xml b/integrations/oci/authentication/instance/pom.xml
index 031fe76a77b..fcff26ab150 100644
--- a/integrations/oci/authentication/instance/pom.xml
+++ b/integrations/oci/authentication/instance/pom.xml
@@ -63,16 +63,6 @@
slf4j-jdk14
test
-
- io.helidon.webserver.testing.junit5
- helidon-webserver-testing-junit5
- test
-
-
- org.mockito
- mockito-core
- test
-
diff --git a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/AuthenticationMethodInstancePrincipalTest.java b/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/AuthenticationMethodInstancePrincipalTest.java
index b0637f250a9..1ec83d01b47 100644
--- a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/AuthenticationMethodInstancePrincipalTest.java
+++ b/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/AuthenticationMethodInstancePrincipalTest.java
@@ -18,45 +18,24 @@
import java.util.Properties;
-import io.helidon.webserver.WebServer;
-import io.helidon.webserver.http.HttpRules;
-import io.helidon.webserver.http.ServerRequest;
-import io.helidon.webserver.http.ServerResponse;
-import io.helidon.webserver.testing.junit5.ServerTest;
-import io.helidon.webserver.testing.junit5.SetUpRoute;
-
import io.helidon.service.registry.ServiceRegistry;
import io.helidon.service.registry.ServiceRegistryManager;
-import com.oracle.bmc.auth.BasicAuthenticationDetailsProvider;
+import com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-@ServerTest
public class AuthenticationMethodInstancePrincipalTest {
private static ServiceRegistryManager registryManager;
private static ServiceRegistry registry;
- private static String imdsBaseUri;
-
- AuthenticationMethodInstancePrincipalTest(WebServer server) {
- imdsBaseUri = "http://localhost:%d/opc/v2/".formatted(server.port());
- }
-
- @SetUpRoute
- static void routing(HttpRules rules) {
- rules.get("/opc/v2/instance", ImdsEmulator::emulateImdsInstance);
- }
void setUp(Properties p) {
p.put("helidon.oci.authentication-method", "instance-principal");
p.put("helidon.oci.imds-timeout", "PT1S");
p.put("helidon.oci.imds-detect-retries", "0");
- p.put("helidon.oci.imds-base-uri", imdsBaseUri);
System.setProperties(p);
registryManager = ServiceRegistryManager.create();
@@ -73,37 +52,20 @@ void cleanUp() {
@Test
public void testInstancePrincipalConfigurationAndInstantiation() {
+ final String IMDS_BASE_URI = "http://localhost:8000/opc/v2/";
final String FEDERATION_ENDPOINT = "https://auth.us-myregion-1.oraclecloud.com";
final String TENANT_ID = "ocid1.tenancy.oc1..mytenancyid";
Properties p = System.getProperties();
+ p.put("helidon.oci.imds-base-uri", IMDS_BASE_URI);
p.put("helidon.oci.federation-endpoint", FEDERATION_ENDPOINT);
p.put("helidon.oci.tenant-id", TENANT_ID);
setUp(p);
- // This error indicates that the instance principal provider has been instantiated
- var thrown = assertThrows(IllegalArgumentException.class,
- () -> registry.get(BasicAuthenticationDetailsProvider.class));
- assertThat(thrown.getMessage(),
- containsString(MockedInstancePrincipalBuilderProvider.INSTANCE_PRINCIPAL_INSTANTIATION_MESSAGE));
-
+ var builder = registry.get(InstancePrincipalsAuthenticationDetailsProvider.InstancePrincipalsAuthenticationDetailsProviderBuilder.class);
// The following validation indicates that the instance principal provider has been configured properly
- assertThat(MockedAuthenticationMethodInstancePrincipal.getBuilder().getMetadataBaseUrl(), is(imdsBaseUri));
- assertThat(MockedAuthenticationMethodInstancePrincipal.getBuilder().getFederationEndpoint(), is(FEDERATION_ENDPOINT));
- assertThat(MockedAuthenticationMethodInstancePrincipal.getBuilder().getTenancyId(), is(TENANT_ID));
- }
-
- public static class ImdsEmulator {
- // This will allow HelidonOci.imdsAvailable() to be tested by making the server that simulates IMDS to return a JSON value
- // when instance property is queried
- private static final String IMDS_INSTANCE_RESPONSE = """
- {
- "displayName": "helidon-server"
- }
- """;
-
- private static void emulateImdsInstance(ServerRequest req, ServerResponse res) {
- res.send(IMDS_INSTANCE_RESPONSE);
- }
+ assertThat(builder.getMetadataBaseUrl(), is(IMDS_BASE_URI));
+ assertThat(builder.getFederationEndpoint(), is(FEDERATION_ENDPOINT));
+ assertThat(builder.getTenancyId(), is(TENANT_ID));
}
}
diff --git a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedAuthenticationMethodInstancePrincipal.java b/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedAuthenticationMethodInstancePrincipal.java
deleted file mode 100644
index 2e9e0e9610a..00000000000
--- a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedAuthenticationMethodInstancePrincipal.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2025 Oracle and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.helidon.integrations.oci.authentication.instance;
-
-import java.util.Optional;
-import java.util.function.Supplier;
-
-import io.helidon.common.Weight;
-import io.helidon.common.Weighted;
-import io.helidon.integrations.oci.OciConfig;
-import io.helidon.service.registry.Service;
-
-import com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider.InstancePrincipalsAuthenticationDetailsProviderBuilder;
-
-@Weight(Weighted.DEFAULT_WEIGHT)
-@Service.Provider
-class MockedAuthenticationMethodInstancePrincipal extends AuthenticationMethodInstancePrincipal {
-
- private static InstancePrincipalsAuthenticationDetailsProviderBuilder providerBuilder;
-
- MockedAuthenticationMethodInstancePrincipal(OciConfig config,
- Supplier>
- builder) {
- super(config, builder);
- providerBuilder = builder.get().get();
- }
-
- static InstancePrincipalsAuthenticationDetailsProviderBuilder getBuilder() {
- return providerBuilder;
- }
-}
diff --git a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedInstancePrincipalBuilderProvider.java b/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedInstancePrincipalBuilderProvider.java
deleted file mode 100644
index 332a77d5bf7..00000000000
--- a/integrations/oci/authentication/instance/src/test/java/io/helidon/integrations/oci/authentication/instance/MockedInstancePrincipalBuilderProvider.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2025 Oracle and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.helidon.integrations.oci.authentication.instance;
-
-import java.util.function.Supplier;
-
-import io.helidon.common.Weight;
-import io.helidon.common.Weighted;
-import io.helidon.integrations.oci.OciConfig;
-import io.helidon.service.registry.Service;
-
-import com.oracle.bmc.auth.InstancePrincipalsAuthenticationDetailsProvider.InstancePrincipalsAuthenticationDetailsProviderBuilder;
-
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-
-@Weight(Weighted.DEFAULT_WEIGHT + 10)
-@Service.Provider
-class MockedInstancePrincipalBuilderProvider extends InstancePrincipalBuilderProvider
- implements Supplier {
- static final String INSTANCE_PRINCIPAL_INSTANTIATION_MESSAGE = "Instance Principal has been instantiated";
- private String metadataBaseUrl = null;
- private String tenancyID = null;
- private String federationEndpoint = null;
-
- MockedInstancePrincipalBuilderProvider(OciConfig config) {
- super(config);
- }
-
- @Override
- InstancePrincipalsAuthenticationDetailsProviderBuilder getBuilder() {
- // Mock the InstancePrincipalsAuthenticationDetailsProviderBuilder
- final InstancePrincipalsAuthenticationDetailsProviderBuilder builder =
- mock(InstancePrincipalsAuthenticationDetailsProviderBuilder.class);
-
- doAnswer(invocation -> {
- throw new IllegalArgumentException(INSTANCE_PRINCIPAL_INSTANTIATION_MESSAGE);
- }).when(builder).build();
-
- // Process metadataBaseUrl
- doAnswer(invocation -> {
- metadataBaseUrl = invocation.getArgument(0);
- return null;
- }).when(builder).metadataBaseUrl(any());
- doAnswer(invocation -> {
- return metadataBaseUrl;
- }).when(builder).getMetadataBaseUrl();
-
- // Process federationEndpoint
- doAnswer(invocation -> {
- federationEndpoint = invocation.getArgument(0);
- return null;
- }).when(builder).federationEndpoint(any());
- doAnswer(invocation -> {
- return federationEndpoint;
- }).when(builder).getFederationEndpoint();
-
- // Process tenancyId
- doAnswer(invocation -> {
- tenancyID = invocation.getArgument(0);
- return null;
- }).when(builder).tenancyId(any());
- doAnswer(invocation -> {
- return tenancyID;
- }).when(builder).getTenancyId();
-
- return builder;
- }
-}
diff --git a/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/AuthenticationMethodOkeWorkloadTest.java b/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/AuthenticationMethodOkeWorkloadTest.java
index 0cdbf5d77c3..79c88d6df8e 100644
--- a/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/AuthenticationMethodOkeWorkloadTest.java
+++ b/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/AuthenticationMethodOkeWorkloadTest.java
@@ -22,6 +22,7 @@
import io.helidon.service.registry.ServiceRegistryManager;
import com.oracle.bmc.auth.BasicAuthenticationDetailsProvider;
+import com.oracle.bmc.auth.okeworkloadidentity.OkeWorkloadIdentityAuthenticationDetailsProvider.OkeWorkloadIdentityAuthenticationDetailsProviderBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@@ -62,10 +63,12 @@ public void testOkeWorkloadIdentityConfigurationAndInstantiation() {
// This error indicates that the oke-workload-identity provider has been instantiated
var thrown = assertThrows(IllegalArgumentException.class,
- () -> registry.get(BasicAuthenticationDetailsProvider.class));
+ () -> registry.get(BasicAuthenticationDetailsProvider.class));
assertThat(thrown.getMessage(), containsString("Invalid Kubernetes ca certification"));
+
+ var builder = registry.get(OkeWorkloadIdentityAuthenticationDetailsProviderBuilder.class);
// The following validation indicates that the oke-workload-identity provider has been configured properly
- assertThat(MockedAuthenticationMethodOkeWorkload.getBuilder().getFederationEndpoint(), is(FEDERATION_ENDPOINT));
- assertThat(MockedAuthenticationMethodOkeWorkload.getBuilder().getTenancyId(), is(TENANT_ID));
+ assertThat(builder.getFederationEndpoint(), is(FEDERATION_ENDPOINT));
+ assertThat(builder.getTenancyId(), is(TENANT_ID));
}
}
diff --git a/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/MockedAuthenticationMethodOkeWorkload.java b/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/MockedAuthenticationMethodOkeWorkload.java
deleted file mode 100644
index 3c79f3c4fc4..00000000000
--- a/integrations/oci/authentication/oke-workload/src/test/java/io/helidon/integrations/oci/authentication/okeworkload/MockedAuthenticationMethodOkeWorkload.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2025 Oracle and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.helidon.integrations.oci.authentication.okeworkload;
-
-import java.util.Optional;
-import java.util.function.Supplier;
-
-import io.helidon.common.Weight;
-import io.helidon.common.Weighted;
-import io.helidon.service.registry.Service;
-
-import com.oracle.bmc.auth.okeworkloadidentity
- .OkeWorkloadIdentityAuthenticationDetailsProvider.OkeWorkloadIdentityAuthenticationDetailsProviderBuilder;
-
-@Service.Provider
-class MockedAuthenticationMethodOkeWorkload extends AuthenticationMethodOkeWorkload {
-
- private static OkeWorkloadIdentityAuthenticationDetailsProviderBuilder providerBuilder;
-
- MockedAuthenticationMethodOkeWorkload(Supplier> builder) {
- super(builder);
- providerBuilder = builder.get().get();
- }
-
- static OkeWorkloadIdentityAuthenticationDetailsProviderBuilder getBuilder() {
- return providerBuilder;
- }
-}
diff --git a/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/AuthenticationMethodResourcePrincipalTest.java b/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/AuthenticationMethodResourcePrincipalTest.java
index 166ad470f67..b7ce3c906f3 100644
--- a/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/AuthenticationMethodResourcePrincipalTest.java
+++ b/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/AuthenticationMethodResourcePrincipalTest.java
@@ -22,6 +22,7 @@
import io.helidon.service.registry.ServiceRegistryManager;
import com.oracle.bmc.auth.BasicAuthenticationDetailsProvider;
+import com.oracle.bmc.auth.ResourcePrincipalAuthenticationDetailsProvider.ResourcePrincipalAuthenticationDetailsProviderBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@@ -65,8 +66,10 @@ public void testResourcePrincipalConfigurationAndInstantiation() {
() -> registry.get(BasicAuthenticationDetailsProvider.class));
assertThat(thrown.getMessage(),
containsString("Resource principals authentication can only be used in certain OCI services"));
+
+ var builder = registry.get(ResourcePrincipalAuthenticationDetailsProviderBuilder.class);
// The following validation indicates that the resource principal provider has been configured properly
- assertThat(MockedAuthenticationMethodResourcePrincipal.getBuilder().getFederationEndpoint(), is(FEDERATION_ENDPOINT));
- assertThat(MockedAuthenticationMethodResourcePrincipal.getBuilder().getTenancyId(), is(TENANT_ID));
+ assertThat(builder.getFederationEndpoint(), is(FEDERATION_ENDPOINT));
+ assertThat(builder.getTenancyId(), is(TENANT_ID));
}
}
diff --git a/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/MockedAuthenticationMethodResourcePrincipal.java b/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/MockedAuthenticationMethodResourcePrincipal.java
deleted file mode 100644
index bcc64a46abb..00000000000
--- a/integrations/oci/authentication/resource/src/test/java/io/helidon/integrations/oci/authentication/resource/MockedAuthenticationMethodResourcePrincipal.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2025 Oracle and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.helidon.integrations.oci.authentication.resource;
-
-import java.util.Optional;
-import java.util.function.Supplier;
-
-import io.helidon.common.Weight;
-import io.helidon.common.Weighted;
-import io.helidon.service.registry.Service;
-
-import com.oracle.bmc.auth.ResourcePrincipalAuthenticationDetailsProvider.ResourcePrincipalAuthenticationDetailsProviderBuilder;
-
-@Service.Provider
-class MockedAuthenticationMethodResourcePrincipal extends AuthenticationMethodResourcePrincipal {
-
- private static ResourcePrincipalAuthenticationDetailsProviderBuilder providerBuilder;
-
- MockedAuthenticationMethodResourcePrincipal(Supplier> builder) {
- super(builder);
- providerBuilder = builder.get().get();
- }
-
- static ResourcePrincipalAuthenticationDetailsProviderBuilder getBuilder() {
- return providerBuilder;
- }
-}