use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class CryptoMapperTest method homePageWithNonEncryptedQueryParameters.
/**
* Verifies that the home page can be reached with non-encrypted query parameters.
* https://issues.apache.org/jira/browse/WICKET-4345
*
* Also, test that the URL for the home page with non-encrypted parameters is not encrypted, to avoid unnecessary redirects.
*/
@Test
public void homePageWithNonEncryptedQueryParameters() {
String expectedEncrypted = "?namedKey1=namedValue1";
PageParameters expectedParameters = new PageParameters();
expectedParameters.add("namedKey1", "namedValue1");
RenderPageRequestHandler renderPageRequestHandler = new RenderPageRequestHandler(new PageProvider(tester.getApplication().getHomePage(), expectedParameters));
Url url = mapper.mapHandler(renderPageRequestHandler);
assertEquals(expectedEncrypted, url.toString());
Request request = getRequest(url);
IRequestHandler requestHandler = mapper.mapRequest(request);
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertEquals(tester.getApplication().getHomePage(), handler.getPageClass());
StringValue queryParam = handler.getPageParameters().get("namedKey1");
assertEquals("namedValue1", queryParam.toOptionalString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class CryptoMapperTest method bookmarkablePageEncrypt.
/**
* Tests that URLs for bookmarkable pages are encrypted.
*/
@Test
public void bookmarkablePageEncrypt() {
IRequestHandler renderPage2BookmarkableHandler = new RenderPageRequestHandler(new PageProvider(Page2.class, new PageParameters()));
Url plainTextUrl = mapper.getDelegateMapper().mapHandler(renderPage2BookmarkableHandler);
assertEquals(PLAIN_BOOKMARKABLE_URL, plainTextUrl.toString());
Url encryptedUrl = mapper.mapHandler(renderPage2BookmarkableHandler);
assertEquals(ENCRYPTED_BOOKMARKABLE_URL, encryptedUrl.toString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class CryptoMapperTest method markedEncryptedUrlDecrypt.
@Test
public void markedEncryptedUrlDecrypt() {
mapper.setMarkEncryptedUrls(true);
Request request = getRequest(Url.parse("crypt." + ENCRYPTED_BOOKMARKABLE_URL));
IRequestHandler requestHandler = mapper.mapRequest(request);
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertTrue(requestHandler instanceof RenderPageRequestHandler);
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertEquals(Page2.class, handler.getPageClass());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class CryptoMapperTest method homePage.
/**
* Tests that the home page is requestable.
*/
@Test
public void homePage() {
IRequestHandler requestHandler = mapper.mapRequest(getRequest(Url.parse("")));
assertNotNull("Unable to map request for home page", requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertSame(tester.getApplication().getHomePage(), handler.getPageClass());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class CryptoMapperTest method expiredMarkedEncryptedUrlThrowsPageExpiredException.
@Test(expected = PageExpiredException.class)
public void expiredMarkedEncryptedUrlThrowsPageExpiredException() {
mapper.setMarkEncryptedUrls(true);
Url encryptedUrl = mapper.mapHandler(new RenderPageRequestHandler(new PageProvider(Page2.class)));
assertTrue(encryptedUrl.getSegments().get(0).startsWith("crypt."));
encryptedUrl.getSegments().remove(0);
encryptedUrl.getSegments().add(0, "crypt.no decryptable");
mapper.mapRequest(getRequest(encryptedUrl));
}
Aggregations