request.setSecure(this.secure);
@Test public void isSecureWithHttpSchemeAndSecureFlagIsFalse() { assertFalse(request.isSecure()); request.setScheme("http"); request.setSecure(false); assertFalse(request.isSecure()); }
@Test public void isSecureWithHttpSchemeAndSecureFlagIsTrue() { assertFalse(request.isSecure()); request.setScheme("http"); request.setSecure(true); assertTrue(request.isSecure()); }
@Test public void isSecureWithHttpsSchemeAndSecureFlagIsFalse() { assertFalse(request.isSecure()); request.setScheme("https"); request.setSecure(false); assertTrue(request.isSecure()); }
@Test public void isSecureWithHttpsSchemeAndSecureFlagIsTrue() { assertFalse(request.isSecure()); request.setScheme("https"); request.setSecure(true); assertTrue(request.isSecure()); }
@Test public void doFilterCookieSecuritySettings() throws Exception { this.request.setSecure(true); doFilter(new DoInFilter() { @Override public void doFilter(HttpServletRequest wrappedRequest) { wrappedRequest.getSession(); } }); Cookie session = getSessionCookie(); assertThat(session.isHttpOnly()).describedAs("Session Cookie should be HttpOnly") .isTrue(); assertThat(session.getSecure()) .describedAs("Session Cookie should be marked as Secure").isTrue(); }
@Test public void writeCookieSecureSecureRequest() { this.request.setSecure(true); this.serializer.setUseSecureCookie(true); this.serializer.writeCookieValue(cookieValue(this.sessionId)); assertThat(getCookie().getSecure()).isTrue(); }
@Test public void writeCookieInsecureSecureRequest() { this.request.setSecure(true); this.serializer.setUseSecureCookie(false); this.serializer.writeCookieValue(cookieValue(this.sessionId)); assertThat(getCookie().getSecure()).isFalse(); }
request.setSecure(secure); MockHttpServletResponse response = new MockHttpServletResponse();
request.setSecure(secure); MockHttpServletResponse response = new MockHttpServletResponse();
public void testConstructServiceUrlWithTrailingSlash() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", "service", "ticket", false); assertEquals(CONST_MY_URL, constructedUrl); }
public void testConstructURlWithMultipleHostsAndPorts() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.addHeader("Host", "www.myserver.com"); request.setScheme("https"); request.setSecure(true); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "http://www.amazon.com https://www.bestbuy.com https://www.myserver.com", "service", "ticket", false); assertEquals(CONST_MY_URL, constructedUrl); }
public void testConstructServiceUrlWithServerNameContainingPathAndSchema() { final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "https://www.my.server.com/app", Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName(), false); assertEquals("https://www.my.server.com/app/hello/hithere/", constructedUrl); }
private void constructUrlNonStandardPortAndNoPortInConfigTest(final String serverNameList) { final String CONST_MY_URL = "https://www.myserver.com:555/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.addHeader("Host", "www.myserver.com"); request.setScheme("https"); request.setSecure(true); request.setServerPort(555); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, serverNameList, "service", "ticket", false); assertEquals(CONST_MY_URL, constructedUrl); }
public void testConstructServiceUrlWithNoServiceParametersPassed() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("TARGET=Test1&service=Test2&custom=custom"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", Protocol.SAML11.getArtifactParameterName(), true); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl); }
public void testConstructServiceUrlWithEncodedParams2Saml() { final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("TARGET%3Dthis%26SAMLart%3Dthat%26custom%3Dcustom%20value%20here%26another%3Dgood"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), true); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom+value+here&another=good", constructedUrl); }
public void testConstructServiceUrlWithParamsCas() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("service=this&ticket=that&custom=custom"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName(), false); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl); }
public void testConstructServiceUrlWithParamsCasAndServerNameWithSchema() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("service=this&ticket=that&custom=custom"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "https://www.myserver.com", Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName(), false); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl); }
public void testConstructServiceUrlWithoutEncodedParamsSamlAndNoEncoding() { final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("TARGET=this&SAMLart=that&custom=custom value here&another=good"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), false); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom value here&another=good", constructedUrl); }
public void testConstructServiceUrlWithEncodedParamsSamlAndNoEncoding() { final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/"; final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/"); request.setScheme("https"); request.setSecure(true); request.setQueryString("TARGET=this&SAMLart=that&custom=custom+value+here&another=good"); final MockHttpServletResponse response = new MockHttpServletResponse(); final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com", Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), true); assertEquals("https://www.myserver.com/hello/hithere/?custom=custom+value+here&another=good", constructedUrl); }