TSK-1893: Convert LDAP AccessId Search inputs to lower case

Extended former testLdap_searchGroupByDn() method with upper case inputs and renamed according to the Testing Guidelines.
This commit is contained in:
Yakup Ensar Evli 2022-06-01 13:42:25 +02:00 committed by Mustapha Zorgati
parent d03455c61f
commit e69273bc5c
2 changed files with 14 additions and 3 deletions

View File

@ -232,7 +232,8 @@ public class LdapClient {
// given DN.
// https://stackoverflow.com/questions/55285743/spring-ldaptemplate-how-to-lookup-fully-qualified-dn-with-configured-base-dn
// Therefore we have to remove the base name from the dn before performing the lookup
String nameWithoutBaseDn = getNameWithoutBaseDn(dn);
String nameWithoutBaseDn = getNameWithoutBaseDn(dn).toLowerCase();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Removed baseDN {} from given DN. New DN to be used: {}", getBaseDn(), nameWithoutBaseDn);

View File

@ -47,8 +47,7 @@ class LdapClientTest {
@Spy @InjectMocks LdapClient cut;
@Test
void testLdap_searchGroupByDn() {
void should_SearchGroupByDn_For_LdapCall() {
setUpEnvMock();
cut.init();
@ -58,6 +57,17 @@ class LdapClientTest {
.lookup(eq("cn=developersgroup,ou=groups"), any(), any(LdapClient.DnContextMapper.class));
}
@Test
void should_ConvertAccessIdToLowercase_When_SearchingGroupByDn() {
setUpEnvMock();
cut.init();
cut.searchAccessIdByDn("cn=Developersgroup,ou=groups,o=taskanatest");
verify(ldapTemplate)
.lookup(eq("cn=developersgroup,ou=groups"), any(), any(LdapClient.DnContextMapper.class));
}
@Test
void testLdap_searchUsersAndGroups() throws Exception {