diff --git a/source/test-java/org/alfresco/repo/lock/LockServiceImplTest.java b/source/test-java/org/alfresco/repo/lock/LockServiceImplTest.java index af742c5b06..6cda7f55f7 100644 --- a/source/test-java/org/alfresco/repo/lock/LockServiceImplTest.java +++ b/source/test-java/org/alfresco/repo/lock/LockServiceImplTest.java @@ -919,7 +919,7 @@ public class LockServiceImplTest extends BaseSpringTest } @SuppressWarnings("deprecation") - public void testUnlockNodeWithAdminUser() + public void testUnlockNodeWithAdminUserAndAllPermissionsUser() { for (Lifetime lt : new Lifetime[]{Lifetime.EPHEMERAL, Lifetime.PERSISTENT}) { @@ -955,6 +955,12 @@ public class LockServiceImplTest extends BaseSpringTest this.securedLockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null); this.securedLockService.unlock(testNode); + this.securedLockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null); + + // user who has ALL PERMISSIONS is able to unlock another's user lock + TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); + this.securedLockService.unlock(testNode); + this.nodeService.deleteNode(testNode); } } diff --git a/source/test-java/org/alfresco/repo/lock/mem/AbstractLockStoreTxTest.java b/source/test-java/org/alfresco/repo/lock/mem/AbstractLockStoreTxTest.java index 51c3cb36e5..51ed54057e 100644 --- a/source/test-java/org/alfresco/repo/lock/mem/AbstractLockStoreTxTest.java +++ b/source/test-java/org/alfresco/repo/lock/mem/AbstractLockStoreTxTest.java @@ -488,7 +488,7 @@ public abstract class AbstractLockStoreTxTest @Test - public void testOnlyCurrentLockOwnerCanChangeInfo() throws NotSupportedException, SystemException + public void testNotOnlyCurrentLockOwnerCanChangeInfo() throws NotSupportedException, SystemException { final TransactionService txService = (TransactionService) ctx.getBean("TransactionService"); UserTransaction txA = txService.getUserTransaction(); @@ -514,20 +514,13 @@ public abstract class AbstractLockStoreTxTest // Check update assertEquals(lockState2, lockStore.get(nodeRef)); - // Incorrect lock owner - this should fail. + // Incorrect lock owner - this shouldn't fail. See ACE-2181 final LockState lockState3 = LockState.createWithOwner(lockState1, "dsmithers"); - try - { - lockStore.set(nodeRef, lockState3); - fail("Exception should have been thrown, but was not."); - } - catch(UnableToAquireLockException e) - { - // Good - } + + lockStore.set(nodeRef, lockState3); - // Check no update. - assertEquals(lockState2, lockStore.get(nodeRef)); + // Check update. + assertEquals(lockState3, lockStore.get(nodeRef)); } finally { @@ -564,23 +557,16 @@ public abstract class AbstractLockStoreTxTest // Updated, since lock had expired. assertEquals(lockState2, lockStore.get(nodeRef)); - - // Incorrect lock owner - this should fail, current lock has not expired + // Incorrect lock owner - this shouldn't fail + // LockStore does not check for lock owning // and is owned by csmith. AuthenticationUtil.setFullyAuthenticatedUser("dsmithers"); final LockState lockState3 = LockState.createWithOwner(lockState2, "dsmithers"); - try - { - lockStore.set(nodeRef, lockState3); - fail("Exception should have been thrown, but was not."); - } - catch(UnableToAquireLockException e) - { - // Good - } - // Check no update. - assertEquals(lockState2, lockStore.get(nodeRef)); + lockStore.set(nodeRef, lockState3); + + // Check update. + assertEquals(lockState3, lockStore.get(nodeRef)); } finally {