Fix bad test permissions. Add a new test to check Community Admins can edit items under their Community

This commit is contained in:
Tim Donohue
2014-08-12 12:59:47 -05:00
parent 56fab73fe4
commit 56fda36375

View File

@@ -30,7 +30,6 @@ import mockit.*;
import org.dspace.app.util.AuthorizeUtil;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.content.authority.MetadataAuthorityManager;
import org.dspace.core.Constants;
/**
@@ -1564,7 +1563,7 @@ public class ItemTest extends AbstractDSpaceObjectTest
@Test
public void testCanEditBooleanAuth3() throws Exception
{
// Test Inheritance of permissions
// Test Inheritance of permissions for owning collection
new NonStrictExpectations(AuthorizeManager.class)
{{
// Disallow Item WRITE perms
@@ -1572,7 +1571,7 @@ public class ItemTest extends AbstractDSpaceObjectTest
Constants.WRITE); result = false;
// Allow parent Collection WRITE perms
AuthorizeManager.authorizeAction((Context) any, (Collection) any,
Constants.WRITE, true); result = null;
Constants.WRITE, false); result = null;
}};
// Create a new Collection and assign it as the owner
@@ -1585,6 +1584,32 @@ public class ItemTest extends AbstractDSpaceObjectTest
assertTrue("testCanEditBooleanAuth3 0", it.canEdit());
}
/**
* Test of canEditBoolean method, of class Collection.
*/
@Test
public void testCanEditBooleanAuth4() throws Exception
{
// Test Inheritance of permissions for Community Admins
new NonStrictExpectations(AuthorizeManager.class)
{{
// Disallow Item WRITE perms
AuthorizeManager.authorizeActionBoolean((Context) any, (Item) any,
Constants.WRITE); result = false;
// Allow parent Community WRITE and ADD perms
AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any,
Constants.WRITE,true); result = true;
AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any,
Constants.ADD,true); result = true;
// Disallow parent Collection WRITE perms
AuthorizeManager.authorizeAction((Context) any, (Collection) any,
Constants.WRITE,true); result = new AuthorizeException();
}};
// Ensure person with WRITE perms on the Collection can edit item
assertTrue("testCanEditBooleanAuth3 0", it.canEdit());
}
/**
* Test of canEditBoolean method, of class Collection.
*/