Ejemplo n.º 1
0
    @Test
    public void shouldNotHaveUserHeader() {
      when(request.getRequestURI()).thenReturn(URIFAIL);

      FilterDirector result = handler.handleRequest(request, response);

      Set<String> values =
          result
              .requestHeaderManager()
              .headersToAdd()
              .get(HeaderName.wrap(PowerApiHeader.USER.toString()));
      assertTrue(
          "Should not have " + PowerApiHeader.USER.toString() + " header set.",
          values == null || values.isEmpty());
    }
Ejemplo n.º 2
0
    @Test
    public void shouldSetTheUserHeaderToThe2ndRegexResult() {
      when(request.getRequestURI()).thenReturn(URI2);

      FilterDirector result = handler.handleRequest(request, response);

      Set<String> values =
          result
              .requestHeaderManager()
              .headersToAdd()
              .get(HeaderName.wrap(PowerApiHeader.USER.toString()));
      assertFalse(
          "Should have " + PowerApiHeader.USER.toString() + " header set.",
          values == null || values.isEmpty());

      String userName = values.iterator().next();

      assertEquals("Should find user name in header", USER2 + QUALITY_VALUE, userName);
    }