use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode3.
/**
*/
@Test
public void encode3() {
PageParameters parameters = new PageParameters();
parameters.set(0, "i1");
parameters.set(1, "i2");
parameters.set("a", "b", INamedParameters.Type.QUERY_STRING);
parameters.set("b", "c", INamedParameters.Type.QUERY_STRING);
PageProvider provider = new PageProvider(MockPage.class, parameters);
provider.setPageSource(context);
IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class CryptoMapperTest method pageParameters.
/**
* Tests that named and indexed parameters are properly (en|de)crypted
*/
@Test
public void pageParameters() {
String expectedEncrypted = "L7ExSNbPC4sb6TPJDblCAopL53TWmZP5y7BQEaJSJAC05HXod5M5U7gT2yNT0lK5L6L09ZAOoZkGyUhseyPrC4S5tqUUrV6zipc4_Ni877FDOOoE5C_Cd7YCyK1xSScpVhno6LeBz2wiu5oWyf7hB1RKcv6zkhEBmbx8vU7K7-e4xe1_LO8Y3fhEjMSQyU9BVh7Uz4HKzkR2OxFo5LaDzQ/L7E59/yPr6a/5L6ae/OxF2c";
PageParameters expectedParameters = new PageParameters();
expectedParameters.add("namedKey1", "namedValue1");
expectedParameters.add("namedKey2", "namedValue2");
expectedParameters.set(0, "indexedValue1");
expectedParameters.set(1, "indexedValue2");
RenderPageRequestHandler renderPageRequestHandler = new RenderPageRequestHandler(new PageProvider(Page2.class, 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(Page2.class, handler.getPageClass());
PageParameters actualParameters = handler.getPageParameters();
assertEquals(expectedParameters, actualParameters);
}
use of org.apache.wicket.core.request.handler.PageProvider 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.PageProvider 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.PageProvider 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