コード例 #1
0
 @Test
 public void testDefaultScheme() throws Exception {
   setRequestHeader("X-Forwarded-Scheme", "https");
   _rule.setHeader("X-Forwarded-Scheme");
   _rule.setHeaderValue("https");
   _rule.matchAndApply("/", _request, _response);
   assertEquals("https", _request.getScheme());
 }
コード例 #2
0
  @Test
  public void testHeaderValue() throws Exception {
    setRequestHeader("Front-End-Https", "on");
    _rule.setHeader("Front-End-Https");
    _rule.setHeaderValue("on");
    _rule.setScheme("https");
    _rule.matchAndApply("/", _request, _response);
    assertEquals("https", _request.getScheme());

    _request.setScheme(null);
    // header value doesn't match rule's value
    setRequestHeader("Front-End-Https", "off");
    _rule.matchAndApply("/", _request, _response);
    assertEquals(null, _request.getScheme());

    _request.setScheme(null);
    // header value can be any value
    setRequestHeader("Front-End-Https", "any");
    _rule.setHeaderValue(null);
    _rule.matchAndApply("/", _request, _response);
    assertEquals("https", _request.getScheme());
  }