-
Notifications
You must be signed in to change notification settings - Fork 31
WIP: Fix/search 1892 #440
base: master
Are you sure you want to change the base?
WIP: Fix/search 1892 #440
Conversation
agazzarini
commented
Dec 6, 2019
•
edited by amohammedalfresco
Loading
edited by amohammedalfresco
- Minor formatting, formal refacroting + additional illegal character in group id
- Added unit tests for the issue
@@ -357,57 +356,6 @@ public void testGetGroup() throws Exception | |||
|
|||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for removing the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @michaelsuzukisagi it was a test added by me. After talking with Meenal, we realized the tests have to be implemented in the TAS RESTAPI project.
So I left the test class as it was, (because the services tested by GroupsTest are not what we are fixing, they belong to some old api), and I'm implementing them in the other repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer having more unit tests over integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit tests for this issue.
… characters are found in GroupName
I'm having confusion. I could see there's a place where the new invalid character There's already an existing test to check for this array of invalid characters at: https://github.com/Alfresco/alfresco-remote-api/blob/master/src/test/java/org/alfresco/rest/api/tests/GroupsTest.java#L1457 without the need to write separate unit test. As this branch is pretty old and the fact it has other changes that am not sure of. I will now fork a new branch from |
@@ -48,6 +48,7 @@ | |||
org.alfresco.rest.api.tests.AuthenticationsTest.class, | |||
org.alfresco.rest.api.tests.DiscoveryApiTest.class, | |||
org.alfresco.rest.api.tests.GroupsTest.class, | |||
org.alfresco.rest.api.impl.GroupsImplTest.class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this and update the test in GroupsTest.java line 1453.
@@ -52,6 +52,8 @@ | |||
import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; | |||
import org.springframework.extensions.webscripts.TestWebScriptServer.Response; | |||
|
|||
import static java.util.Arrays.stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
/* | ||
* #%L | ||
* Alfresco Remote API | ||
* %% | ||
* Copyright (C) 2005 - 2016 Alfresco Software Limited | ||
* %% | ||
* This file is part of the Alfresco software. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* Alfresco is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Alfresco is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||
* #L% | ||
*/ | ||
package org.alfresco.rest.api.impl; | ||
|
||
import org.alfresco.repo.domain.permissions.Authority; | ||
import org.alfresco.repo.security.authority.AuthorityDAO; | ||
import org.alfresco.rest.api.impl.GroupsImpl; | ||
import org.alfresco.rest.api.tests.client.data.Group; | ||
import org.alfresco.rest.framework.resource.parameters.Parameters; | ||
import org.alfresco.service.cmr.security.AuthorityService; | ||
import org.alfresco.service.cmr.security.AuthorityType; | ||
import org.alfresco.service.cmr.security.PermissionService; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static org.mockito.Matchers.*; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class GroupsImplTest | ||
{ | ||
private GroupsImpl groupsImpl; | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void createGroupCheckWithillegalCharacterInGroupId() { | ||
groupsImpl = new GroupsImpl(); | ||
Group group= new Group(); | ||
String groupId="GROUP_Identifier\"WithIllegalChar"; | ||
group.setId(groupId); | ||
group.setDisplayName(groupId); | ||
AuthorityDAO authorityDAO = Mockito.mock(AuthorityDAO.class); | ||
when(authorityDAO.getAuthorityDisplayName(anyString())).thenReturn(groupId); | ||
AuthorityService authorityService = Mockito.mock(AuthorityService.class); | ||
groupsImpl.setAuthorityService(authorityService); | ||
groupsImpl.setAuthorityDAO(authorityDAO); | ||
when(authorityService.authorityExists(anyString())).thenReturn(false); | ||
when(authorityService.getName(any(AuthorityType.class), anyString())).thenReturn("test"); | ||
when(authorityService.createAuthority(any(AuthorityType.class), anyString(), anyString(), anySet())).thenReturn(PermissionService.ALL_AUTHORITIES); | ||
Parameters parameters = Mockito.mock(Parameters.class); | ||
groupsImpl.create(group, parameters); | ||
} | ||
|
||
@Test() | ||
public void createGroupCheckWithlegalCharacterInGroupId() { | ||
groupsImpl = new GroupsImpl(); | ||
Group group= new Group(); | ||
String groupId="GROUP_IdentifierWithLegalChar"; | ||
group.setId(groupId); | ||
group.setDisplayName(groupId); | ||
AuthorityDAO authorityDAO = Mockito.mock(AuthorityDAO.class); | ||
when(authorityDAO.getAuthorityDisplayName(anyString())).thenReturn(groupId); | ||
AuthorityService authorityService = Mockito.mock(AuthorityService.class); | ||
groupsImpl.setAuthorityService(authorityService); | ||
groupsImpl.setAuthorityDAO(authorityDAO); | ||
when(authorityService.authorityExists(anyString())).thenReturn(false); | ||
when(authorityService.getName(any(AuthorityType.class), anyString())).thenReturn("test"); | ||
when(authorityService.createAuthority(any(AuthorityType.class), anyString(), anyString(), anySet())).thenReturn(PermissionService.ALL_AUTHORITIES); | ||
Parameters parameters = Mockito.mock(Parameters.class); | ||
groupsImpl.create(group, parameters); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this class and update the test in GroupsTest.java line 1453.
@agazzarini: I've raised another PR #603 in regards to my previous observations. To avoid confusion, do you consider if we can close this PR? Thanks. |