TSK-1308: Format corrections.

This commit is contained in:
Holger Hagen 2021-07-08 15:55:10 +02:00 committed by holgerhagen
parent 1ba7aebc2d
commit 9375b3ead2
3 changed files with 36 additions and 45 deletions

View File

@ -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");
} }

View File

@ -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");
} }
} }

View File

@ -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() {