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