use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AclScannerTest method testCorrectFileInstall.
@Test
public void testCorrectFileInstall() throws Exception {
File file = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI());
ManagedAcl acl = new ManagedAclImpl(1L, "TestAcl", "org", new AccessControlList());
Option<ManagedAcl> managedAcl = Option.some(acl);
EasyMock.expect(aclDb.createAcl(anyObject(Organization.class), anyObject(AccessControlList.class), anyString())).andReturn(managedAcl).times(3);
EasyMock.expect(aclDb.getAcls(anyObject(Organization.class))).andReturn(new ArrayList<ManagedAcl>()).times(3);
EasyMock.replay(aclDb);
aclScanner.install(file);
EasyMock.verify(aclDb);
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AclScannerTest method testRemoveFile.
@Test
public void testRemoveFile() throws Exception {
File file1 = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI());
Long id = 1L;
String org = "org";
ManagedAcl acl = new ManagedAclImpl(id, "TestAcl", org, new AccessControlList());
Option<ManagedAcl> managedAcl = Option.some(acl);
EasyMock.expect(aclDb.createAcl(anyObject(Organization.class), anyObject(AccessControlList.class), anyString())).andReturn(managedAcl).times(3);
EasyMock.expect(aclDb.getAcl(EasyMock.anyObject(Organization.class), anyLong())).andReturn(managedAcl).times(3);
EasyMock.expect(aclDb.deleteAcl(anyObject(Organization.class), anyLong())).andReturn(true).times(3);
EasyMock.expect(aclDb.getAcls(anyObject(Organization.class))).andReturn(new ArrayList<ManagedAcl>()).times(3);
EasyMock.replay(aclDb);
aclScanner.install(file1);
aclScanner.uninstall(file1);
EasyMock.verify(aclDb);
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AclScannerTest method testCorrectFileUpdate.
@Test
public void testCorrectFileUpdate() throws Exception {
File file = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI());
ManagedAcl acl = new ManagedAclImpl(1L, "TestAcl", "org", new AccessControlList());
Option<ManagedAcl> managedAcl = Option.some(acl);
EasyMock.expect(aclDb.createAcl(anyObject(Organization.class), anyObject(AccessControlList.class), anyString())).andReturn(managedAcl).times(3);
EasyMock.expect(aclDb.getAcl(anyObject(Organization.class), anyLong())).andReturn(managedAcl).times(3);
EasyMock.expect(aclDb.updateAcl(anyObject(ManagedAcl.class))).andReturn(true).times(3);
EasyMock.expect(aclDb.getAcls(anyObject(Organization.class))).andReturn(new ArrayList<ManagedAcl>()).times(3);
EasyMock.replay(aclDb);
aclScanner.install(file);
aclScanner.update(file);
EasyMock.verify(aclDb);
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testStoreAndGetEpisodeACL.
@Test
public void testStoreAndGetEpisodeACL() throws Exception {
final Date now = new Date();
// a fallback to series transition should be saveable
db.storeEpisodeAclTransition(ORG, "uuid", now, none(0L), Option.<ConfiguredWorkflowRef>none());
// a transition referencing a non existing ACL should not be saveable
try {
db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(1L), Option.<ConfiguredWorkflowRef>none());
fail("No ACL with ID 1");
} catch (AclTransitionDbException ignore) {
}
// a transition referencing an existing ACL should be saveable
final ManagedAcl macl = createAcl();
final EpisodeACLTransition t3 = db.storeEpisodeAclTransition(ORG, "uuid-2", now, some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
assertEquals("uuid-2", t3.getEpisodeId());
assertEquals(now, t3.getApplicationDate());
assertTrue(t3.getAccessControlList().isSome());
assertEquals(macl.getName(), t3.getAccessControlList().get().getName());
// a transition with the same properties should not be saveable
try {
db.storeEpisodeAclTransition(ORG, "uuid", now, some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
fail("Duplicated episode ACL must not be stored");
} catch (AclTransitionDbDuplicatedException ignore) {
}
List<EpisodeACLTransition> ts = db.getEpisodeAclTransitions(ORG, "uuid");
assertEquals(1, ts.size());
assertEquals("uuid", ts.get(0).getEpisodeId());
assertTrue(ts.get(0).isDelete());
assertTrue(!ts.get(0).isDone());
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testGetByQuery.
@Test
public void testGetByQuery() throws Exception {
final ManagedAcl macl = createAcl();
SeriesACLTransition st1 = db.storeSeriesAclTransition(ORG, "uuid-series", new Date(1347000000000L), macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
SeriesACLTransition st2 = db.storeSeriesAclTransition(ORG, "uuid-series", new Date(1347000900000L), macl.getId(), false, Option.<ConfiguredWorkflowRef>none());
SeriesACLTransition st3 = db.storeSeriesAclTransition(ORG, "uuid-series2", new Date(1347000030000L), macl.getId(), false, option(workflow("full")));
SeriesACLTransition st4 = db.markSeriesTransitionAsCompleted(ORG, st3.getTransitionId());
EpisodeACLTransition et1 = db.storeEpisodeAclTransition(ORG, "uuid-episode", new Date(1347005303736L), Option.<Long>none(), Option.<ConfiguredWorkflowRef>none());
EpisodeACLTransition et2 = db.storeEpisodeAclTransition(ORG, "uuid-episode", new Date(1347005343736L), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
EpisodeACLTransition et3 = db.storeEpisodeAclTransition(ORG, "uuid-episode2", new Date(1347005343736L), some(macl.getId()), option(workflow("full")));
EpisodeACLTransition et4 = db.markEpisodeTransitionAsCompleted(ORG, et3.getTransitionId());
// Test All
TransitionQuery query = TransitionQuery.query();
TransitionResult result = db.getByQuery(ORG, query);
assertEquals(3, result.getEpisodeTransistions().size());
assertEquals(3, result.getSeriesTransistions().size());
assertEquals(et1.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
assertEquals(et2.getTransitionId(), result.getEpisodeTransistions().get(1).getTransitionId());
assertEquals(et4.getTransitionId(), result.getEpisodeTransistions().get(2).getTransitionId());
assertEquals(st1.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
assertEquals(st4.getTransitionId(), result.getSeriesTransistions().get(1).getTransitionId());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(2).getTransitionId());
// Test Episode
query.withScope(AclScope.Episode);
result = db.getByQuery(ORG, query);
assertEquals(3, result.getEpisodeTransistions().size());
assertEquals(0, result.getSeriesTransistions().size());
assertEquals(et1.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
assertEquals(et2.getTransitionId(), result.getEpisodeTransistions().get(1).getTransitionId());
assertEquals(et3.getTransitionId(), result.getEpisodeTransistions().get(2).getTransitionId());
query.withScope(AclScope.Episode);
result = db.getByQuery(ORG2, query);
assertEquals(0, result.getEpisodeTransistions().size());
assertEquals(0, result.getSeriesTransistions().size());
// Test Series
query.withScope(AclScope.Series);
result = db.getByQuery(ORG, query);
assertEquals(0, result.getEpisodeTransistions().size());
assertEquals(3, result.getSeriesTransistions().size());
assertEquals(st1.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
assertEquals(st3.getTransitionId(), result.getSeriesTransistions().get(1).getTransitionId());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(2).getTransitionId());
// Test Date from
query = TransitionQuery.query().after(new Date(1347000040000L));
result = db.getByQuery(ORG, query);
assertEquals(3, result.getEpisodeTransistions().size());
assertEquals(1, result.getSeriesTransistions().size());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
// Test Date from, to
query.before(new Date(1347005313736L)).after(new Date(1347000040000L));
result = db.getByQuery(ORG, query);
assertEquals(1, result.getEpisodeTransistions().size());
assertEquals(1, result.getSeriesTransistions().size());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
assertEquals(et1.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
// Test id
query = TransitionQuery.query().withId("uuid-series");
result = db.getByQuery(ORG, query);
assertEquals(0, result.getEpisodeTransistions().size());
assertEquals(2, result.getSeriesTransistions().size());
assertEquals(st1.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(1).getTransitionId());
query = TransitionQuery.query().withId("uuid-series");
result = db.getByQuery(ORG2, query);
assertEquals(0, result.getEpisodeTransistions().size());
assertEquals(0, result.getSeriesTransistions().size());
// Test transitionId
result = db.getByQuery(ORG, TransitionQuery.query().withTransitionId(et2.getTransitionId()));
assertEquals(1, result.getEpisodeTransistions().size());
assertEquals(0, result.getSeriesTransistions().size());
assertEquals(et2.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
// Test is done
query = TransitionQuery.query().withDone(false);
result = db.getByQuery(ORG, query);
assertEquals(2, result.getEpisodeTransistions().size());
assertEquals(2, result.getSeriesTransistions().size());
assertEquals(et1.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
assertEquals(et2.getTransitionId(), result.getEpisodeTransistions().get(1).getTransitionId());
assertEquals(st1.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
assertEquals(st2.getTransitionId(), result.getSeriesTransistions().get(1).getTransitionId());
query.withDone(true);
result = db.getByQuery(ORG, query);
assertEquals(1, result.getEpisodeTransistions().size());
assertEquals(1, result.getSeriesTransistions().size());
assertEquals(et3.getTransitionId(), result.getEpisodeTransistions().get(0).getTransitionId());
assertEquals(st3.getTransitionId(), result.getSeriesTransistions().get(0).getTransitionId());
}
Aggregations