use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class SeriesServiceImplTest method testACLEquality4.
@Test
public void testACLEquality4() {
AccessControlList a = new AccessControlList(new AccessControlEntry("b", Permissions.Action.WRITE.toString(), false));
AccessControlList b = new AccessControlList(new AccessControlEntry("b", Permissions.Action.WRITE.toString(), false), new AccessControlEntry("b", Permissions.Action.READ.toString(), false));
assertFalse(AccessControlUtil.equals(a, b));
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class SeriesServiceImplTest method testACLManagement.
@Test
public void testACLManagement() throws Exception {
// sample access control list
AccessControlList accessControlList = new AccessControlList();
List<AccessControlEntry> acl = accessControlList.getEntries();
acl.add(new AccessControlEntry("admin", "delete", true));
try {
seriesService.updateAccessControl("failid", accessControlList);
Assert.fail("Should fail when adding ACL to nonexistent series,");
} catch (NotFoundException e) {
// expected
}
seriesService.updateSeries(testCatalog);
seriesService.updateAccessControl(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER), accessControlList);
AccessControlList retrievedACL = seriesService.getSeriesAccessControl(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.assertNotNull(retrievedACL);
acl = retrievedACL.getEntries();
Assert.assertEquals(acl.size(), 1);
Assert.assertEquals("admin", acl.get(0).getRole());
acl = accessControlList.getEntries();
acl.clear();
acl.add(new AccessControlEntry("student", Permissions.Action.READ.toString(), true));
seriesService.updateAccessControl(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER), accessControlList);
retrievedACL = seriesService.getSeriesAccessControl(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.assertNotNull(retrievedACL);
acl = retrievedACL.getEntries();
Assert.assertEquals(acl.size(), 1);
Assert.assertEquals("student", acl.get(0).getRole());
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class SeriesServiceImplTest method testACLEquality3.
@Test
public void testACLEquality3() {
AccessControlList a = new AccessControlList();
AccessControlList b = new AccessControlList(new AccessControlEntry("b", Permissions.Action.WRITE.toString(), false));
assertFalse(AccessControlUtil.equals(a, b));
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class SeriesServiceSolrTest method testAccessControlManagmentRewrite.
@Test
public void testAccessControlManagmentRewrite() throws Exception {
// sample access control list
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
User user = new JaxbUser("anonymous", "test", new DefaultOrganization(), new JaxbRole("ROLE_ANONYMOUS", new DefaultOrganization()));
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
EasyMock.replay(securityService);
// deactivate the default index created in setUp()
index.deactivate();
// create a new index with the security service anonymous user
index = new SeriesServiceSolrIndex();
index.solrRoot = PathSupport.concat("target", Long.toString(System.currentTimeMillis()));
dcService = new DublinCoreCatalogService();
index.setDublinCoreService(dcService);
index.setSecurityService(securityService);
index.activate(null);
AccessControlList accessControlList = new AccessControlList();
List<AccessControlEntry> acl = accessControlList.getEntries();
acl.add(new AccessControlEntry("ROLE_ANONYMOUS", Permissions.Action.READ.toString(), true));
index.updateIndex(testCatalog);
String seriesID = testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER);
index.updateSecurityPolicy(seriesID, accessControlList);
SeriesQuery q = new SeriesQuery();
DublinCoreCatalogList result = index.search(q);
Assert.assertTrue("Only one anomymous series", result.size() == 1);
index.updateSecurityPolicy(seriesID, new AccessControlList());
q = new SeriesQuery();
result = index.search(q);
Assert.assertTrue("No anomymous series", result.size() == 0);
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class SeriesServiceSolrTest method testAccessControlManagment.
@Test
public void testAccessControlManagment() throws Exception {
// sample access control list
AccessControlList accessControlList = new AccessControlList();
List<AccessControlEntry> acl = accessControlList.getEntries();
acl.add(new AccessControlEntry("admin", "delete", true));
index.updateIndex(testCatalog);
String seriesID = testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER);
index.updateSecurityPolicy(seriesID, accessControlList);
AccessControlList retrievedACL = index.getAccessControl(seriesID);
Assert.assertNotNull(retrievedACL);
acl = retrievedACL.getEntries();
Assert.assertEquals(acl.size(), 1);
Assert.assertEquals(acl.get(0).getRole(), "admin");
try {
index.updateSecurityPolicy("failid", accessControlList);
Assert.fail("Should fail when indexing ACL to nonexistent series");
} catch (NotFoundException e) {
// expected
}
}
Aggregations