fas*_*ser 5 java spring integration-testing ldap active-directory
上一次我向我们的项目中添加了另一个身份验证提供程序,以便通过Windows Active Directory服务器对用户进行身份验证:
<security:authentication-manager id="authenticationManager" erase-credentials="true">
<security:authentication-provider ref="ldapActiveDirectoryAuthProvider" />
<security:authentication-provider ref="authenticationProvider1"/>
<security:authentication-provider ref="authenticationProvider2"/>
</security:authentication-manager>
<bean id="customLdapUserDetailsMapper" class="security.authentication.customLdapUserDetailsMapper">
</bean>
<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<constructor-arg value="my.domain"/>
<constructor-arg value="ldap://my.custom.host:389" />
<property name="useAuthenticationRequestCredentials" value="true" />
<property name="convertSubErrorCodesToExceptions" value="true" />
<property name="userDetailsContextMapper" ref="customLdapUserDetailsMapper" />
</bean>
Run Code Online (Sandbox Code Playgroud)
除了与身份验证流程一起使用的现有集成测试以外,几乎一切正常。即,每个测试都尝试在ActiveDirectoryLdapAuthenticationProvider.bindAsUser然后失败时尝试连接到服务器,因为my.custom.host无法用于此类型的测试。
我已经开始谷歌搜索,以便为这种类型的测试找到一些模拟,但是不幸的是,我只找到了这篇有关spring-security和ldap的集成测试,其中Luke Taylor建议使用现有的集成测试作为指南。我已经研究了它,但其中不包含针对此类提供程序的任何测试。
我是新手,很高兴知道以下几点:
new ApacheDSContainer("dc=springframework,dc=org", "classpath:test-server.ldif");以LDAP集成测试中提到的方法以任何方式重用是否正确(我不确定它是否适合我,因为我没有在应用程序上下文中创建ldap ebbedded ldap服务器,也未指定任何方法。提及配置中的ldif文件)。