use of org.springframework.security.web.PortMapperImpl in project spring-security by spring-projects.
the class LoginUrlAuthenticationEntryPointTests method testGettersSetters.
@Test
public void testGettersSetters() {
LoginUrlAuthenticationEntryPoint ep = new LoginUrlAuthenticationEntryPoint("/hello");
ep.setPortMapper(new PortMapperImpl());
ep.setPortResolver(new MockPortResolver(8080, 8443));
assertThat(ep.getLoginFormUrl()).isEqualTo("/hello");
assertThat(ep.getPortMapper() != null).isTrue();
assertThat(ep.getPortResolver() != null).isTrue();
ep.setForceHttps(false);
assertThat(ep.isForceHttps()).isFalse();
ep.setForceHttps(true);
assertThat(ep.isForceHttps()).isTrue();
assertThat(ep.isUseForward()).isFalse();
ep.setUseForward(true);
assertThat(ep.isUseForward()).isTrue();
}
use of org.springframework.security.web.PortMapperImpl in project spring-security by spring-projects.
the class RetryWithHttpsEntryPointTests method testOperationWithNonStandardPort.
@Test
public void testOperationWithNonStandardPort() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/bigWebApp/hello/pathInfo.html");
request.setQueryString("open=true");
request.setScheme("http");
request.setServerName("www.example.com");
request.setServerPort(8888);
MockHttpServletResponse response = new MockHttpServletResponse();
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
map.put("8888", "9999");
portMapper.setPortMappings(map);
RetryWithHttpsEntryPoint ep = new RetryWithHttpsEntryPoint();
ep.setPortResolver(new MockPortResolver(8888, 9999));
ep.setPortMapper(portMapper);
ep.commence(request, response);
assertThat(response.getRedirectedUrl()).isEqualTo("https://www.example.com:9999/bigWebApp/hello/pathInfo.html?open=true");
}
use of org.springframework.security.web.PortMapperImpl in project spring-security by spring-projects.
the class RetryWithHttpsEntryPointTests method testNormalOperation.
@Test
public void testNormalOperation() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/bigWebApp/hello/pathInfo.html");
request.setQueryString("open=true");
request.setScheme("http");
request.setServerName("www.example.com");
request.setServerPort(80);
MockHttpServletResponse response = new MockHttpServletResponse();
RetryWithHttpsEntryPoint ep = new RetryWithHttpsEntryPoint();
ep.setPortMapper(new PortMapperImpl());
ep.setPortResolver(new MockPortResolver(80, 443));
ep.commence(request, response);
assertThat(response.getRedirectedUrl()).isEqualTo("https://www.example.com/bigWebApp/hello/pathInfo.html?open=true");
}
use of org.springframework.security.web.PortMapperImpl in project spring-security by spring-projects.
the class RetryWithHttpsEntryPointTests method testNormalOperationWithNullQueryString.
@Test
public void testNormalOperationWithNullQueryString() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/bigWebApp/hello");
request.setScheme("http");
request.setServerName("www.example.com");
request.setServerPort(80);
MockHttpServletResponse response = new MockHttpServletResponse();
RetryWithHttpsEntryPoint ep = new RetryWithHttpsEntryPoint();
ep.setPortMapper(new PortMapperImpl());
ep.setPortResolver(new MockPortResolver(80, 443));
ep.commence(request, response);
assertThat(response.getRedirectedUrl()).isEqualTo("https://www.example.com/bigWebApp/hello");
}
Aggregations