use of org.apache.wicket.request.flow.RedirectToUrlException in project wicket by apache.
the class ISecuritySettingsTest method enforceMounts.
/**
* https://issues.apache.org/jira/browse/WICKET-3849
*/
@Test
public void enforceMounts() {
MockPageWithLink pageWithLink = new MockPageWithLink();
pageWithLink.add(new Link<Void>(MockPageWithLink.LINK_ID) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
throw new RedirectToUrlException("/wicket/bookmarkable/" + UnknownPage.class.getName());
}
});
tester.startPage(pageWithLink);
tester.assertRenderedPage(MockPageWithLink.class);
tester.clickLink(MockPageWithLink.LINK_ID);
tester.assertRenderedPage(UnknownPage.class);
tester.getApplication().getSecuritySettings().setEnforceMounts(true);
tester.startPage(pageWithLink);
tester.assertRenderedPage(MockPageWithLink.class);
tester.clickLink(MockPageWithLink.LINK_ID);
Assert.assertNull(tester.getLastRenderedPage());
/*
* Test that mounts are enforced when the root compound mapper does not directly contain the mounted mapper.
*/
tester.getApplication().setRootRequestMapper(new HttpsMapper(tester.getApplication().getRootRequestMapper(), new HttpsConfig()));
tester.startPage(pageWithLink);
tester.assertRenderedPage(MockPageWithLink.class);
tester.clickLink(MockPageWithLink.LINK_ID);
Assert.assertNull(tester.getLastRenderedPage());
}
Aggregations