package org.apereo.cas.consent;

import org.apereo.cas.adaptors.ldap.LdapIntegrationTestsOperations;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.util.junit.EnabledIfPortOpen;

import com.unboundid.ldap.sdk.LDAPConnection;
import lombok.Cleanup;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.TestPropertySource;

/**
 * Unit tests for {@link LdapConsentRepository} class.
 *
 * @author Arnold Bergner
 * @since 5.3.0
 */
@TestPropertySource(properties = {
    "cas.consent.ldap.ldap-url=ldap://localhost:10389",
    "cas.consent.ldap.base-dn=ou=people,dc=example,dc=org",
    "cas.consent.ldap.search-filter=cn={0}",
    "cas.consent.ldap.consent-attribute-name=description",
    "cas.consent.ldap.bind-dn=cn=Directory Manager",
    "cas.consent.ldap.bind-credential=password"
})
@EnabledIfPortOpen(port = 10389)
@Slf4j
@Tag("Ldap")
public class LdapConsentRepositoryTests extends BaseLdapConsentRepositoryTests {
    private static final int LDAP_PORT = 10389;

    @Autowired
    private CasConfigurationProperties casProperties;

    @BeforeAll
    @SneakyThrows
    public static void bootstrap() {
        @Cleanup
        val localhost = new LDAPConnection("localhost", LDAP_PORT, "cn=Directory Manager", "password");
        val resource = new ClassPathResource("ldif/ldap-consent.ldif");
        LOGGER.debug("Populating LDAP entries from [{}]", resource);
        LdapIntegrationTestsOperations.populateEntries(localhost, resource.getInputStream(), "ou=people,dc=example,dc=org");
    }


    @Override
    @SneakyThrows
    public LDAPConnection getConnection() {
        val ldap = casProperties.getConsent().getLdap();
        return new LDAPConnection("localhost", LDAP_PORT,
            ldap.getBindDn(),
            ldap.getBindCredential());
    }
}

@@ -98,72 +98,8 @@
 ns;%0A
-import org.apereo.cas.configuration.CasConfigurationProperties;%0A
 impo
@@ -375,71 +375,8 @@
 ag;%0A
-import org.springframework.beans.factory.annotation.Autowired;%0A
 impo
@@ -1140,78 +1140,8 @@
 9;%0A%0A
-    @Autowired%0A    private CasConfigurationProperties casProperties;%0A%0A
     

fix build