Search in sources :

Example 41 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapperTest method bookmarkablePageDecryptMultipleCryptoMapper.

/**
 * Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper when there is more than
 * one cryptomapper installed.
 */
@Test
public void bookmarkablePageDecryptMultipleCryptoMapper() {
    Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_URL));
    IRequestHandler requestHandler = new CryptoMapper(mapper, tester.getApplication()).mapRequest(request);
    assertNotNull(requestHandler);
    requestHandler = unwrapRequestHandlerDelegate(requestHandler);
    assertThat(requestHandler, instanceOf(RenderPageRequestHandler.class));
    RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
    assertEquals(Page2.class, handler.getPageClass());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Request(org.apache.wicket.request.Request) Test(org.junit.Test)

Example 42 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapperTest method bookmarkablePageDecrypt.

/**
 * Tests that encrypted URLs for bookmarkable pages are decrypted and passed to the wrapped mapper.
 */
@Test
public void bookmarkablePageDecrypt() {
    Request request = getRequest(Url.parse(ENCRYPTED_BOOKMARKABLE_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());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) Request(org.apache.wicket.request.Request) Test(org.junit.Test)

Example 43 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapperTest method resourceReference.

/**
 * Relative ResourceReferences, WICKET-3514
 */
@Test
public void resourceReference() {
    PackageResourceReference resource = new PackageResourceReference(getClass(), "crypt/crypt.txt");
    Url url = mapper.mapHandler(new ResourceReferenceRequestHandler(resource));
    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/crypt.txt", handler.getResourceReference().getName());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 44 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapperTest method decryptFailed.

/**
 * Test a failed decrypt, WICKET-4139
 */
@Test
public void decryptFailed() {
    String encrypted = "style.css";
    Request request = getRequest(Url.parse(encrypted));
    assertNull(mapper.mapRequest(request));
}
Also used : Request(org.apache.wicket.request.Request) Test(org.junit.Test)

Example 45 with Request

use of org.apache.wicket.request.Request in project wicket by apache.

the class CryptoMapperTest method resourceReferenceWithLessSegments.

/**
 * Relative ResourceReferences, WICKET-3514
 */
@Test
public void resourceReferenceWithLessSegments() {
    PackageResourceReference resource = new PackageResourceReference(getClass(), "crypt/crypt.txt");
    Url url = mapper.mapHandler(new ResourceReferenceRequestHandler(resource));
    url.getSegments().remove(url.getSegments().size() - 1);
    url.getSegments().remove(url.getSegments().size() - 1);
    url.getSegments().add("less-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("less-crypt.txt", handler.getResourceReference().getName());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

Request (org.apache.wicket.request.Request)61 Test (org.junit.Test)28 IRequestHandler (org.apache.wicket.request.IRequestHandler)26 Url (org.apache.wicket.request.Url)23 WebRequest (org.apache.wicket.request.http.WebRequest)9 Response (org.apache.wicket.request.Response)8 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)8 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)6 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)5 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)5 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)5 MockApplication (org.apache.wicket.mock.MockApplication)4 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)4 Session (org.apache.wicket.Session)3 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)3 Attributes (org.apache.wicket.request.resource.IResource.Attributes)3 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)3 UrlAttributes (org.apache.wicket.request.resource.ResourceReference.UrlAttributes)3