use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class SchedulerServiceDatabaseImplTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
schedulerDatabase = new SchedulerServiceDatabaseImpl();
schedulerDatabase.setEntityManagerFactory(newTestEntityManagerFactory(SchedulerServiceDatabaseImpl.PERSISTENCE_UNIT));
schedulerDatabase.setSecurityService(securityService);
schedulerDatabase.activate(null);
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class CommentSchedulerConflictNotifierTest method setUp.
@Before
public void setUp() throws Exception {
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(new JaxbUser("admin", "provider", new DefaultOrganization(), new JaxbRole("admin", new DefaultOrganization(), "test"))).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(IoSupport.classPathResourceAsFile("/dublincore.xml").get()).anyTimes();
EasyMock.replay(workspace);
EventCatalogUIAdapter episodeAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(episodeAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("dublincore", "episode")).anyTimes();
EasyMock.expect(episodeAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(episodeAdapter);
EventCatalogUIAdapter extendedAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(extendedAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("extended", "episode")).anyTimes();
EasyMock.expect(extendedAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(extendedAdapter);
conflictNotifier = new CommentSchedulerConflictNotifier();
conflictNotifier.setSecurityService(securityService);
conflictNotifier.setWorkspace(workspace);
conflictNotifier.addCatalogUIAdapter(episodeAdapter);
conflictNotifier.addCatalogUIAdapter(extendedAdapter);
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class EmailSchedulerConflictNotifierTest method setUp.
@Before
public void setUp() throws Exception {
Dictionary<String, String> properties = new Hashtable<>();
properties.put("to", "test@test.com");
properties.put("subject", "Test email scheduler conflict");
properties.put("template", "Dear Administrator,\n\nthe following recording schedules are conflicting with existing ones:\n\n${recordings}\nBye!");
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(new JaxbUser("admin", "provider", new DefaultOrganization(), new JaxbRole("admin", new DefaultOrganization(), "test"))).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(IoSupport.classPathResourceAsFile("/dublincore.xml").get()).anyTimes();
EasyMock.replay(workspace);
EventCatalogUIAdapter episodeAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(episodeAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("dublincore", "episode")).anyTimes();
EasyMock.expect(episodeAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(episodeAdapter);
EventCatalogUIAdapter extendedAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(extendedAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("extended", "episode")).anyTimes();
EasyMock.expect(extendedAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(extendedAdapter);
BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bundleContext.getProperty(OpencastConstants.SERVER_URL_PROPERTY)).andReturn("http://localhost:8080").anyTimes();
EasyMock.replay(bundleContext);
ComponentContext componentContext = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(componentContext.getBundleContext()).andReturn(bundleContext).anyTimes();
EasyMock.expect(componentContext.getProperties()).andReturn(new Hashtable<String, Object>()).anyTimes();
EasyMock.replay(componentContext);
conflictNotifier = new EmailSchedulerConflictNotifier();
conflictNotifier.setSecurityService(securityService);
conflictNotifier.setWorkspace(workspace);
conflictNotifier.addCatalogUIAdapter(episodeAdapter);
conflictNotifier.addCatalogUIAdapter(extendedAdapter);
conflictNotifier.activate(componentContext);
conflictNotifier.updated(properties);
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class OaiPmhRepositoryPersistenceTest method oaiPmhDatabase.
private static AbstractOaiPmhDatabase oaiPmhDatabase(MediaPackage... mps) {
try {
final Organization org = new DefaultOrganization();
final SecurityService secSvc = EasyMock.createNiceMock(SecurityService.class);
// security service
final User user = createSystemUser("admin", org);
expect(secSvc.getOrganization()).andReturn(org).anyTimes();
expect(secSvc.getUser()).andReturn(user).anyTimes();
EasyMock.replay(secSvc);
// series service
final SeriesService seriesService = EasyMock.createNiceMock(SeriesService.class);
final String xacml = IOUtils.toString(OaiPmhRepositoryPersistenceTest.class.getResource("/xacml.xml").toURI());
final AccessControlList securityACL = AccessControlParser.parseAcl(xacml);
EasyMock.expect(seriesService.getSeriesAccessControl("10.0000/1")).andReturn(securityACL).anyTimes();
EasyMock.replay(seriesService);
// workspace
final Workspace workspace = EasyMock.createNiceMock(Workspace.class);
final File episodeDublinCore = new File(OaiPmhRepositoryPersistenceTest.class.getResource("/episode-dublincore.xml").toURI());
final File seriesDublinCore = new File(OaiPmhRepositoryPersistenceTest.class.getResource("/series-dublincore.xml").toURI());
expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> {
final String uri = getCurrentArguments()[0].toString();
if ("dublincore.xml".equals(uri))
return new FileInputStream(episodeDublinCore);
if ("series-dublincore.xml".equals(uri))
return new FileInputStream(seriesDublinCore);
throw new Error("Workspace mock does not know about file " + uri);
}).anyTimes();
EasyMock.replay(workspace);
// oai-pmh database
final EntityManagerFactory emf = PersistenceUtil.newTestEntityManagerFactory(OaiPmhDatabaseImpl.PERSISTENCE_UNIT_NAME);
final AbstractOaiPmhDatabase db = new AbstractOaiPmhDatabase() {
@Override
public EntityManagerFactory getEmf() {
return emf;
}
@Override
public SecurityService getSecurityService() {
return secSvc;
}
@Override
public Workspace getWorkspace() {
return workspace;
}
@Override
public Date currentDate() {
return new Date();
}
};
for (MediaPackage mp : mps) db.store(mp, REPOSITORY_ID);
return db;
} catch (Exception e) {
return chuck(e);
}
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class PresetProviderImplTest method propertyInSeriesNullOrg.
@Test
public void propertyInSeriesNullOrg() throws NotFoundException {
SecurityService securityServiceWithoutOrg = EasyMock.createMock(SecurityService.class);
EasyMock.expect(securityServiceWithoutOrg.getOrganization()).andReturn(null);
EasyMock.replay(securityServiceWithoutOrg);
presetProviderImpl.setSecurityService(securityServiceWithoutOrg);
assertEquals(SERIES_PROPERTY_VALUE, presetProviderImpl.getProperty(SERIES_ID, SERIES_PROPERTY_NAME));
}
Aggregations