// 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;
            @Override
            public String getProxyCallbackUrl() {
                return "http://localhost/cas/callback";
            }

            @Override
            public void setContext(HttpServletRequest context) {
                // do nothing
            }
        });

        authenticationProvider.authenticate(authentication);

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

    @Test
    public void authenticate_EveryRequirements_TicketValidatorProxyCallbackUrlUpdated() {
        Cas20ServiceTicketValidator ticketValidator = mock(Cas20ServiceTicketValidator.class);

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

        when(authentication.getDetails()).thenReturn(new ProxyCallbackAndServiceAuthenticationDetails() {
            private static final long serialVersionUID = -541835714542292545L;

            @Override
            public String getServiceUrl() {
// 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;

            @Override
            public String getProxyCallbackUrl() {
                return "http://localhost/cas/callback";
            }

            @Override
            public void setContext(HttpServletRequest context) {
                // do nothing
            }
        });

        authenticationProvider.authenticate(authentication);

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

    @Test
    public void authenticate_EveryRequirements_TicketValidatorProxyCallbackUrlUpdated() {
        Cas20ServiceTicketValidator ticketValidator = mock(Cas20ServiceTicketValidator.class);

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

        when(authentication.getDetails()).thenReturn(new ProxyCallbackAndServiceAuthenticationDetails() {
            private static final long serialVersionUID = -541835714542292545L;

            @Override
            public String getServiceUrl() {
                return "http://localhost";