use of org.apache.wicket.request.Request 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.request.Request in project wicket by apache.
the class CryptoMapperTest method additionalParameters.
/**
* Additional parameters, WICKET-4923
*/
@Test
public void additionalParameters() {
MockPage page = new MockPage();
IRequestableComponent c = page.get("foo:bar");
PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
IRequestHandler handler = new ListenerRequestHandler(provider);
Url url = mapper.mapHandler(handler);
url.addQueryParameter("q", "foo");
Request request = getRequest(url);
IRequestHandler requestHandler = mapper.mapRequest(request);
assertThat(requestHandler, instanceOf(RequestSettingRequestHandler.class));
assertEquals("foo", ((RequestSettingRequestHandler) requestHandler).getRequest().getUrl().getQueryParameterValue("q").toString());
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class CryptoMapperTest method bookmarkablePageDecrypt2.
/**
* https://issues.apache.org/jira/browse/WICKET-6131
*
* Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper.
* Extra segments should be ignored.
*/
@Test
public void bookmarkablePageDecrypt2() {
String encryptedExtraSegments = "/i87b7/i87b7";
Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_URL + encryptedExtraSegments));
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.request.Request in project wicket by apache.
the class MountedMapperTest method exactMountGetsBetterScore_ThanParameterOne.
@Test
public void exactMountGetsBetterScore_ThanParameterOne() throws Exception {
final Url url = Url.parse("all/sindex");
final MountedMapper exactMount = new MountedMapper("/all/sindex", MockPage.class);
final MountedMapper requiredParam = new MountedMapper("/all/${exp}", MockPage.class);
Request request = getRequest(url);
final int exactCompatScore = exactMount.getCompatibilityScore(request);
final int requiredParamScore = requiredParam.getCompatibilityScore(request);
assertTrue("exactCompatScore should have greater compatibility score than required one" + " got exact = " + exactCompatScore + " and required= " + requiredParamScore, exactCompatScore > requiredParamScore);
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class MountedMapperTest method optionalParameterGetsLowerScore_ThanExactOne.
/**
* WICKET-5056
*/
@Test
public void optionalParameterGetsLowerScore_ThanExactOne() throws Exception {
final Url url = Url.parse("all/sindex");
final MountedMapper exactMount = new MountedMapper("/all/sindex", MockPage.class);
final MountedMapper optionalParameter = new MountedMapper("/all/#{exp}", MockPage.class);
Request request = getRequest(url);
final int exactCompatScore = exactMount.getCompatibilityScore(request);
final int optCompatScore = optionalParameter.getCompatibilityScore(request);
assertTrue("exactCompatScore should have greater compatibility score than optional one" + " got exact = " + exactCompatScore + " and optional = " + optCompatScore, exactCompatScore > optCompatScore);
}
Aggregations