diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index 788491ed0c315deef32d9d4faa6b860567e155ba..0489626493e9b2bb17228040037e4d4e4f883f0d 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -68,21 +68,6 @@ spec: configMapKeyRef: name: osdu-svc-properties key: ENV_KEYVAULT - - name: AZURE_CLIENT_ID - valueFrom: - secretKeyRef: - name: active-directory - key: principal-clientid - - name: AZURE_CLIENT_SECRET - valueFrom: - secretKeyRef: - name: active-directory - key: principal-clientpassword - - name: AZURE_TENANT_ID - valueFrom: - secretKeyRef: - name: active-directory - key: tenantid - name: aad_client_id valueFrom: secretKeyRef: diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/ElasticClientHandlerTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/ElasticClientHandlerTest.java index e5782165553a1efd1a5a39a3ffa6891696371993..effda48aaef31616b6f583844fdadbd31276747a 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/ElasticClientHandlerTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/ElasticClientHandlerTest.java @@ -19,29 +19,30 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestHighLevelClient; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService; import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.model.search.DeploymentEnvironment; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.powermock.core.classloader.annotations.PrepareForTest; -import org.springframework.test.context.junit4.SpringRunner; +import org.powermock.modules.junit4.PowerMockRunner; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; +import static org.powermock.api.mockito.PowerMockito.mockStatic; -@Ignore -@RunWith(SpringRunner.class) -@PrepareForTest({RestClientBuilder.class, RestClient.class, RestHighLevelClient.class}) +@RunWith(PowerMockRunner.class) +@PrepareForTest({RestClient.class, RestHighLevelClient.class}) public class ElasticClientHandlerTest { + private static final boolean SECURITY_HTTPS_CERTIFICATE_TRUST = false; + @Mock private IndexerConfigurationProperties configurationProperties; @Mock @@ -62,7 +63,9 @@ public class ElasticClientHandlerTest { public void setup() { initMocks(this); -// mockStatic(RestClient.class); + mockStatic(RestClient.class); + + elasticClientHandler.setSecurityHttpsCertificateTrust(SECURITY_HTTPS_CERTIFICATE_TRUST); } @Test @@ -70,7 +73,7 @@ public class ElasticClientHandlerTest { ClusterSettings clusterSettings = new ClusterSettings("H", 1, "U:P"); when(configurationProperties.getDeploymentEnvironment()).thenReturn(DeploymentEnvironment.CLOUD); when(elasticSettingService.getElasticClusterInformation()).thenReturn(clusterSettings); - when(RestClient.builder(new HttpHost("H", 1, "https"))).thenReturn(builder); + when(RestClient.builder(new HttpHost("H", 1, "https"))).thenAnswer(invocation -> builder); when(builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(60000))).thenReturn(builder); when(builder.build()).thenReturn(restClient); @@ -84,7 +87,7 @@ public class ElasticClientHandlerTest { ClusterSettings clusterSettings = new ClusterSettings("H", 1, "U:P"); when(configurationProperties.getDeploymentEnvironment()).thenReturn(DeploymentEnvironment.CLOUD); when(elasticSettingService.getElasticClusterInformation()).thenReturn(clusterSettings); - when(RestClient.builder(new HttpHost("H", 1, "https"))).thenReturn(builder); + when(RestClient.builder(new HttpHost("H", 1, "https"))).thenAnswer(invocation -> builder); when(builder.build()).thenReturn(null); this.elasticClientHandler.createRestClient(); @@ -94,7 +97,7 @@ public class ElasticClientHandlerTest { public void failed_createRestClientForSaaS_when_getcluster_info_throws_exception() { when(configurationProperties.getDeploymentEnvironment()).thenReturn(DeploymentEnvironment.CLOUD); when(elasticSettingService.getElasticClusterInformation()).thenThrow(new AppException(1, "", "")); - when(RestClient.builder(new HttpHost("H", 1, "https"))).thenReturn(builder); + when(RestClient.builder(new HttpHost("H", 1, "https"))).thenAnswer(invocation -> builder); this.elasticClientHandler.createRestClient(); }