Search in sources :

Example 1 with RedirectToUrlException

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());
}
Also used : HttpsMapper(org.apache.wicket.protocol.https.HttpsMapper) RedirectToUrlException(org.apache.wicket.request.flow.RedirectToUrlException) HttpsConfig(org.apache.wicket.protocol.https.HttpsConfig) MockPageWithLink(org.apache.wicket.MockPageWithLink) Test(org.junit.Test)

Aggregations

MockPageWithLink (org.apache.wicket.MockPageWithLink)1 HttpsConfig (org.apache.wicket.protocol.https.HttpsConfig)1 HttpsMapper (org.apache.wicket.protocol.https.HttpsMapper)1 RedirectToUrlException (org.apache.wicket.request.flow.RedirectToUrlException)1 Test (org.junit.Test)1