// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
//     String getProxyCallbackUrl();
// 
//     void setContext(HttpServletRequest context);
// }


import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import org.springframework.security.core.Authentication;
import javax.servlet.http.HttpServletRequest;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
        when(authentication.getDetails()).thenReturn(null);

        authenticationProvider.authenticate(authentication);

        verify(authentication, times(1)).getDetails();
        verifyZeroInteractions(ticketValidator);
    }

    @Test
    public void authenticate_WithDetailsNotInstanceOfProxyCallbackAndServiceAuthenticationDetails_DoNothing() {
        TicketValidator ticketValidator = mock(TicketValidator.class);

        DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
                new DynamicProxyCallbackUrlCasAuthenticationProvider();
        authenticationProvider.setTicketValidator(ticketValidator);

        when(authentication.getDetails()).thenReturn((ServiceAuthenticationDetails) () -> "http://localhost");

        authenticationProvider.authenticate(authentication);

        verify(authentication, times(1)).getDetails();
        verifyZeroInteractions(ticketValidator);
    }

    @Test
    public void authenticate_WithNullTicketValidator_DoNothing() {
        DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
                new DynamicProxyCallbackUrlCasAuthenticationProvider();
        authenticationProvider.setTicketValidator(null);

// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetails.java
// public interface ProxyCallbackAndServiceAuthenticationDetails extends ServiceAuthenticationDetails {
//     String getProxyCallbackUrl();
// 
//     void setContext(HttpServletRequest context);
// }


// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/authentication/DynamicProxyCallbackUrlCasAuthenticationProviderTest.java
import com.kakawait.spring.security.cas.web.authentication.ProxyCallbackAndServiceAuthenticationDetails;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.jasig.cas.client.validation.TicketValidator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import org.springframework.security.core.Authentication;
import javax.servlet.http.HttpServletRequest;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

        when(authentication.getDetails()).thenReturn(null);

        authenticationProvider.authenticate(authentication);

        verify(authentication, times(1)).getDetails();
        verifyZeroInteractions(ticketValidator);
    }

    @Test
    public void authenticate_WithDetailsNotInstanceOfProxyCallbackAndServiceAuthenticationDetails_DoNothing() {
        TicketValidator ticketValidator = mock(TicketValidator.class);

        DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
                new DynamicProxyCallbackUrlCasAuthenticationProvider();
        authenticationProvider.setTicketValidator(ticketValidator);

        when(authentication.getDetails()).thenReturn((ServiceAuthenticationDetails) () -> "http://localhost");

        authenticationProvider.authenticate(authentication);

        verify(authentication, times(1)).getDetails();
        verifyZeroInteractions(ticketValidator);
    }

    @Test
    public void authenticate_WithNullTicketValidator_DoNothing() {
        DynamicProxyCallbackUrlCasAuthenticationProvider authenticationProvider =
                new DynamicProxyCallbackUrlCasAuthenticationProvider();
        authenticationProvider.setTicketValidator(null);

        when(authentication.getDetails()).thenReturn(new ProxyCallbackAndServiceAuthenticationDetails() {