content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Mon Mar 18 01:30:36 GMT 2024
   */
  
  package org.jsecurity.web;
  
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import org.junit.jupiter.api.Timeout;
  import java.util.concurrent.TimeUnit;
  import static org.evosuite.shaded.org.mockito.Mockito.*;
  import static org.evosuite.runtime.EvoAssertions.*;
  import javax.servlet.ServletRequest;
  import javax.servlet.ServletResponse;
  import javax.servlet.ServletResponseWrapper;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.evosuite.runtime.ViolatedAssumptionAnswer;
  import org.jsecurity.session.Session;
  import org.jsecurity.subject.Subject;
  import org.jsecurity.web.DefaultWebSecurityManager;
  import org.junit.runner.RunWith;
  
  @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) 
  public class DefaultWebSecurityManager_Original_ESTest extends DefaultWebSecurityManager_Original_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionIdCookieSecure() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.setSessionIdCookieSecure(true);
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionIdCookiePath() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.setSessionIdCookiePath("public static final String constants in the ");
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionIdCookieName() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.setSessionIdCookieName("+dE3 73");
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsAuthenticated() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        boolean authenticated = defaultWebSecurityManager.isAuthenticated((Session) null);
        assertFalse(authenticated);
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetPrincipals() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.getPrincipals((Session) null);
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testNewSessionManagerInstance() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.newSessionManagerInstance();
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsHttpSessionModeReturningFalse() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.isHttpSessionMode();
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testIsHttpSessionModeReturningTrue() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        boolean httpSessionMode = defaultWebSecurityManager.isHttpSessionMode();
        assertTrue(httpSessionMode);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionModeThrowsIllegalArgumentException() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        // Undeclared exception!
        try { 
          defaultWebSecurityManager.setSessionMode("org.jsecurity.web.DefaultWebSecurityManager_AUTHENTICATED_SESSION_KEY");
          fail("Expecting exception: IllegalArgumentException");
        
        } catch(IllegalArgumentException e) {
           //
           // Invalid sessionMode [org.jsecurity.web.DefaultWebSecurityManager_AUTHENTICATED_SESSION_KEY].  Allowed values are public static final String constants in the org.jsecurity.web.DefaultWebSecurityManager class: 'http' or 'jsecurity', with 'http' being the default.
           //
           verifyException("org.jsecurity.web.DefaultWebSecurityManager", e);
        }
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionMode() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("http");
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionModeWithNull() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        // Undeclared exception!
        try { 
          defaultWebSecurityManager.setSessionMode((String) null);
          fail("Expecting exception: IllegalArgumentException");
        
        } catch(IllegalArgumentException e) {
           //
           // Invalid sessionMode [null].  Allowed values are public static final String constants in the org.jsecurity.web.DefaultWebSecurityManager class: 'http' or 'jsecurity', with 'http' being the default.
           //
           verifyException("org.jsecurity.web.DefaultWebSecurityManager", e);
        }
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionIdCookieMaxAge() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setSessionMode("jsecurity");
        defaultWebSecurityManager.setSessionIdCookieMaxAge(0);
        assertEquals("jsecurity", defaultWebSecurityManager.getSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetRememberMeCookiePath() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setRememberMeCookiePath("7#'0`bMhbZd");
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetSessionIdCookieSecureThrowsIllegalStateException() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        // Undeclared exception!
        try { 
          defaultWebSecurityManager.setSessionIdCookieSecure(true);
          fail("Expecting exception: IllegalStateException");
        
        } catch(IllegalStateException e) {
           //
           // The convenience passthrough methods for setting session id cookie attributes are only available when the underlying SessionManager implementation is org.jsecurity.web.session.DefaultWebSessionManager, which is enabled by default when the sessionMode is 'jsecurity'.
           //
           verifyException("org.jsecurity.web.DefaultWebSecurityManager", e);
        }
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetSessionMode() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        String sessionMode = defaultWebSecurityManager.getSessionMode();
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
        assertEquals("http", sessionMode);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreateSubjectTakingNoArgumentsThrowsIllegalStateException() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        // Undeclared exception!
        try { 
          defaultWebSecurityManager.createSubject();
          fail("Expecting exception: IllegalStateException");
        
        } catch(IllegalStateException e) {
           //
           // No ServletRequest found in ThreadContext. Make sure WebUtils.bind() is being called. (typically called by JSecurityFilter)  This could also happen when running integration tests that don't properly call WebUtils.bind().
           //
           verifyException("org.jsecurity.web.WebUtils", e);
        }
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreateSubjectTaking3Arguments() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        ServletRequest arg1 = mock(ServletRequest.class, new ViolatedAssumptionAnswer());
        doReturn("org.jsecurity.web.DefaultWebSecurityManager_PRINCIPALS_SESSION_KEY").when(arg1).getRemoteHost();
        ServletResponse arg0 = mock(ServletResponse.class, new ViolatedAssumptionAnswer());
        ServletResponseWrapper arg2 = new ServletResponseWrapper(arg0);
        Subject createSubject = defaultWebSecurityManager.createSubject((Session) null, arg1, (ServletResponse) arg2);
        assertFalse(createSubject.isAuthenticated());
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetRememberMeCookieMaxAge() throws Throwable  {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        Integer arg0 = Integer.getInteger("org.jsecurity.web.DefaultWebSecurityManager_AUTHENTICATED_SESSION_KEY", (-1787));
        defaultWebSecurityManager.setRememberMeCookieMaxAge(arg0);
        assertTrue(defaultWebSecurityManager.isHttpSessionMode());
    }
  }
  