|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2002-2019 the original author or authors.
|
|
|
+ * Copyright 2002-2020 the original author or authors.
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -16,8 +16,11 @@
|
|
|
|
|
|
package org.springframework.security.config.ldap;
|
|
|
|
|
|
+import java.text.MessageFormat;
|
|
|
+
|
|
|
import org.junit.After;
|
|
|
import org.junit.Test;
|
|
|
+
|
|
|
import org.springframework.context.ApplicationContextException;
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
import org.springframework.security.authentication.AuthenticationProvider;
|
|
@@ -29,8 +32,6 @@ import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
import org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper;
|
|
|
|
|
|
-import java.text.MessageFormat;
|
|
|
-
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
public class LdapProviderBeanDefinitionParserTests {
|
|
@@ -46,7 +47,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
|
|
|
@Test
|
|
|
public void simpleProviderAuthenticatesCorrectly() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider group-search-filter='member={0}' />"
|
|
|
+ "</authentication-manager>"
|
|
@@ -60,7 +61,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
|
|
|
@Test
|
|
|
public void multipleProvidersAreSupported() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider group-search-filter='member={0}' />"
|
|
|
+ " <ldap-authentication-provider group-search-filter='uniqueMember={0}' />"
|
|
@@ -84,7 +85,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
|
|
|
@Test
|
|
|
public void supportsPasswordComparisonAuthentication() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
|
|
+ " <password-compare />"
|
|
@@ -100,7 +101,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
|
|
|
@Test
|
|
|
public void supportsPasswordComparisonAuthenticationWithPasswordEncoder() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
|
|
+ " <password-compare password-attribute='uid'>"
|
|
@@ -120,7 +121,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
// SEC-2472
|
|
|
@Test
|
|
|
public void supportsCryptoPasswordEncoder() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider user-dn-pattern='uid={0},ou=people'>"
|
|
|
+ " <password-compare>"
|
|
@@ -139,7 +140,7 @@ public class LdapProviderBeanDefinitionParserTests {
|
|
|
|
|
|
@Test
|
|
|
public void inetOrgContextMapperIsSupported() {
|
|
|
- appCtx = new InMemoryXmlApplicationContext("<ldap-server url='ldap://127.0.0.1:343/dc=springframework,dc=org'/>"
|
|
|
+ appCtx = new InMemoryXmlApplicationContext("<ldap-server url='ldap://127.0.0.1:343/dc=springframework,dc=org' port='0'/>"
|
|
|
+ "<authentication-manager>"
|
|
|
+ " <ldap-authentication-provider user-details-class='inetOrgPerson' />"
|
|
|
+ "</authentication-manager>"
|