Merged 5.2.0 (5.2.0) to HEAD (5.2)

133842 rmunteanu: REPO-1746: Merge fixes for 5.2 GA issues to 5.2.0 branch
      Merged 5.2.N (5.2.1) to 5.2.0 (5.2.0)
         133336 rmunteanu: REPO-1654, REPO-1655: Update one permission field returns 500
            - Changed status code and message in case one of the required permission fields is missing.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@134181 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2017-01-11 10:33:53 +00:00
parent 62038af3ee
commit 342fe6f26c
3 changed files with 56 additions and 7 deletions

View File

@@ -4255,6 +4255,9 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
testUpdatePermissionInvalidAccessStatus();
testUpdatePermissionAddDuplicate();
// required permission properties missing
testUpdatePermissionMissingFields();
// 'Permission Denied' tests
testUpdatePermissionsPermissionDeniedUser();
testUpdatePermissionsOnSpecialNodes();
@@ -4438,6 +4441,42 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 400);
}
/**
* Tests updating permissions on a node without providing mandatory
* properties
*
* @throws Exception
*/
private void testUpdatePermissionMissingFields() throws Exception
{
// create folder with an empty document
String postUrl = createFolder();
String dId = createDocument(postUrl);
// update permissions
Document dUpdate = new Document();
// Add same permission with different access status
NodePermissions nodePermissions = new NodePermissions();
List<NodePermissions.NodePermission> locallySetPermissions = new ArrayList<>();
locallySetPermissions.add(new NodePermissions.NodePermission(null, PermissionService.CONSUMER, AccessStatus.ALLOWED.toString()));
nodePermissions.setLocallySet(locallySetPermissions);
dUpdate.setPermissions(nodePermissions);
// "Authority Id is expected."
put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 400);
locallySetPermissions.clear();
locallySetPermissions.add(new NodePermissions.NodePermission("", PermissionService.CONSUMER, AccessStatus.ALLOWED.toString()));
put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 400);
locallySetPermissions.clear();
locallySetPermissions.add(new NodePermissions.NodePermission(groupA, null, AccessStatus.ALLOWED.toString()));
// "Permission name is expected."
put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 400);
locallySetPermissions.clear();
locallySetPermissions.add(new NodePermissions.NodePermission(groupA, "", AccessStatus.ALLOWED.toString()));
put(URL_NODES, dId, toJsonAsStringNonNull(dUpdate), null, 400);
}
/**
* Tests updating permissions on a node that user doesn't have permission for
*