use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.
the class RequestSecurityManagerImplTest method link_security_when_security_is_disabled.
/**
* https://issues.apache.org/jira/browse/TAP5-1511
*/
@Test(dataProvider = "security_disabled_data")
public void link_security_when_security_is_disabled(boolean secureRequest, LinkSecurity expectedLinkSecurity) {
Request request = mockRequest();
Response response = mockResponse();
MetaDataLocator locator = mockMetaDataLocator();
train_isSecure(request, secureRequest);
replay();
RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, null, locator, false);
assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity);
verify();
}
use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.
the class RequestSecurityManagerImplTest method check_redirect_needed.
@Test
public void check_redirect_needed() throws Exception {
Request request = mockRequest();
Response response = mockResponse();
MetaDataLocator locator = mockMetaDataLocator();
Link link = mockLink();
ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
train_isSecure(request, false);
train_isSecure(locator, PAGE_NAME, true);
PageRenderRequestParameters parameters = new PageRenderRequestParameters(PAGE_NAME, new EmptyEventContext(), false);
train_createPageRenderLink(encoder, parameters, link);
response.sendRedirect(link);
replay();
RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
assertTrue(manager.checkForInsecurePageRenderRequest(parameters));
verify();
}
use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.
the class RequestImplTest method isSessionInvalidated_is_true_when_session_is_invalid.
@Test
public void isSessionInvalidated_is_true_when_session_is_invalid() {
HttpServletRequest sr = mockHttpServletRequest();
Session session = mockSession();
TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
expect(sf.getSession(false)).andReturn(session);
expect(session.isInvalidated()).andReturn(true);
replay();
Request request = new RequestImpl(sr, CHARSET, sf);
assertTrue(request.isSessionInvalidated());
verify();
}
use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.
the class RequestImplTest method isSessionInvalidated_is_false_when_no_session_at_all.
@Test
public void isSessionInvalidated_is_false_when_no_session_at_all() {
HttpServletRequest sr = mockHttpServletRequest();
TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
expect(sf.getSession(false)).andReturn(null);
replay();
Request request = new RequestImpl(sr, CHARSET, sf);
assertFalse(request.isSessionInvalidated());
verify();
}
use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.
the class RequestImplTest method get_path_for_websphere_with_nonempty_path.
/**
* TAPESTRY-1713
*/
@Test
public void get_path_for_websphere_with_nonempty_path() {
HttpServletRequest sr = mockHttpServletRequest();
train_getPathInfo(sr, "");
replay();
Request request = new RequestImpl(sr, CHARSET, null);
assertEquals(request.getPath(), "/");
verify();
}
Aggregations