Search in sources :

Example 1 with HttpsConfig

use of org.apache.wicket.protocol.https.HttpsConfig 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)

Example 2 with HttpsConfig

use of org.apache.wicket.protocol.https.HttpsConfig in project wicket by apache.

the class JSR356Application method init.

@Override
public void init() {
    super.init();
    scheduledExecutorService = Executors.newScheduledThreadPool(1);
    setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
    mountPage("/behavior", WebSocketBehaviorDemoPage.class);
    mountPage("/resource", WebSocketResourceDemoPage.class);
    getSharedResources().add(ChartWebSocketResource.NAME, new ChartWebSocketResource());
    if (System.getenv("OPENSHIFT_APP_NAME") != null) {
        // OpenShift uses special proxy for WebSocket connections
        // https://blog.openshift.com/paas-websockets/
        final WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(this);
        webSocketSettings.setPort(8000);
        webSocketSettings.setSecurePort(8443);
    }
}
Also used : HttpsMapper(org.apache.wicket.protocol.https.HttpsMapper) WebSocketSettings(org.apache.wicket.protocol.ws.WebSocketSettings) HttpsConfig(org.apache.wicket.protocol.https.HttpsConfig) ChartWebSocketResource(org.apache.wicket.examples.websocket.charts.ChartWebSocketResource)

Aggregations

HttpsConfig (org.apache.wicket.protocol.https.HttpsConfig)2 HttpsMapper (org.apache.wicket.protocol.https.HttpsMapper)2 MockPageWithLink (org.apache.wicket.MockPageWithLink)1 ChartWebSocketResource (org.apache.wicket.examples.websocket.charts.ChartWebSocketResource)1 WebSocketSettings (org.apache.wicket.protocol.ws.WebSocketSettings)1 RedirectToUrlException (org.apache.wicket.request.flow.RedirectToUrlException)1 Test (org.junit.Test)1