TSK-1308: Format corrections.
This commit is contained in:
parent
1ba7aebc2d
commit
9375b3ead2
|
@ -15,7 +15,7 @@ import pro.taskana.common.test.rest.TaskanaSpringBootTest;
|
|||
class LdapEmptySearchRootsTest extends LdapTest {
|
||||
|
||||
@Test
|
||||
void should_findGroupsForUser_When_UserIdIsProvided() throws Exception {
|
||||
void should_FindGroupsForUser_When_UserIdIsProvided() throws Exception {
|
||||
List<AccessIdRepresentationModel> groups =
|
||||
ldapClient.searchGroupsAccessIdIsMemberOf("user-2-2");
|
||||
assertThat(groups)
|
||||
|
@ -27,7 +27,7 @@ class LdapEmptySearchRootsTest extends LdapTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void should_returnFullDnForUser_When_AccessIdOfUserIsGiven() {
|
||||
void should_ReturnFullDnForUser_When_AccessIdOfUserIsGiven() {
|
||||
String dn = ldapClient.searchDnForAccessId("otheruser");
|
||||
assertThat(dn).isEqualTo("uid=otheruser,cn=other-users,ou=test,o=taskana");
|
||||
}
|
||||
|
|
|
@ -10,17 +10,14 @@ import pro.taskana.common.rest.ldap.LdapClient;
|
|||
import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
||||
import pro.taskana.common.test.rest.TaskanaSpringBootTest;
|
||||
|
||||
/**
|
||||
* Test Ldap attachment.
|
||||
*/
|
||||
/** Test Ldap attachment. */
|
||||
@TaskanaSpringBootTest
|
||||
class LdapTest {
|
||||
|
||||
@Autowired
|
||||
LdapClient ldapClient;
|
||||
@Autowired LdapClient ldapClient;
|
||||
|
||||
@Test
|
||||
void testFindUsers() throws Exception {
|
||||
void should_FindAllUsersAndGroup_When_SearchWithSubstringOfName() throws Exception {
|
||||
List<AccessIdRepresentationModel> usersAndGroups = ldapClient.searchUsersAndGroups("lead");
|
||||
assertThat(usersAndGroups)
|
||||
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||
|
@ -29,7 +26,7 @@ class LdapTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void should_findUserByWholeName_WhenSearchingWithLdapClient() throws Exception {
|
||||
void should_FindUser_When_SearchingWithFirstAndLastname() throws Exception {
|
||||
List<AccessIdRepresentationModel> usersAndGroups = ldapClient.searchUsersAndGroups("Elena");
|
||||
assertThat(usersAndGroups).hasSize(2);
|
||||
|
||||
|
@ -38,19 +35,17 @@ class LdapTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void should_findGroupsForUser_When_UserIdIsProvided() throws Exception {
|
||||
List<AccessIdRepresentationModel> groups = ldapClient
|
||||
.searchGroupsAccessIdIsMemberOf("user-2-2");
|
||||
void should_FindGroupsForUser_When_UserIdIsProvided() throws Exception {
|
||||
List<AccessIdRepresentationModel> groups =
|
||||
ldapClient.searchGroupsAccessIdIsMemberOf("user-2-2");
|
||||
assertThat(groups)
|
||||
.extracting(AccessIdRepresentationModel::getAccessId)
|
||||
.containsExactlyInAnyOrder(
|
||||
"cn=ksc-users,cn=groups,ou=test,o=taskana");
|
||||
.containsExactlyInAnyOrder("cn=ksc-users,cn=groups,ou=test,o=taskana");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_returnFullDnForUser_When_AccessIdOfUserIsGiven() {
|
||||
void should_FeturnFullDnForUser_When_AccessIdOfUserIsGiven() {
|
||||
String dn = ldapClient.searchDnForAccessId("user-2-2");
|
||||
assertThat(dn).isEqualTo("uid=user-2-2,cn=users,ou=test,o=taskana");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,17 +35,13 @@ import pro.taskana.common.rest.models.AccessIdRepresentationModel;
|
|||
@ExtendWith(MockitoExtension.class)
|
||||
class LdapClientTest {
|
||||
|
||||
@Mock
|
||||
Environment environment;
|
||||
@Mock Environment environment;
|
||||
|
||||
@Mock
|
||||
LdapTemplate ldapTemplate;
|
||||
@Mock LdapTemplate ldapTemplate;
|
||||
|
||||
@Mock
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
@Mock TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
|
||||
@InjectMocks
|
||||
LdapClient cut;
|
||||
@InjectMocks LdapClient cut;
|
||||
|
||||
@Test
|
||||
void testLdap_searchGroupByDn() {
|
||||
|
@ -69,10 +65,10 @@ class LdapClientTest {
|
|||
AccessIdRepresentationModel user = new AccessIdRepresentationModel("testU", "testUId");
|
||||
|
||||
when(ldapTemplate.search(
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.GroupContextMapper.class)))
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.GroupContextMapper.class)))
|
||||
.thenReturn(List.of(group));
|
||||
when(ldapTemplate.search(
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.UserContextMapper.class)))
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.UserContextMapper.class)))
|
||||
.thenReturn(List.of(user));
|
||||
|
||||
assertThat(cut.searchUsersAndGroups("test")).hasSize(2).containsExactlyInAnyOrder(user, group);
|
||||
|
@ -111,7 +107,7 @@ class LdapClientTest {
|
|||
when(taskanaEngineConfiguration.getRoleMap()).thenReturn(roleMap);
|
||||
|
||||
when(ldapTemplate.search(
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.UserContextMapper.class)))
|
||||
any(String.class), any(), anyInt(), any(), any(LdapClient.UserContextMapper.class)))
|
||||
.thenReturn(List.of(user));
|
||||
|
||||
assertThat(cut.searchUsersByNameOrAccessIdInUserRole("test")).hasSize(1).containsExactly(user);
|
||||
|
@ -165,24 +161,24 @@ class LdapClientTest {
|
|||
private void setUpEnvMock() {
|
||||
|
||||
Stream.of(
|
||||
new String[][]{
|
||||
{"taskana.ldap.minSearchForLength", "3"},
|
||||
{"taskana.ldap.maxNumberOfReturnedAccessIds", "50"},
|
||||
{"taskana.ldap.baseDn", "o=TaskanaTest"},
|
||||
{"taskana.ldap.userSearchBase", "ou=people"},
|
||||
{"taskana.ldap.userSearchFilterName", "objectclass"},
|
||||
{"taskana.ldap.groupsOfUser", "memberUid"},
|
||||
{"taskana.ldap.groupNameAttribute", "cn"},
|
||||
{"taskana.ldap.groupSearchFilterValue", "groupOfUniqueNames"},
|
||||
{"taskana.ldap.groupSearchFilterName", "objectclass"},
|
||||
{"taskana.ldap.groupSearchBase", "ou=groups"},
|
||||
{"taskana.ldap.userIdAttribute", "uid"},
|
||||
{"taskana.ldap.userMemberOfGroupAttribute", "memberOf"},
|
||||
{"taskana.ldap.userLastnameAttribute", "sn"},
|
||||
{"taskana.ldap.userFirstnameAttribute", "givenName"},
|
||||
{"taskana.ldap.userFullnameAttribute", "cn"},
|
||||
{"taskana.ldap.userSearchFilterValue", "person"}
|
||||
})
|
||||
new String[][] {
|
||||
{"taskana.ldap.minSearchForLength", "3"},
|
||||
{"taskana.ldap.maxNumberOfReturnedAccessIds", "50"},
|
||||
{"taskana.ldap.baseDn", "o=TaskanaTest"},
|
||||
{"taskana.ldap.userSearchBase", "ou=people"},
|
||||
{"taskana.ldap.userSearchFilterName", "objectclass"},
|
||||
{"taskana.ldap.groupsOfUser", "memberUid"},
|
||||
{"taskana.ldap.groupNameAttribute", "cn"},
|
||||
{"taskana.ldap.groupSearchFilterValue", "groupOfUniqueNames"},
|
||||
{"taskana.ldap.groupSearchFilterName", "objectclass"},
|
||||
{"taskana.ldap.groupSearchBase", "ou=groups"},
|
||||
{"taskana.ldap.userIdAttribute", "uid"},
|
||||
{"taskana.ldap.userMemberOfGroupAttribute", "memberOf"},
|
||||
{"taskana.ldap.userLastnameAttribute", "sn"},
|
||||
{"taskana.ldap.userFirstnameAttribute", "givenName"},
|
||||
{"taskana.ldap.userFullnameAttribute", "cn"},
|
||||
{"taskana.ldap.userSearchFilterValue", "person"}
|
||||
})
|
||||
.forEach(
|
||||
strings ->
|
||||
lenient().when(this.environment.getProperty(strings[0])).thenReturn(strings[1]));
|
||||
|
|
Loading…
Reference in New Issue