예제 #1
0
  /** WICKET-4935 prevent another double slash */
  @Test
  public void test15() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("private/AdminPage")));

    assertEquals(
        "../signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u",
        r1.renderRelativeUrl(Url.parse("/signIn;jsessionid=16k3wqa9c4sgq1cnp7fisa20u")));
  }
예제 #2
0
  @Test
  public void renderFullUrlAsRelativeToBaseUrlWithoutSchemeHostnameAndPort() {
    Url baseUrl = Url.parse("/contextPath/filterPath/a/b/c/d");
    Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");

    UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
  }
예제 #3
0
  /** WICKET-4920 prevent double slash */
  @Test
  public void test14() {
    UrlRenderer r1 = new UrlRenderer(new MockWebRequest(new Url()));

    assertEquals(
        "./;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component",
        r1.renderRelativeUrl(
            Url.parse(
                "http://localhost:8080/;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component")));
  }
예제 #4
0
  @Test
  public void renderFullUrlAsRelativeToBaseUrlWithoutComposedFilterPath() {
    Url baseUrl = Url.parse("a/b/c/d"); // base url without context path and filter path
    Url encodedFullUrl = Url.parse("http://host:8080/context/path/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setContextPath("context/path");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
  }
예제 #5
0
  @Test
  public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPath() {
    // base url without context path and filter path
    // 'filterPath' here is a normal segment with the same value
    Url baseUrl = Url.parse("filterPath/a/b/c/d");

    // here 'filterPath' is the actual filter path and should be ignored
    Url encodedFullUrl = Url.parse("http://host:8080/filterPath/a/b;jsessionid=123456");

    MockWebRequest request = new MockWebRequest(baseUrl);
    request.setFilterPath("filterPath");
    UrlRenderer renderer = new UrlRenderer(request);
    String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);

    assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
  }