use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method resourceReferenceWithModifiedSegments.
/**
* Relative ResourceReferences, WICKET-3514
*/
@Test
public void resourceReferenceWithModifiedSegments() {
PackageResourceReference resource = new PackageResourceReference(getClass(), "crypt/crypt.txt");
Url url = mapper.mapHandler(new ResourceReferenceRequestHandler(resource));
url.getSegments().remove(url.getSegments().size() - 1);
url.getSegments().add("modified-crypt.txt");
Request request = getRequest(url);
IRequestHandler requestHandler = mapper.mapRequest(request);
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(ResourceReferenceRequestHandler.class));
ResourceReferenceRequestHandler handler = (ResourceReferenceRequestHandler) requestHandler;
assertEquals(getClass(), handler.getResourceReference().getScope());
assertEquals("crypt/modified-crypt.txt", handler.getResourceReference().getName());
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method homePageForceEncryptionOfRequestListener.
/**
* Tests that we do not allow unencrypted URLs to IRequestListeners on the home page, like: ?0-0.ILinkListener-link
*/
@Test
public void homePageForceEncryptionOfRequestListener() {
PageAndComponentProvider provider = new PageAndComponentProvider(tester.getApplication().getHomePage(), "link");
IRequestHandler requestHandler = new BookmarkableListenerRequestHandler(provider);
Url plainUrl = mapper.getDelegateMapper().mapHandler(requestHandler);
assertTrue("Plain URL for home page has segments: " + plainUrl.toString(), plainUrl.getSegments().isEmpty());
assertNull(mapper.mapRequest(getRequest(plainUrl)));
}
use of org.apache.wicket.request.IRequestHandler in project wicket by apache.
the class CryptoMapperTest method pageInstanceDecrypt.
/**
* Make sure that encrypted page instance URLs are decrypted and the correct handler resolved.
*/
@Test
public void pageInstanceDecrypt() {
IRequestHandler requestHandler = mapper.mapRequest(getRequest(Url.parse(ENCRYPTED_PAGE_INSTANCE_URL)));
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
assertEquals(5, handler.getPageId().intValue());
}
use of org.apache.wicket.request.IRequestHandler 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.request.IRequestHandler 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());
}
Aggregations