mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
RM-1644 (Possible to create "report" records and copy records without Create Record capability)
* Removed test case git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@96975 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,29 +28,28 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
|||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create record tests.
|
* Create record tests.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public class CreateRecordTest extends BaseRMTestCase
|
public class CreateRecordTest extends BaseRMTestCase
|
||||||
{
|
{
|
||||||
public void testCreateRecordCapabilityOnly() throws Exception
|
public void testCreateRecordCapabilityOnly() throws Exception
|
||||||
{
|
{
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
{
|
{
|
||||||
/** test data */
|
/** test data */
|
||||||
String roleName = GUID.generate();
|
String roleName = GUID.generate();
|
||||||
String user = GUID.generate();
|
String user = GUID.generate();
|
||||||
NodeRef recordFolder;
|
NodeRef recordFolder;
|
||||||
NodeRef record;
|
NodeRef record;
|
||||||
|
|
||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// create role
|
// create role
|
||||||
@@ -58,42 +57,42 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
||||||
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
||||||
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
||||||
|
|
||||||
// create user and assign to role
|
// create user and assign to role
|
||||||
createPerson(user, true);
|
createPerson(user, true);
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
||||||
|
|
||||||
// create file plan structure
|
// create file plan structure
|
||||||
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate());
|
recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
{
|
{
|
||||||
// give read and file permissions to user
|
// give read and file permissions to user
|
||||||
filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING);
|
filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING);
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null);
|
record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void then()
|
public void then()
|
||||||
{
|
{
|
||||||
// check the details of the record
|
// check the details of the record
|
||||||
assertTrue(recordService.isRecord(record));
|
assertTrue(recordService.isRecord(record));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see
|
* @see
|
||||||
*/
|
*/
|
||||||
public void testCreateRecordCapabilityOnlyFromFileFolderService() throws Exception
|
public void testCreateRecordCapabilityOnlyFromFileFolderService() throws Exception
|
||||||
{
|
{
|
||||||
@@ -101,10 +100,10 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
/** test data */
|
/** test data */
|
||||||
String roleName = GUID.generate();
|
String roleName = GUID.generate();
|
||||||
String user = GUID.generate();
|
String user = GUID.generate();
|
||||||
NodeRef recordFolder;
|
NodeRef recordFolder;
|
||||||
NodeRef record;
|
NodeRef record;
|
||||||
|
|
||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// create role
|
// create role
|
||||||
@@ -112,45 +111,45 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
||||||
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
||||||
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
||||||
|
|
||||||
// create user and assign to role
|
// create user and assign to role
|
||||||
createPerson(user, true);
|
createPerson(user, true);
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
||||||
|
|
||||||
// create file plan structure
|
// create file plan structure
|
||||||
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate());
|
recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
{
|
{
|
||||||
// give read and file permissions to user
|
// give read and file permissions to user
|
||||||
filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING);
|
filePlanPermissionService.setPermission(recordFolder, user, RMPermissionModel.FILING);
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
record = fileFolderService.create(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
|
record = fileFolderService.create(recordFolder, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef();
|
||||||
|
|
||||||
ContentWriter writer = contentService.getWriter(record, ContentModel.TYPE_CONTENT, true);
|
ContentWriter writer = contentService.getWriter(record, ContentModel.TYPE_CONTENT, true);
|
||||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
writer.setEncoding("UTF-8");
|
writer.setEncoding("UTF-8");
|
||||||
writer.putContent("Lucy Wetherall");
|
writer.putContent("Lucy Wetherall");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void then()
|
public void then()
|
||||||
{
|
{
|
||||||
// check the details of the record
|
// check the details of the record
|
||||||
assertTrue(recordService.isRecord(record));
|
assertTrue(recordService.isRecord(record));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unit test for RM1649 fix
|
* unit test for RM1649 fix
|
||||||
* test if a user with create record permissions and without file record permission is able to create a record within unfiled record container
|
* test if a user with create record permissions and without file record permission is able to create a record within unfiled record container
|
||||||
@@ -163,7 +162,7 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
String roleName = GUID.generate();
|
String roleName = GUID.generate();
|
||||||
String user = GUID.generate();
|
String user = GUID.generate();
|
||||||
NodeRef record;
|
NodeRef record;
|
||||||
|
|
||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// create a role with view and create capabilities
|
// create a role with view and create capabilities
|
||||||
@@ -171,16 +170,16 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
||||||
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
capabilities.add(capabilityService.getCapability("CreateRecords"));
|
||||||
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
||||||
|
|
||||||
|
|
||||||
// create user and assign to role
|
// create user and assign to role
|
||||||
createPerson(user, true);
|
createPerson(user, true);
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
||||||
|
|
||||||
//give read and file permission to user on unfiled records container
|
//give read and file permission to user on unfiled records container
|
||||||
filePlanPermissionService.setPermission(unfiledContainer , user, RMPermissionModel.FILING);
|
filePlanPermissionService.setPermission(unfiledContainer , user, RMPermissionModel.FILING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
@@ -188,12 +187,12 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
record = recordService.createRecordFromContent(unfiledContainer, GUID.generate(), TYPE_CONTENT, null, null);
|
record = recordService.createRecordFromContent(unfiledContainer, GUID.generate(), TYPE_CONTENT, null, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, user);
|
}, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void then()
|
public void then()
|
||||||
{
|
{
|
||||||
// check the details of the record
|
// check the details of the record
|
||||||
@@ -202,49 +201,4 @@ public class CreateRecordTest extends BaseRMTestCase
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateRecordWithoutCreateRecordCapability() throws Exception
|
|
||||||
{
|
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class)
|
|
||||||
{
|
|
||||||
/** test data */
|
|
||||||
String roleName = GUID.generate();
|
|
||||||
String user = GUID.generate();
|
|
||||||
NodeRef recordFolder;
|
|
||||||
|
|
||||||
public void given()
|
|
||||||
{
|
|
||||||
// create role
|
|
||||||
Set<Capability> capabilities = new HashSet<Capability>(2);
|
|
||||||
capabilities.add(capabilityService.getCapability("ViewRecords"));
|
|
||||||
filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
|
|
||||||
|
|
||||||
// create user and assign to role
|
|
||||||
createPerson(user, true);
|
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user);
|
|
||||||
|
|
||||||
// create file plan structure
|
|
||||||
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
|
||||||
recordFolder = recordFolderService.createRecordFolder(rc, GUID.generate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void when()
|
|
||||||
{
|
|
||||||
// give read and file permissions to user
|
|
||||||
filePlanPermissionService.setPermission(recordFolder, user,
|
|
||||||
RMPermissionModel.FILING);
|
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
|
||||||
{
|
|
||||||
public Void doWork() throws Exception
|
|
||||||
{
|
|
||||||
recordService.createRecordFromContent(recordFolder, GUID.generate(),
|
|
||||||
TYPE_CONTENT, null, null);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user