@Test
public void testTrustedUserFilter() throws Exception
{

    // Override configuration.
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.SECURITY_ENABLED_SPEL_EXPRESSION.getKey(), "false");
    modifyPropertySourceInEnvironment(overrideMap);
    try
    {
        // Invalidate user session if exists.
        invalidateApplicationUser(null);
        trustedUserAuthenticationFilter.init(new MockFilterConfig());
        trustedUserAuthenticationFilter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
        validateTrustedApplicationUser();
        // retry with same request.
        trustedUserAuthenticationFilter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
        validateTrustedApplicationUser();
    }
    finally
    {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}