Skip to content

Commit

Permalink
GH-1872 Fix LdapAuthenticatorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Jul 11, 2023
1 parent 5fea4c7 commit 96f1896
Showing 1 changed file with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ internal class LdapAuthenticatorTest : AuthenticationSpecification() {
fun createLdapServer() {
this.ldapConfiguration.update {
LdapSettings(
it.enabled,
"ldap.domain.com",
(1024 + Math.random() * (Short.MAX_VALUE - 1025)).toInt(),
"dc=domain,dc=com",
"cn=Reposilite,ou=Search Accounts,dc=domain,dc=com",
"search-secret",
"cn",
"(&(objectClass=person)(ou=Maven Users))",
it.userType
enabled = it.enabled,
hostname = "ldap.domain.com",
port = (1024 + Math.random() * (Short.MAX_VALUE - 1025)).toInt(),
baseDn = "dc=domain,dc=com",
searchUserDn = "cn=Reposilite,ou=Search Accounts,dc=domain,dc=com",
searchUserPassword = "search-secret",
userAttribute = "cn",
userFilter = "(&(objectClass=person)(ou=Maven Users))",
userType = it.userType
)
}
this.ldapConfiguration.peek {
Expand All @@ -62,16 +62,8 @@ internal class LdapAuthenticatorTest : AuthenticationSpecification() {
this.ldapServer = InMemoryDirectoryServer(config)
ldapServer.startListening(it.hostname)
this.ldapConfiguration.update(
LdapSettings(
it.enabled,
ldapServer.getListenAddress(it.hostname).hostAddress,
it.port,
it.baseDn,
it.searchUserDn,
it.searchUserPassword,
it.userAttribute,
it.userFilter,
it.userType
it.copy(
hostname = ldapServer.getListenAddress(it.hostname).hostAddress
)
)

Expand All @@ -96,7 +88,7 @@ internal class LdapAuthenticatorTest : AuthenticationSpecification() {

@Test
fun `should connect with search user`() {
val result = assertOk(authenticator.search("(&(objectClass=person)(cn=Reposilite)(ou=Search Accounts))", "cn"))
val result = assertOk(authenticator.search("(&(objectClass=person)(cn=Reposilite)(ou=Search Accounts))", arrayOf("cn")))
assertCollectionsEquals(listOf(Pair("cn=Reposilite,ou=Search Accounts,dc=domain,dc=com", mapOf("cn" to listOf("Reposilite")))), result)
}

Expand Down

0 comments on commit 96f1896

Please sign in to comment.