@Override
  public void doFilter(HttpRequest request, HttpResponse response, FilterChain chain) throws IOException{
    PluginRiskConsent riskConsent = PluginRiskConsent.valueOf(config.get(PLUGINS_RISK_CONSENT).orElse(NOT_ACCEPTED.name()));

    if (userSession.hasSession() && userSession.isLoggedIn()
      && userSession.isSystemAdministrator() && riskConsent == REQUIRED) {
      redirectTo(response, request.getContextPath() + PLUGINS_RISK_CONSENT_PATH);
    }

    chain.doFilter(request, response);
  }
@Test
  public void doFilter_givenNotLoggedInAndRequired_dontRedirect() throws Exception {
    PluginsRiskConsentFilter consentFilter = new PluginsRiskConsentFilter(configuration, userSession);

    when(userSession.hasSession()).thenReturn(true);
    when(userSession.isLoggedIn()).thenReturn(false);
    when(configuration.get(PLUGINS_RISK_CONSENT)).thenReturn(Optional.of(PluginRiskConsent.REQUIRED.name()));

    consentFilter.doFilter(request, response, chain);

    verify(response, times(0)).sendRedirect(Mockito.anyString());
  }