use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AclScannerTest method testMissingFileUpdate.
@Test
public void testMissingFileUpdate() throws Exception {
File file1 = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI());
File file2 = new File(AclScannerTest.class.getResource("/xacml_correct2.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(file1);
aclScanner.update(file2);
EasyMock.verify(aclDb);
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testDeleteSeries.
@Test
public void testDeleteSeries() throws Exception {
final ManagedAcl macl = createAcl();
SeriesACLTransition t1 = db.storeSeriesAclTransition(ORG, "uuid", new Date(), macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
// try deletion from different org
try {
db.deleteSeriesAclTransition(ORG2, t1.getTransitionId());
fail("Deleting from non-owner org should not be possible");
} catch (NotFoundException ignore) {
}
db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
try {
db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
fail("Deleting a non existing transition should throw an exception");
} catch (NotFoundException ignore) {
}
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testGetEpisodeTransitions.
@Test
public void testGetEpisodeTransitions() throws Exception {
final ManagedAcl macl = createAcl();
db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
// there should now be two transitions for episode "uuid"
List<EpisodeACLTransition> episodes = db.getEpisodeAclTransitions(ORG, "uuid");
assertEquals(2, episodes.size());
// transitions shouldn't be accessible from another organization
assertEquals(0, db.getEpisodeAclTransitions(ORG2, "uuid").size());
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testStoreAndGetSeriesACL.
@Test
public void testStoreAndGetSeriesACL() throws Exception {
final Date now = new Date();
// a transition referencing a non existing ACL should not be saveable
try {
db.storeSeriesAclTransition(ORG, "uuid", new Date(), 1L, true, 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 SeriesACLTransition t3 = db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), false, Option.<ConfiguredWorkflowRef>none());
assertEquals("uuid", t3.getSeriesId());
assertEquals(now, t3.getApplicationDate());
assertEquals(macl.getName(), t3.getAccessControlList().getName());
// a transition with the same properties should not be saveable
try {
db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
fail("Duplicated episode ACL must not be stored");
} catch (AclTransitionDbDuplicatedException ignore) {
}
List<SeriesACLTransition> ts = db.getSeriesAclTransitions(ORG, "uuid");
assertEquals(1, ts.size());
assertEquals("uuid", ts.get(0).getSeriesId());
assertTrue(!ts.get(0).isOverride());
assertTrue(!ts.get(0).isDone());
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class SeriesAclTransitionEntity method update.
SeriesAclTransitionEntity update(final String seriesId, final String orgId, final Date applicationDate, final ManagedAclEntity managedAcl, final Option<ConfiguredWorkflowRef> workflow, final boolean override) {
final SeriesAclTransitionEntity self = this;
run(SeriesACLTransition.class, new SeriesACLTransition() {
@Override
public String getSeriesId() {
self.seriesId = seriesId;
return null;
}
@Override
public ManagedAcl getAccessControlList() {
self.managedAcl = managedAcl;
return null;
}
@Override
public boolean isOverride() {
self.override = override;
return false;
}
@Override
public long getTransitionId() {
return 0;
}
@Override
public String getOrganizationId() {
self.organizationId = orgId;
return null;
}
@Override
public Date getApplicationDate() {
self.applicationDate = applicationDate;
return null;
}
@Override
public Option<ConfiguredWorkflowRef> getWorkflow() {
final Tuple<Option<String>, Option<String>> s = splitConfiguredWorkflowRef(workflow);
self.workflowId = s.getA().getOrElseNull();
self.workflowParams = s.getB().getOrElseNull();
return null;
}
@Override
public boolean isDone() {
self.done = done;
return false;
}
});
return this;
}
Aggregations