Reverse merged HEAD (5.0/Cloud)

<< Put the code back to HEAD >>
   86049 : Reverse merged HEAD (5.0/Cloud)
      << Cause of 4 errors in https://bamboo.alfresco.com/bamboo/browse/ALF-ENT-141 >>
      85880: ACE-2181 : Reverse Merge HEAD (5.0)
         << Implementing another approach for MNT-10946 and ACE-2181 >>
         Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
            71600: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud)
               70349: Merged DEV to V4.2-BUG-FIX (4.2.3)
                  70294 : MNT-10946 : Admin is no longer able to unlock files
                     - Check if node is locked before unlock for non-admin or System users. Fix related test
      85881: ACE-2181 : Merged DEV to HEAD (5.0)
         76214 : MNT-10946 : Admin is no longer able to unlock files
            - Drop check for lockowner from AbstractLockStore.set. Fix related test 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@86238 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Pavel Yurke
2014-10-02 09:39:02 +00:00
parent a8c7c459f9
commit ef5954a1a4
5 changed files with 27 additions and 85 deletions

View File

@@ -34,6 +34,7 @@ import org.alfresco.repo.search.IndexerAndSearcher;
import org.alfresco.repo.search.SearcherComponent;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus;
@@ -47,6 +48,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.test_category.BaseSpringTestsCategory;
import org.alfresco.test_category.OwnJVMTestsCategory;
@@ -71,6 +73,8 @@ public class LockServiceImplTest extends BaseSpringTest
private MutableAuthenticationService authenticationService;
private CheckOutCheckInService cociService;
private PermissionService permissionService;
private LockService securedLockService;
/**
* Data used in tests
*/
@@ -94,6 +98,10 @@ public class LockServiceImplTest extends BaseSpringTest
{
this.nodeService = (NodeService)applicationContext.getBean("dbNodeService");
this.lockService = (LockService)applicationContext.getBean("lockService");
this.securedLockService = (LockService)applicationContext.getBean("LockService");
this.permissionService = (PermissionService)applicationContext.getBean("PermissionService");
this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("authenticationService");
this.cociService = (CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
@@ -171,6 +179,11 @@ public class LockServiceImplTest extends BaseSpringTest
TestWithUserUtils.createUser(GOOD_USER_NAME, PWD, rootNodeRef, this.nodeService, this.authenticationService);
TestWithUserUtils.createUser(BAD_USER_NAME, PWD, rootNodeRef, this.nodeService, this.authenticationService);
this.permissionService.setPermission(rootNodeRef, GOOD_USER_NAME, PermissionService.ALL_PERMISSIONS, true);
this.permissionService.setPermission(rootNodeRef, BAD_USER_NAME, PermissionService.CHECK_OUT, true);
this.permissionService.setPermission(rootNodeRef, BAD_USER_NAME, PermissionService.WRITE, true);
this.permissionService.setPermission(rootNodeRef, BAD_USER_NAME, PermissionService.READ, true);
// Stash the user node ref's for later use
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
@@ -905,7 +918,8 @@ public class LockServiceImplTest extends BaseSpringTest
}
}
public void testUnlockEphemeralNodeWithAdminUser()
@SuppressWarnings("deprecation")
public void testUnlockNodeWithAdminUser()
{
for (Lifetime lt : new Lifetime[]{Lifetime.EPHEMERAL, Lifetime.PERSISTENT})
{
@@ -916,27 +930,30 @@ public class LockServiceImplTest extends BaseSpringTest
this.nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{}testNode"), ContentModel.TYPE_CONTAINER).getChildRef();
// lock it as GOOD user
this.lockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null);
this.securedLockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null);
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
try
{
// try to unlock as bad user
this.lockService.unlock(testNode);
this.securedLockService.unlock(testNode);
fail("BAD user shouldn't be able to unlock " + lt + " lock");
}
catch(UnableToReleaseLockException e)
catch(AccessDeniedException e)
{
// it's expected
// expected expetion
}
TestWithUserUtils.authenticateUser(AuthenticationUtil.getAdminUserName(), "admin", rootNodeRef, this.authenticationService);
// try to unlock as ADMIN user
this.lockService.unlock(testNode);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.securedLockService.unlock(testNode);
// test that bad use able to lock/unlock node
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.securedLockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null);
this.securedLockService.unlock(testNode);
this.nodeService.deleteNode(testNode);
}