mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Add test to check retrieving of policies after changing mode to READ_ONLY
(cherry picked from commit d19a9599b5
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
1b0e826bba
commit
ddbba2d125
42
dspace-api/src/test/java/org/dspace/core/ContextModeIT.java
Normal file
42
dspace-api/src/test/java/org/dspace/core/ContextModeIT.java
Normal 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());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user