Search in sources :

Example 16 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class LdapServerBeanDefinitionParserTests method defaultLdifFileIsSuccessful.

@Test
public void defaultLdifFileIsSuccessful() {
    this.appCtx = new InMemoryXmlApplicationContext("<ldap-server/>");
    ApacheDSContainer dsContainer = this.appCtx.getBean(ApacheDSContainer.class);
    assertThat(ReflectionTestUtils.getField(dsContainer, "ldifResources")).isEqualTo("classpath*:*.ldif");
}
Also used : ApacheDSContainer(org.springframework.security.ldap.server.ApacheDSContainer) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 17 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class LdapServerBeanDefinitionParserTests method embeddedServerCreationContainsExpectedContextSourceAndData.

@Test
public void embeddedServerCreationContainsExpectedContextSourceAndData() {
    this.appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>");
    DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) this.appCtx.getBean(BeanIds.CONTEXT_SOURCE);
    // Check data is loaded
    LdapTemplate template = new LdapTemplate(contextSource);
    template.lookup("uid=ben,ou=people");
}
Also used : DefaultSpringSecurityContextSource(org.springframework.security.ldap.DefaultSpringSecurityContextSource) LdapTemplate(org.springframework.ldap.core.LdapTemplate) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 18 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class Jsr250AnnotationDrivenBeanDefinitionParserTests method loadContext.

@BeforeEach
public void loadContext() {
    // @formatter:off
    this.appContext = new InMemoryXmlApplicationContext("<b:bean id='target' class='org.springframework.security.access.annotation.Jsr250BusinessServiceImpl'/>" + "<global-method-security jsr250-annotations='enabled'/>" + ConfigTestUtils.AUTH_PROVIDER_XML);
    // @formatter:on
    this.target = (BusinessService) this.appContext.getBean("target");
}
Also used : InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class SessionManagementConfigServlet31Tests method loadContext.

private void loadContext(String context) {
    this.context = new InMemoryXmlApplicationContext(context);
    this.springSecurityFilterChain = this.context.getBean("springSecurityFilterChain", Filter.class);
}
Also used : Filter(jakarta.servlet.Filter) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext)

Example 20 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class SecuredAnnotationDrivenBeanDefinitionParserTests method loadContext.

@BeforeEach
public void loadContext() {
    SecurityContextHolder.clearContext();
    this.appContext = new InMemoryXmlApplicationContext("<b:bean id='target' class='org.springframework.security.access.annotation.BusinessServiceImpl'/>" + "<global-method-security secured-annotations='enabled'/>" + ConfigTestUtils.AUTH_PROVIDER_XML);
    this.target = (BusinessService) this.appContext.getBean("target");
}
Also used : InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

InMemoryXmlApplicationContext (org.springframework.security.config.util.InMemoryXmlApplicationContext)20 Test (org.junit.jupiter.api.Test)15 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)4 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)4 Authentication (org.springframework.security.core.Authentication)4 LdapTemplate (org.springframework.ldap.core.LdapTemplate)3 ProviderManager (org.springframework.security.authentication.ProviderManager)3 DefaultSpringSecurityContextSource (org.springframework.security.ldap.DefaultSpringSecurityContextSource)3 Filter (jakarta.servlet.Filter)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MessageFormat (java.text.MessageFormat)1 Test (org.junit.Test)1 AuthenticationProvider (org.springframework.security.authentication.AuthenticationProvider)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1 MessageDigestPasswordEncoder (org.springframework.security.crypto.password.MessageDigestPasswordEncoder)1 ApacheDSContainer (org.springframework.security.ldap.server.ApacheDSContainer)1 InetOrgPersonContextMapper (org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper)1