use of org.opencastproject.security.api.JaxbUser in project opencast by opencast.
the class CommentParserTest method setUp.
@Before
public void setUp() throws Exception {
userDirectoryService = EasyMock.createNiceMock(UserDirectoryService.class);
testUser = new JaxbUser("test", "test", new DefaultOrganization());
EasyMock.expect(userDirectoryService.loadUser(EasyMock.anyObject(String.class))).andReturn(testUser).anyTimes();
EasyMock.replay(userDirectoryService);
}
use of org.opencastproject.security.api.JaxbUser in project opencast by opencast.
the class EventCommentDatabaseImplTest method testGetEventsWithComments.
@Test
public void testGetEventsWithComments() throws Exception {
Organization org1 = EasyMock.createNiceMock(Organization.class);
EasyMock.expect(org1.getId()).andReturn("org1").anyTimes();
EasyMock.expect(org1.getName()).andReturn("org1").anyTimes();
Organization org2 = EasyMock.createNiceMock(Organization.class);
EasyMock.expect(org2.getId()).andReturn("org2").anyTimes();
EasyMock.expect(org2.getName()).andReturn("org2").anyTimes();
EasyMock.replay(org1, org2);
User userOrg1 = new JaxbUser("userOrg1", "default", JaxbOrganization.fromOrganization(org1));
User userOrg2 = new JaxbUser("userOrg2", "default", JaxbOrganization.fromOrganization(org2));
EventComment eventComment1 = EventComment.create(none(Long.class), "event1", org1.getId(), "test", userOrg1);
EventComment eventComment2 = EventComment.create(none(Long.class), "event2", org1.getId(), "test", userOrg1);
EventComment eventComment3 = EventComment.create(none(Long.class), "event3", org2.getId(), "test", userOrg2);
persistence.updateComment(eventComment1);
persistence.updateComment(eventComment2);
persistence.updateComment(eventComment3);
Map<String, List<String>> eventsWithComments = persistence.getEventsWithComments();
assertEquals(2, eventsWithComments.keySet().size());
assertTrue(eventsWithComments.keySet().contains(org1.getId()));
assertTrue(eventsWithComments.keySet().contains(org2.getId()));
assertTrue(eventsWithComments.get(org1.getId()).contains(eventComment1.getEventId()));
assertTrue(eventsWithComments.get(org1.getId()).contains(eventComment2.getEventId()));
assertTrue(eventsWithComments.get(org2.getId()).contains(eventComment3.getEventId()));
assertFalse(eventsWithComments.get(org1.getId()).contains(eventComment3.getEventId()));
assertFalse(eventsWithComments.get(org2.getId()).contains(eventComment1.getEventId()));
assertFalse(eventsWithComments.get(org2.getId()).contains(eventComment2.getEventId()));
}
use of org.opencastproject.security.api.JaxbUser 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.JaxbUser 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.JaxbUser in project opencast by opencast.
the class WorkflowServiceSolrIndexTest method testNonAdminQuery.
/**
* Tests whether a simple query is built correctly with the authentication fragment
*/
@Test
public void testNonAdminQuery() throws Exception {
String userRole = "ROLE_USER";
User nonAdminUser = new JaxbUser("noAdmin", "test", new DefaultOrganization(), new JaxbRole(userRole, new DefaultOrganization()));
// security service
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(nonAdminUser).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
dao.setSecurityService(securityService);
WorkflowQuery q = new WorkflowQuery().withMediaPackage("123").withSeriesId("series1");
String solrQuery = dao.createQuery(q, Permissions.Action.READ.toString(), true);
String expected = "oc_org:mh_default_org AND mediapackageid:123 AND seriesid:series1 AND oc_org:" + DefaultOrganization.DEFAULT_ORGANIZATION_ID + " AND (oc_creator:" + nonAdminUser.getUsername() + " OR oc_acl_read:" + userRole + ")";
assertEquals(expected, solrQuery);
}
Aggregations