Skip to content
Snippets Groups Projects
Commit 40398c2d authored by Jagan Gottimukkula's avatar Jagan Gottimukkula
Browse files

Added auth for /reindex and fixed testcases

parent 395ad2b2
No related branches found
No related tags found
1 merge request!6Trusted ibm
Showing
with 73 additions and 282 deletions
......@@ -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>
......
......@@ -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"
......@@ -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");
}
......
......@@ -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.");
// }
......
......@@ -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))
......
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");
}
}
......@@ -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());
......
......@@ -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
......
......@@ -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 {
......
......@@ -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());
}
......
......@@ -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());
}
......
......@@ -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<>();
......
......@@ -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>
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
......
//// 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
// }
//}
//// 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);
//// }
//}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment