[Task 72503] added the default Anon READ policy for the site object

This commit is contained in:
Raf Ponsaerts
2020-08-14 13:15:51 +02:00
parent d1ee942bd4
commit 63ca007dc2
2 changed files with 37 additions and 1 deletions

View File

@@ -14,13 +14,16 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.dspace.AbstractUnitTest;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.SiteService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.eperson.Group;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -143,4 +146,17 @@ public class SiteTest extends AbstractUnitTest {
assertThat("testGetURL 0", s.getURL(), equalTo(ConfigurationManager.getProperty("dspace.ui.url")));
}
@Test
public void testAnonymousReadRights() throws Exception {
List<Group> groupList = authorizeService.getAuthorizedGroups(context, s, Constants.READ);
boolean foundAnonInList = false;
for (Group group : groupList) {
if (StringUtils.equalsIgnoreCase(group.getName(), "Anonymous")) {
foundAnonInList = true;
}
}
assertTrue(foundAnonInList);
}
}