// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
// 
//     private final boolean dynamicServiceResolution;
// 
//     public LaxServiceProperties() {
//         this(true);
//     }
// 
//     public LaxServiceProperties(boolean dynamicServiceResolution) {
//         this.dynamicServiceResolution = dynamicServiceResolution;
//     }
// 
//     @Override
//     public void afterPropertiesSet() {
//         if (!dynamicServiceResolution) {
//             try {
//                 super.afterPropertiesSet();
//             } catch (RuntimeException e) {
//                 throw e;
//             } catch (Exception e) {
//                 // Old version of spring security throw Exception for afterPropertiesSet()
//                 throw new RuntimeException(e);
//             }
//         } else {
//             Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
//             Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
//         }
//     }
// 
//     public boolean isDynamicServiceResolution() {
//         return dynamicServiceResolution;
//     }
// }


import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import java.net.URI;
import javax.servlet.http.HttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
package com.kakawait.spring.security.cas.web.authentication;





/**
 * @author Thibaud Leprêtre
 */
public class ProxyCallbackAndServiceAuthenticationDetailsSourceTest {

    @Test
    public void buildDetails_WithUri_DefaultProxyCallbackAndServiceAuthenticationDetails() {
        ServiceProperties serviceProperties = new LaxServiceProperties();
        ProxyCallbackAndServiceAuthenticationDetailsSource authenticationDetailsSource =
                new ProxyCallbackAndServiceAuthenticationDetailsSource(serviceProperties, URI.create("/cas/callback"));

        MockHttpServletRequest context = new MockHttpServletRequest();

        ServiceAuthenticationDetails serviceAuthenticationDetails = authenticationDetailsSource.buildDetails(context);
        assertThat(serviceAuthenticationDetails)
                .isInstanceOf(DefaultProxyCallbackAndServiceAuthenticationDetails.class);
        assertThat(serviceAuthenticationDetails.getServiceUrl()).isEqualTo("http://localhost");
        assertThat(((ProxyCallbackAndServiceAuthenticationDetails) serviceAuthenticationDetails).getProxyCallbackUrl())
                .isEqualTo("http://localhost/cas/callback");
    }

    @Test
    public void buildDetails_WithCustomProxyCallbackAndServiceAuthenticationDetails_DelegateTo() {
// Path: spring-security-cas-extension/src/main/java/com/kakawait/spring/security/cas/LaxServiceProperties.java
// public class LaxServiceProperties extends ServiceProperties {
// 
//     private final boolean dynamicServiceResolution;
// 
//     public LaxServiceProperties() {
//         this(true);
//     }
// 
//     public LaxServiceProperties(boolean dynamicServiceResolution) {
//         this.dynamicServiceResolution = dynamicServiceResolution;
//     }
// 
//     @Override
//     public void afterPropertiesSet() {
//         if (!dynamicServiceResolution) {
//             try {
//                 super.afterPropertiesSet();
//             } catch (RuntimeException e) {
//                 throw e;
//             } catch (Exception e) {
//                 // Old version of spring security throw Exception for afterPropertiesSet()
//                 throw new RuntimeException(e);
//             }
//         } else {
//             Assert.hasLength(getArtifactParameter(), "artifactParameter cannot be empty.");
//             Assert.hasLength(getServiceParameter(), "serviceParameter cannot be empty.");
//         }
//     }
// 
//     public boolean isDynamicServiceResolution() {
//         return dynamicServiceResolution;
//     }
// }


// Path: spring-security-cas-extension/src/test/java/com/kakawait/spring/security/cas/web/authentication/ProxyCallbackAndServiceAuthenticationDetailsSourceTest.java
import com.kakawait.spring.security.cas.LaxServiceProperties;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;
import java.net.URI;
import javax.servlet.http.HttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;

package com.kakawait.spring.security.cas.web.authentication;





/**
 * @author Thibaud Leprêtre
 */
public class ProxyCallbackAndServiceAuthenticationDetailsSourceTest {

    @Test
    public void buildDetails_WithUri_DefaultProxyCallbackAndServiceAuthenticationDetails() {
        ServiceProperties serviceProperties = new LaxServiceProperties();
        ProxyCallbackAndServiceAuthenticationDetailsSource authenticationDetailsSource =
                new ProxyCallbackAndServiceAuthenticationDetailsSource(serviceProperties, URI.create("/cas/callback"));

        MockHttpServletRequest context = new MockHttpServletRequest();

        ServiceAuthenticationDetails serviceAuthenticationDetails = authenticationDetailsSource.buildDetails(context);
        assertThat(serviceAuthenticationDetails)
                .isInstanceOf(DefaultProxyCallbackAndServiceAuthenticationDetails.class);
        assertThat(serviceAuthenticationDetails.getServiceUrl()).isEqualTo("http://localhost");
        assertThat(((ProxyCallbackAndServiceAuthenticationDetails) serviceAuthenticationDetails).getProxyCallbackUrl())
                .isEqualTo("http://localhost/cas/callback");
    }

    @Test
    public void buildDetails_WithCustomProxyCallbackAndServiceAuthenticationDetails_DelegateTo() {
        ServiceProperties serviceProperties = new LaxServiceProperties();