Add test to check retrieving of policies after changing mode to READ_ONLY

(cherry picked from commit d19a9599b5)
This commit is contained in:
Toni Prieto
2023-10-13 20:59:33 +02:00
committed by github-actions[bot]
parent 1b0e826bba
commit ddbba2d125

View File

@@ -0,0 +1,42 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.dspace.AbstractIntegrationTestWithDatabase;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.builder.CommunityBuilder;
import org.junit.Test;
public class ContextModeIT extends AbstractIntegrationTestWithDatabase {
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
@Test
public void testGetPoliciesNewCommunityAfterReadOnlyModeChange() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
context.restoreAuthSystemState();
context.setMode(Context.Mode.READ_ONLY);
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, parentCommunity,
Constants.READ);
assertEquals("Should return the default anonymous group read policy", 1, policies.size());
}
}