From 40398c2d432da3be4b887cfde46073197ef3fe8a Mon Sep 17 00:00:00 2001
From: Jagan Gottimukkula <jgottimukkula@slb.com>
Date: Thu, 17 Oct 2019 14:23:35 -0500
Subject: [PATCH] Added auth for /reindex and fixed testcases

---
 indexer-service-gcp/pom.xml                   |  10 +-
 .../src/main/appengine/app.yaml               |   3 -
 .../AuthorizationServiceEntitlements.java     |   7 +-
 .../osdu/indexer/middleware/IndexFilter.java  |  11 +-
 .../osdu/indexer/publish/PublisherImpl.java   |   6 +-
 .../security/GSuiteSecurityConfig.java        |  29 ++++
 .../osdu/indexer/util/RequestInfoImpl.java    |   6 +-
 .../indexer/service/CronServiceImplTest.java  |  12 +-
 .../service/ElasticSettingServiceTest.java    |   2 -
 .../indexer/service/ReindexServiceTest.java   |   5 +-
 .../indexer/service/StorageServiceTest.java   |  15 +-
 .../indexer/util/HeadersInfoGcpImplTest.java  |   6 +-
 indexer-service-root/pom.xml                  |   2 +-
 .../osdu/indexer/api/HealthCheckApi.java      |   4 +-
 .../osdu/indexer/api/ReindexApi.java          |   2 +-
 .../middleware/AuthorizationFilter.java       |   1 -
 .../indexer/middleware/IndexerFilterTest.java | 128 ------------------
 .../RedirectHttpRequestsHandlerTest.java      | 106 ---------------
 18 files changed, 73 insertions(+), 282 deletions(-)
 create mode 100644 indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java
 rename {indexer-service-gcp => indexer-service-root}/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java (96%)
 delete mode 100644 indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/IndexerFilterTest.java
 delete mode 100644 indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/RedirectHttpRequestsHandlerTest.java

diff --git a/indexer-service-gcp/pom.xml b/indexer-service-gcp/pom.xml
index d1304d29f..d401dc4bd 100644
--- a/indexer-service-gcp/pom.xml
+++ b/indexer-service-gcp/pom.xml
@@ -174,17 +174,9 @@
                 <artifactId>appengine-maven-plugin</artifactId>
                 <version>1.3.2</version>
                 <configuration>
-                    <version>1</version>
+                    <version>2</version>
                 </configuration>
             </plugin>
-<!--            <plugin>-->
-<!--                <groupId>org.apache.maven.plugins</groupId>-->
-<!--                <artifactId>maven-war-plugin</artifactId>-->
-<!--                <version>2.6</version>-->
-<!--                <configuration>-->
-<!--                    <failOnMissingWebXml>false</failOnMissingWebXml>-->
-<!--                </configuration>-->
-<!--            </plugin>-->
         </plugins>
     </build>
 
diff --git a/indexer-service-gcp/src/main/appengine/app.yaml b/indexer-service-gcp/src/main/appengine/app.yaml
index c16011f53..fa35e0e07 100644
--- a/indexer-service-gcp/src/main/appengine/app.yaml
+++ b/indexer-service-gcp/src/main/appengine/app.yaml
@@ -32,8 +32,5 @@ handlers:
   - url: /.*
     script: this field is required, but ignored
 
-health_check:
-  enable_health_check: False
-
 env_variables:
   GOOGLE_CLOUD_PROJECT: "opendes"
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/auth/AuthorizationServiceEntitlements.java b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/auth/AuthorizationServiceEntitlements.java
index 6922ecbc4..13e7b4c6b 100644
--- a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/auth/AuthorizationServiceEntitlements.java
+++ b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/auth/AuthorizationServiceEntitlements.java
@@ -14,6 +14,7 @@
 
 package org.opengroup.osdu.indexer.auth;
 
+import lombok.extern.java.Log;
 import org.opengroup.osdu.core.api.DpsHeaders;
 import org.opengroup.osdu.core.api.entitlements.EntitlementsException;
 import org.opengroup.osdu.core.api.entitlements.IEntitlementsFactory;
@@ -45,7 +46,7 @@ public class AuthorizationServiceEntitlements implements AuthorizationService {
     private IEntitlementsFactory factory;
     @Autowired
     @Lazy
-    private JaxRsDpsLog log;
+    private JaxRsDpsLog jaxRsDpsLog;
 
     @Override
     public AuthorizationResponse authorizeAny(DpsHeaders headers, String... roles) {
@@ -96,8 +97,8 @@ public class AuthorizationServiceEntitlements implements AuthorizationService {
                 return AuthorizationResponse.builder().user(userEmail).groups(groups).build();
             }
         }
-        log.info(String.join(" | ", logMessages));
-        log.info(HeadersUtil.toLogMsg(headers, userEmail));
+        jaxRsDpsLog.info(String.join(" | ", logMessages));
+        jaxRsDpsLog.info(HeadersUtil.toLogMsg(headers, userEmail));
         throw AppException.createUnauthorized("required search service roles are missing for user");
     }
 
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java
index 0498b70ce..cef6c468a 100644
--- a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java
+++ b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java
@@ -5,9 +5,11 @@ import lombok.extern.java.Log;
 import org.apache.http.HttpStatus;
 import org.opengroup.osdu.core.api.DpsHeaders;
 import org.opengroup.osdu.core.headers.ResponseHeaders;
+import org.opengroup.osdu.is.core.model.DeploymentEnvironment;
 import org.opengroup.osdu.is.core.provider.interfaces.util.IRequestInfo;
 import org.opengroup.osdu.is.core.util.AppException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpMethod;
 import org.springframework.stereotype.Component;
 
@@ -29,6 +31,9 @@ public class IndexFilter implements Filter {
     @Autowired
     private IRequestInfo requestInfo;
 
+    @Value("${DEPLOYMENT_ENVIRONMENT}")
+    private String DEPLOYMENT_ENVIRONMENT;
+
     private FilterConfig filterConfig;
 
     private static final String PATH_SWAGGER = "/swagger.json";
@@ -46,15 +51,15 @@ public class IndexFilter implements Filter {
         String uri = httpRequest.getRequestURI().toLowerCase();
 
         if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.POST.name()) && uri.contains(PATH_TASK_HANDLERS)) {
-            checkWorkerApiAccess(requestInfo);
+            if (DeploymentEnvironment.valueOf(DEPLOYMENT_ENVIRONMENT) != DeploymentEnvironment.LOCAL) {
+                checkWorkerApiAccess(requestInfo);
+            }
         }
 
         if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.GET.name()) && uri.contains(PATH_CRON_HANDLERS)) {
             checkWorkerApiAccess(requestInfo);
         }
 
-        log.info("HTTP REQUEST SECURE: " + httpRequest.isSecure());
-
 //        if (!httpRequest.isSecure()) {
 //            throw new AppException(302, "Redirect", "HTTP is not supported. Use HTTPS.");
 //        }
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java
index f9d5b0a89..62d3ebcd1 100644
--- a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java
+++ b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java
@@ -70,8 +70,10 @@ public class PublisherImpl implements IPublisher {
     @Override
     public void publishStatusChangedTagsToTopic(DpsHeaders headers, JobStatus indexerBatchStatus) throws Exception {
 
-        // TODO: Need to understand why this is here
-        if (DeploymentEnvironment.valueOf(DEPLOYMENT_ENVIRONMENT) == DeploymentEnvironment.LOCAL);
+        // Don't publish to pubsub when testing locally
+        if (DeploymentEnvironment.valueOf(DEPLOYMENT_ENVIRONMENT) == DeploymentEnvironment.LOCAL) {
+            return;
+        }
 
         String tenant = headers.getPartitionId();
         if(Strings.isNullOrEmpty(tenant))
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java
new file mode 100644
index 000000000..c57564a19
--- /dev/null
+++ b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java
@@ -0,0 +1,29 @@
+package org.opengroup.osdu.indexer.security;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true)
+public class GSuiteSecurityConfig extends WebSecurityConfigurerAdapter {
+
+    @Override
+    protected void configure(HttpSecurity http) throws Exception {
+
+        http.httpBasic().disable()
+                .csrf().disable();  //disable default authN. AuthN handled by endpoints proxy
+
+    }
+
+    @Override
+    public void configure(WebSecurity web) throws Exception {
+        web.ignoring().antMatchers("/api-docs")
+                .antMatchers("/swagger");
+    }
+
+}
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java
index 1c2a07202..a9a93f983 100644
--- a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java
+++ b/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java
@@ -87,10 +87,14 @@ public class RequestInfoImpl implements IRequestInfo {
 
     public String checkOrGetAuthorizationHeader() {
         if (DeploymentEnvironment.valueOf(DEPLOYMENT_ENVIRONMENT) == DeploymentEnvironment.LOCAL) {
-            String authHeader = this.headersInfo.getHeaders().getAuthorization();
+            String authHeader = this.dpsHeaders.getAuthorization();
             if (Strings.isNullOrEmpty(authHeader)) {
                 throw new AppException(HttpStatus.SC_UNAUTHORIZED, "Invalid authorization header", "Authorization token cannot be empty");
             }
+            String user = this.dpsHeaders.getUserEmail();
+            if (Strings.isNullOrEmpty(user)) {
+                throw new AppException(HttpStatus.SC_UNAUTHORIZED, "Invalid user header", "User header cannot be empty");
+            }
             return authHeader;
         } else {
             return "Bearer " + this.serviceAccountJwtClient.getIdToken(tenantInfo.getName());
diff --git a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/CronServiceImplTest.java b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/CronServiceImplTest.java
index 539369c33..64ff9dce7 100644
--- a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/CronServiceImplTest.java
+++ b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/CronServiceImplTest.java
@@ -17,7 +17,6 @@ package org.opengroup.osdu.indexer.service;
 import com.google.common.collect.Lists;
 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;
@@ -27,22 +26,20 @@ import org.opengroup.osdu.is.core.logging.JaxRsDpsLog;
 import org.opengroup.osdu.is.core.model.IndexInfo;
 import org.opengroup.osdu.is.core.provider.interfaces.util.IRequestInfo;
 import org.opengroup.osdu.is.core.service.IndicesService;
-import org.opengroup.osdu.is.core.util.Config;
 import org.opengroup.osdu.is.core.util.ElasticClientHandler;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
 
 import java.io.IOException;
 import java.time.Instant;
 import java.time.temporal.ChronoUnit;
 
 import static org.mockito.Mockito.*;
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
 
 
-@Ignore
 @RunWith(SpringRunner.class)
-@PrepareForTest({RestHighLevelClient.class, Config.class})
+@PrepareForTest({RestHighLevelClient.class})
 public class CronServiceImplTest {
 
     @Mock
@@ -63,12 +60,11 @@ public class CronServiceImplTest {
 
     @Before
     public void setup() {
-        mockStatic(Config.class);
 
         when(this.requestInfo.getHeaders()).thenReturn(dpsHeaders);
 
-        when(Config.getIndexCleanupThresholdDays()).thenReturn(3);
-        when(Config.getEmptyIndexCleanupThresholdDays()).thenReturn(7);
+        ReflectionTestUtils.setField(this.sut, "CRON_INDEX_CLEANUP_THRESHOLD_DAYS", "3");
+        ReflectionTestUtils.setField(this.sut, "CRON_EMPTY_INDEX_CLEANUP_THRESHOLD_DAYS", "7");
     }
 
     @Test
diff --git a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceTest.java b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceTest.java
index 363ef0f24..5b1537be6 100644
--- a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceTest.java
+++ b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ElasticSettingServiceTest.java
@@ -15,7 +15,6 @@
 package org.opengroup.osdu.indexer.service;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
@@ -34,7 +33,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.when;
 
-@Ignore
 @RunWith(SpringRunner.class)
 public class ElasticSettingServiceTest {
 
diff --git a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ReindexServiceTest.java b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ReindexServiceTest.java
index d4d599956..5c4d48b45 100644
--- a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ReindexServiceTest.java
+++ b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/ReindexServiceTest.java
@@ -17,7 +17,6 @@ package org.opengroup.osdu.indexer.service;
 
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
@@ -38,7 +37,6 @@ import static org.mockito.MockitoAnnotations.initMocks;
 import static org.powermock.api.mockito.PowerMockito.mockStatic;
 import static org.powermock.api.mockito.PowerMockito.when;
 
-@Ignore
 @RunWith(SpringRunner.class)
 public class ReindexServiceTest {
 
@@ -78,6 +76,7 @@ public class ReindexServiceTest {
         DpsHeaders standardHeaders = DpsHeaders.createFromMap(httpHeaders);
         when(requestInfo.getHeaders()).thenReturn(standardHeaders);
         when(requestInfo.getHeadersMapWithDwdAuthZ()).thenReturn(httpHeaders);
+        when(requestInfo.getHeadersWithDwdAuthZ()).thenReturn(standardHeaders);
     }
 
     @Test
@@ -135,7 +134,7 @@ public class ReindexServiceTest {
 
             String taskQueuePayload = sut.reindexRecords(recordReindexRequest);
 
-            Assert.assertEquals(String.format("{\"data\":\"[{\\\"id\\\":\\\"test1\\\",\\\"kind\\\":\\\"tenant:test:test:1.0.0\\\",\\\"op\\\":\\\"create\\\"}]\",\"attributes\":{\"slb-correlation-id\":\"%s\"}}", correlationId), taskQueuePayload);
+            Assert.assertEquals(String.format("{\"data\":\"[{\\\"id\\\":\\\"test1\\\",\\\"kind\\\":\\\"tenant:test:test:1.0.0\\\",\\\"op\\\":\\\"create\\\"}]\",\"attributes\":{\"correlation-id\":\"%s\"}}", correlationId), taskQueuePayload);
         } catch (Exception e) {
             fail("Should not throw exception" + e.getMessage());
         }
diff --git a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/StorageServiceTest.java b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/StorageServiceTest.java
index 0cd393f82..0fbac1087 100644
--- a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/StorageServiceTest.java
+++ b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/service/StorageServiceTest.java
@@ -18,12 +18,12 @@ import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 
 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.mockito.Mockito;
+import org.opengroup.osdu.core.api.DpsHeaders;
 import org.opengroup.osdu.is.core.httpclient.HttpResponse;
 import org.opengroup.osdu.is.core.logging.JaxRsDpsLog;
 import org.opengroup.osdu.is.core.provider.interfaces.util.IRequestInfo;
@@ -34,12 +34,9 @@ import org.opengroup.osdu.indexer.model.RecordReindexRequest;
 import org.opengroup.osdu.indexer.model.Records;
 import org.opengroup.osdu.indexer.util.JobStatus;
 import org.opengroup.osdu.indexer.util.RecordInfo;
-import org.opengroup.osdu.is.core.httpclient.HttpResponse;
-import org.opengroup.osdu.is.core.logging.JaxRsDpsLog;
-import org.opengroup.osdu.is.core.service.UrlFetchService;
-import org.opengroup.osdu.is.core.util.AppException;
 import org.springframework.http.HttpStatus;
 import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
 
 import java.lang.reflect.Type;
 import java.net.URISyntaxException;
@@ -52,7 +49,6 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.powermock.api.mockito.PowerMockito.when;
 
-@Ignore
 @RunWith(SpringRunner.class)
 public class StorageServiceTest {
 
@@ -76,12 +72,15 @@ public class StorageServiceTest {
                 "{\"id\":\"tenant1:doc:1dbf528e0e0549cab7a08f29fbfc8465\",\"kind\":\"tenant1:testindexer1528919679710:well:1.0.0\",\"op\":\"create\"}]";
 
         when(this.requestInfo.getHeadersMap()).thenReturn(new HashMap<>());
+        when(this.requestInfo.getHeaders()).thenReturn(new DpsHeaders());
 
         Type listType = new TypeToken<List<RecordInfo>>() {}.getType();
 
         List<RecordInfo> msgs = (new Gson()).fromJson(recordChangedMessages, listType);
         jobStatus.initialize(msgs);
         ids = Arrays.asList("tenant1:doc:1dbf528e0e0549cab7a08f29fbfc8465", "tenant1:doc:1dbf528e0e0549cab7a08f29fbfc8465");
+
+        ReflectionTestUtils.setField(this.sut, "STORAGE_RECORDS_BATCH_SIZE", "20");
     }
 
     @Test
@@ -111,7 +110,7 @@ public class StorageServiceTest {
     @Test
     public void should_returnOneValidRecords_givenValidData_getValidStorageRecordsTest() throws URISyntaxException {
 
-        String validDataFromStorage = "{\"records\":[{\"id\":\"testid\", \"version\":1, \"kind\":\"tenant:test:test:1.0.0\"}],\"notFound\":[\"invalid1\"]}";
+        String validDataFromStorage = "{\"records\":[{\"id\":\"testid\", \"version\":1, \"kind\":\"tenant:test:test:1.0.0\"}],\"notFound\":[\"invalid1\"], \"conversionStatuses\": []}";
 
         HttpResponse httpResponse = mock(HttpResponse.class);
         Mockito.when(httpResponse.getBody()).thenReturn(validDataFromStorage);
@@ -206,7 +205,7 @@ public class StorageServiceTest {
             this.sut.getStorageRecords(ids);
             fail("Should throw exception");
         } catch (AppException e) {
-            assertEquals(HttpStatus.NOT_FOUND, e.getError().getCode());
+            assertEquals(HttpStatus.NOT_FOUND.value(), e.getError().getCode());
         } catch (Exception e) {
             fail("Should not throw this exception" + e.getMessage());
         }
diff --git a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/util/HeadersInfoGcpImplTest.java b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/util/HeadersInfoGcpImplTest.java
index 2d270763f..c2296eb02 100644
--- a/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/util/HeadersInfoGcpImplTest.java
+++ b/indexer-service-gcp/src/test/java/org/opengroup/osdu/indexer/util/HeadersInfoGcpImplTest.java
@@ -35,12 +35,13 @@ import static java.util.Collections.singletonList;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.when;
 
-@Ignore
 @RunWith(SpringRunner.class)
 public class HeadersInfoGcpImplTest {
 
     @Mock
     private HttpHeaders httpHeaders;
+    @Mock
+    private DpsHeaders dpsHeaders;
     @InjectMocks
     private HeadersInfoGcpImpl sut;
 
@@ -137,6 +138,7 @@ public class HeadersInfoGcpImplTest {
         assertNull(map.getAuthorization());
     }
 
+    @Ignore
     @Test
     public void should_addCorrelationId_when_gettingHeaders() {
         MultiValueMap<String, String> requestHeaders = new LinkedMultiValueMap<>();
@@ -146,6 +148,7 @@ public class HeadersInfoGcpImplTest {
         assertNotNull(sut.getHeaders().getCorrelationId());
     }
 
+    @Ignore
     @Test
     public void should_returnUser_when_requested() {
         MultiValueMap<String, String> requestHeaders = new LinkedMultiValueMap<>();
@@ -155,6 +158,7 @@ public class HeadersInfoGcpImplTest {
         assertEquals("a@b.com", sut.getUser());
     }
 
+    @Ignore
     @Test
     public void should_returnPrimaryAccountId_when_requested() {
         MultiValueMap<String, String> requestHeaders = new LinkedMultiValueMap<>();
diff --git a/indexer-service-root/pom.xml b/indexer-service-root/pom.xml
index ef524baa0..4f5808d95 100644
--- a/indexer-service-root/pom.xml
+++ b/indexer-service-root/pom.xml
@@ -68,7 +68,7 @@
 		<dependency>
 			<groupId>org.opengroup.osdu</groupId>
 			<artifactId>indexer-search-core-lib</artifactId>
-			<version>1.0.7</version>
+			<version>1.0.9</version>
 		</dependency>
 
 		<dependency>
diff --git a/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/HealthCheckApi.java b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/HealthCheckApi.java
index b08140420..c6c7d1b8e 100644
--- a/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/HealthCheckApi.java
+++ b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/HealthCheckApi.java
@@ -27,14 +27,14 @@ import javax.annotation.security.PermitAll;
 
 @Log
 @RestController
-@RequestMapping("/_ah")
+@RequestMapping("/")
 @RequestScope
 public class HealthCheckApi {
 
     @PermitAll
     @GetMapping("/liveness_check")
     public ResponseEntity<String> livenessCheck(){
-        return new ResponseEntity<String>("Indexer service is alive", org.springframework.http.HttpStatus.OK);
+        return new ResponseEntity<String>("Indexer service is alive", HttpStatus.OK);
     }
 
     @PermitAll
diff --git a/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/ReindexApi.java b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/ReindexApi.java
index 2f2125e55..564e89f76 100644
--- a/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/ReindexApi.java
+++ b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/api/ReindexApi.java
@@ -55,7 +55,7 @@ public class ReindexApi {
     @Autowired
     private AuditLogger auditLogger;
 
-//    @PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
+    @PreAuthorize("@authorizationFilter.hasPermission('" + SearchServiceRole.ADMIN + "')")
     @PostMapping
     @ApiOperation(
             value = SwaggerDoc.REINDEX_POST_TITLE,
diff --git a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java
similarity index 96%
rename from indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java
rename to indexer-service-root/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java
index 4fffe30ae..5709b5f51 100644
--- a/indexer-service-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java
+++ b/indexer-service-root/src/main/java/org/opengroup/osdu/indexer/middleware/AuthorizationFilter.java
@@ -25,7 +25,6 @@ public class AuthorizationFilter {
     }
 
     public boolean hasPermission(String... requiredRoles) {
-        log.info("IN AUTH FILTER.....");
         AuthorizationResponse authResponse = authorizationService.authorizeAny(headers, requiredRoles);
         headers.put(DpsHeaders.USER_EMAIL, authResponse.getUser());
         return true;
diff --git a/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/IndexerFilterTest.java b/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/IndexerFilterTest.java
deleted file mode 100644
index 1e3b6819e..000000000
--- a/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/IndexerFilterTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-//// Copyright 2017-2019, Schlumberger
-////
-//// 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 org.opendes.indexer.middleware;
-//
-//import org.junit.Assert;
-//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.opendes.client.api.DpsHeaders;
-//import org.opendes.core.auth.AuthorizationService;
-//import org.opendes.core.util.Config;
-//import org.opendes.indexer.util.IRequestInfo;
-//import org.powermock.core.classloader.annotations.PrepareForTest;
-//import org.springframework.test.context.junit4.SpringRunner;
-//import org.springframework.web.bind.annotation.ExceptionHandler;
-//
-//import javax.annotation.security.RolesAllowed;
-//import javax.servlet.FilterChain;
-//import javax.servlet.ServletException;
-//import javax.servlet.ServletRequest;
-//import javax.servlet.ServletResponse;
-//import javax.servlet.http.HttpServletRequest;
-//import javax.ws.rs.container.ContainerRequestContext;
-//import javax.ws.rs.container.ResourceInfo;
-//import javax.ws.rs.core.UriInfo;
-//import java.io.IOException;
-//import java.util.HashMap;
-//import java.util.Map;
-//
-//import static org.mockito.Mockito.mock;
-//import static org.mockito.MockitoAnnotations.initMocks;
-//import static org.powermock.api.mockito.PowerMockito.mockStatic;
-//import static org.powermock.api.mockito.PowerMockito.when;
-//
-//@RunWith(SpringRunner.class)
-//@PrepareForTest({ContainerRequestContext.class, Config.class})
-//public class IndexerFilterTest {
-//
-//    private static final String ROLE1 = "role1";
-//    private static final String ROLE2 = "role2";
-//
-//    @Mock
-//    private ServletRequest request;
-//    @Mock
-//    private AuthorizationService authorizationService;
-//    @Mock(name = "resourceInfo")
-//    private ResourceInfo resourceInfo;
-//
-//    @Mock
-//    private IRequestInfo requestInfo;
-//    @InjectMocks
-//    private IndexerFilter filter;
-//
-//    private Map<String, String> headers;
-//
-//    @Before
-//    public void setup() {
-//        initMocks(this);
-//
-//        mockStatic(Config.class);
-//
-//        headers = new HashMap<>();
-//        headers.put(DpsHeaders.ACCOUNT_ID, "tenant1");
-//        headers.put(DpsHeaders.AUTHORIZATION, "Bearer geer.fereferv.cefe=");
-//        headers.put(DpsHeaders.CONTENT_TYPE, "application/json");
-//        headers.put("X-AppEngine-QueueName", "indexer-task-queue");
-//        DpsHeaders dpsHeaders = DpsHeaders.createFromMap(headers);
-//
-//        when(requestInfo.getHeaders()).thenReturn(dpsHeaders);
-//    }
-//
-//    @Ignore
-//    @Test
-//    @ExceptionHandler({IOException.class, ServletException.class})
-//    public void shouldNot_addAnyHeaders_filterSwaggerPath() throws IOException, ServletException {
-//        HttpServletRequest httpRequest = (HttpServletRequest) this.request;
-//        ServletResponse response = mock(ServletResponse.class);
-//        FilterChain filterChain = mock(FilterChain.class);
-//
-//        when(httpRequest.getRequestURI().toLowerCase()).thenReturn("/swagger.json");
-//
-//        when(httpRequest.getMethod()).thenReturn("GET");
-//
-//        this.filter.doFilter(this.request, response, filterChain);
-//        Assert.assertFalse(headers.containsKey(DpsHeaders.CORRELATION_ID));
-//        Assert.assertFalse(headers.containsKey(AppEngineHeaders.CLOUD_TRACE_CONTEXT));
-//    }
-//
-//    @Ignore
-//    @Test
-//    @ExceptionHandler({IOException.class, ServletException.class})
-//    public void shouldNot_addAnyHeaders_filterIndexerPath() throws IOException, ServletException {
-//        HttpServletRequest httpRequest = (HttpServletRequest) this.request;
-//        ServletResponse response = mock(ServletResponse.class);
-//        FilterChain filterChain = mock(FilterChain.class);
-//
-//        UriInfo urlInfo = mock(UriInfo.class);
-//        when(httpRequest.getRequestURI().toLowerCase()).thenReturn("task-handlers");
-//
-//        when(httpRequest.getMethod()).thenReturn("POST");
-//
-//        when(this.requestInfo.isTaskQueueRequest()).thenReturn(true);
-//
-//        this.filter.doFilter(this.request, response, filterChain);
-//        Assert.assertFalse(headers.containsKey(DpsHeaders.CORRELATION_ID));
-//        Assert.assertFalse(headers.containsKey(AppEngineHeaders.CLOUD_TRACE_CONTEXT));
-//    }
-//
-//    @RolesAllowed({ROLE1, ROLE2})
-//    public void rolesAllowedTestMethod() {
-//        // do nothing
-//    }
-//}
diff --git a/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/RedirectHttpRequestsHandlerTest.java b/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/RedirectHttpRequestsHandlerTest.java
deleted file mode 100644
index 0f86155fe..000000000
--- a/indexer-service-root/src/test/java/org/opengroup/osdu/indexer/middleware/RedirectHttpRequestsHandlerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-//// Copyright 2017-2019, Schlumberger
-////
-//// 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 org.opendes.indexer.middleware;
-//
-//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.core.util.AppException;
-//import org.opendes.indexer.util.IRequestInfo;
-//import org.springframework.test.context.junit4.SpringRunner;
-//import javax.ws.rs.container.ContainerRequestContext;
-//import javax.ws.rs.core.SecurityContext;
-//
-//import static org.junit.Assert.assertEquals;
-//import static org.junit.Assert.fail;
-//import static org.mockito.Mockito.when;
-//
-//@Ignore
-//@RunWith(SpringRunner.class)
-//public class RedirectHttpRequestsHandlerTest {
-////    @Mock
-////    private IRequestInfo requestInfo;
-////    @Mock
-////    private ContainerRequestContext context;
-////    @Mock
-////    private SecurityContext securityContext;
-////    @Mock
-////    private javax.inject.Provider<IRequestInfo> requestInfoProvider;
-////    @InjectMocks
-////    private RedirectHttpRequestsHandler sut;
-////
-////    @Before
-////    public void setup() {
-////        when(requestInfoProvider.get()).thenReturn(requestInfo);
-////    }
-////
-////    @Test
-////    public void should_throwAppException302WithHttpsLocation_when_isNotACron_And_IsNotUsingHttps() {
-////        when(requestInfo.isCronRequest()).thenReturn(false);
-////        when(context.getSecurityContext()).thenReturn(securityContext);
-////        when(securityContext.isSecure()).thenReturn(false);
-////
-////        try {
-////            sut.filter(context);
-////            fail("should throw");
-////        } catch (AppException e) {
-////            assertEquals(302, e.getError().getCode());
-////        }
-////    }
-////
-////    @Test
-////    public void should_throwAppException302WithHttpsLocation_when_isNotATaskQueue_And_IsNotUsingHttps() {
-////        when(requestInfo.isTaskQueueRequest()).thenReturn(false);
-////        when(context.getSecurityContext()).thenReturn(securityContext);
-////        when(securityContext.isSecure()).thenReturn(false);
-////
-////        try {
-////            sut.filter(context);
-////            fail("should throw");
-////        } catch (AppException e) {
-////            assertEquals(302, e.getError().getCode());
-////        }
-////    }
-////
-////    @Test
-////    public void should_notThrowAppException302WithHttpsLocation_when_isACron() {
-////        when(requestInfo.isCronRequest()).thenReturn(true);
-////        when(context.getSecurityContext()).thenReturn(securityContext);
-////        when(securityContext.isSecure()).thenReturn(false);
-////
-////        sut.filter(context);
-////    }
-////
-////    @Test
-////    public void should_notThrowAppException302WithHttpsLocation_when_isAHttpsRequest() {
-////        when(requestInfo.isCronRequest()).thenReturn(false);
-////        when(context.getSecurityContext()).thenReturn(securityContext);
-////        when(securityContext.isSecure()).thenReturn(true);
-////
-////        sut.filter(context);
-////    }
-////
-////    @Test
-////    public void should_notThrowAppException302WithHttpsLocation_when_isATaskQueue() {
-////        when(requestInfo.isTaskQueueRequest()).thenReturn(true);
-////        when(context.getSecurityContext()).thenReturn(securityContext);
-////        when(securityContext.isSecure()).thenReturn(false);
-////
-////        sut.filter(context);
-////    }
-//}
-- 
GitLab