Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

59349: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      59348: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1)
         59346: MNT-9771: Merged V4.1.7 (4.1.7.1) to V4.1-BUG-FIX (4.1.8)
            59313: MNT-10231 : CLONE: Version History shows incorrect creator for previous versions
               -  Java-backed webscript CommentsPost added. Also auditable behavior is disabled around creating comment-node
            59326: MNT-10231 : CLONE: Version History shows incorrect creator for previous versions
               -  Posting activity item added to CommentsPost web-script. Also copyright message and comments added, @since changed to 4.1.7.1
            59334: MNT-10231: Merged DEV to V4.1.7 (4.1.7.1)
               56938: MNT-9771 : Version History shows incorrect creator for previous versions
                  - Added a test to reproduce this issue


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62132 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-12 01:29:42 +00:00
parent be6f4be740
commit c21e64b37a
4 changed files with 413 additions and 71 deletions

View File

@@ -12,6 +12,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.repo.security.permissions.PermissionServiceSPI;
import org.alfresco.repo.security.permissions.impl.ModelDAO;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.permissions.impl.SimplePermissionEntry;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.model.FileFolderService;
@@ -48,6 +49,7 @@ public class CommentsApiTest extends BaseWebScriptTest
private AuthenticationComponent authenticationComponent;
protected PermissionServiceSPI permissionService;
protected ModelDAO permissionModelDAO;
private MutableAuthenticationDao authenticationDAO;
private NodeRef rootNodeRef;
private NodeRef companyHomeNodeRef;
@@ -57,6 +59,9 @@ public class CommentsApiTest extends BaseWebScriptTest
private UserTransaction txn;
private String USER2 = "user2";
@Override
protected void setUp() throws Exception
{
@@ -70,6 +75,7 @@ public class CommentsApiTest extends BaseWebScriptTest
namespaceService = (NamespaceService)appContext.getBean("namespaceService");
versionService = (VersionService)appContext.getBean("versionService");
personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
authenticationDAO = (MutableAuthenticationDao) appContext.getBean("authenticationDao");
authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService");
authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent");
permissionService = (PermissionServiceSPI) getServer().getApplicationContext().getBean("permissionService");
@@ -98,6 +104,12 @@ public class CommentsApiTest extends BaseWebScriptTest
nodeRef = fileFolderService.create(companyHomeNodeRef, "Commenty", ContentModel.TYPE_CONTENT).getNodeRef();
versionService.ensureVersioningEnabled(nodeRef, null);
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTO_VERSION_PROPS, true);
if (authenticationDAO.userExists(USER2))
{
authenticationService.deleteAuthentication(USER2);
}
authenticationService.createAuthentication(USER2, USER2.toCharArray());
createUser(USER_TEST);
@@ -154,7 +166,7 @@ public class CommentsApiTest extends BaseWebScriptTest
String version = versionService.getCurrentVersion(nodeRef).getVersionLabel();
return version;
}
public void testCommentDoesNotVersion() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
@@ -165,6 +177,10 @@ public class CommentsApiTest extends BaseWebScriptTest
assertEquals(versionBefore, versionAfter);
}
/**
* MNT-9771
* @throws Exception
*/
public void testCommentPermissions() throws Exception
{
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
@@ -217,4 +233,18 @@ public class CommentsApiTest extends BaseWebScriptTest
{
return permissionModelDAO.getPermissionReference(null, permission);
}
/**
* MNT-9771
* @throws Exception
*/
public void testCommentDoesNotChangeModifier() throws Exception
{
permissionService.setPermission(nodeRef, USER2, PermissionService.ALL_PERMISSIONS, true);
String modifierBefore = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER);
addComment(nodeRef, USER2, 200);
String modifierAfter = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER);
assertEquals(modifierBefore, modifierAfter);
}
}