Search in sources :

Example 61 with SecurityService

use of org.opencastproject.security.api.SecurityService in project opencast by opencast.

the class TestSearchIndex method createSecurityService.

public static final SecurityService createSecurityService(DefaultOrganization organization) {
    JaxbUser creator = new JaxbUser("creator", "password", "Creator", null, "test", organization, new HashSet<JaxbRole>());
    SecurityService securityService = createNiceMock(SecurityService.class);
    expect(securityService.getOrganization()).andReturn(organization).anyTimes();
    expect(securityService.getUser()).andReturn(creator).anyTimes();
    replay(securityService);
    return securityService;
}
Also used : JaxbRole(org.opencastproject.security.api.JaxbRole) SecurityService(org.opencastproject.security.api.SecurityService) JaxbUser(org.opencastproject.security.api.JaxbUser)

Example 62 with SecurityService

use of org.opencastproject.security.api.SecurityService in project opencast by opencast.

the class SchedulerMessageReceiverImplTest method setUp.

@Before
public void setUp() throws Exception {
    SecurityService securityService = TestSearchIndex.createSecurityService(new DefaultOrganization());
    scheduler = new SchedulerMessageReceiverImpl();
    scheduler.setSecurityService(securityService);
    scheduler.setSearchIndex(index);
}
Also used : SecurityService(org.opencastproject.security.api.SecurityService) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Before(org.junit.Before)

Example 63 with SecurityService

use of org.opencastproject.security.api.SecurityService in project opencast by opencast.

the class EventCommentDatabaseImplTest method setUp.

@Before
public void setUp() throws Exception {
    UserDirectoryService userDirectoryService = EasyMock.createNiceMock(UserDirectoryService.class);
    EasyMock.expect(userDirectoryService.loadUser(EasyMock.anyObject(String.class))).andReturn(USER).anyTimes();
    EasyMock.replay(userDirectoryService);
    SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
    EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
    EasyMock.replay(securityService);
    MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
    EasyMock.replay(messageSender);
    persistence = new EventCommentDatabaseServiceImpl();
    persistence.setEntityManagerFactory(newTestEntityManagerFactory(PERSISTENCE_UNIT));
    persistence.setUserDirectoryService(userDirectoryService);
    persistence.setMessageSender(messageSender);
    persistence.setSecurityService(securityService);
    persistence.activate(null);
}
Also used : SecurityService(org.opencastproject.security.api.SecurityService) MessageSender(org.opencastproject.message.broker.api.MessageSender) UserDirectoryService(org.opencastproject.security.api.UserDirectoryService) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Before(org.junit.Before)

Example 64 with SecurityService

use of org.opencastproject.security.api.SecurityService in project opencast by opencast.

the class TestEventsEndpoint method setupSecurityService.

private void setupSecurityService() {
    // Prepare mocked security service
    SecurityService securityService = createNiceMock(SecurityService.class);
    expect(securityService.getOrganization()).andStubReturn(defaultOrg);
    // Replay mocked objects
    replay(securityService);
    setSecurityService(securityService);
}
Also used : SecurityService(org.opencastproject.security.api.SecurityService)

Example 65 with SecurityService

use of org.opencastproject.security.api.SecurityService in project opencast by opencast.

the class OaiPmhPersistenceTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    // Mock up a security service
    SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
    User user = SecurityUtil.createSystemUser("admin", new DefaultOrganization());
    EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
    EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
    EasyMock.replay(securityService);
    mp1 = MediaPackageSupport.loadFromClassPath("/mp1.xml");
    mp2 = MediaPackageSupport.loadFromClassPath("/mp2.xml");
    Workspace workspace = EasyMock.createNiceMock(Workspace.class);
    EasyMock.expect(workspace.read(uri("series-dublincore.xml"))).andAnswer(() -> getClass().getResourceAsStream("/series-dublincore.xml")).anyTimes();
    EasyMock.expect(workspace.read(uri("episode-dublincore.xml"))).andAnswer(() -> getClass().getResourceAsStream("/episode-dublincore.xml")).anyTimes();
    EasyMock.expect(workspace.read(uri("mpeg7.xml"))).andAnswer(() -> getClass().getResourceAsStream("/mpeg7.xml")).anyTimes();
    EasyMock.expect(workspace.read(uri("series-xacml.xml"))).andAnswer(() -> getClass().getResourceAsStream("/series-xacml.xml")).anyTimes();
    EasyMock.replay(workspace);
    oaiPmhDatabase = new OaiPmhDatabaseImpl();
    oaiPmhDatabase.setEntityManagerFactory(newTestEntityManagerFactory(OaiPmhDatabaseImpl.PERSISTENCE_UNIT_NAME));
    oaiPmhDatabase.setSecurityService(securityService);
    oaiPmhDatabase.setWorkspace(workspace);
    oaiPmhDatabase.activate(null);
}
Also used : User(org.opencastproject.security.api.User) SecurityService(org.opencastproject.security.api.SecurityService) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Aggregations

SecurityService (org.opencastproject.security.api.SecurityService)99 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)62 Before (org.junit.Before)55 JaxbUser (org.opencastproject.security.api.JaxbUser)44 User (org.opencastproject.security.api.User)43 JaxbRole (org.opencastproject.security.api.JaxbRole)39 Organization (org.opencastproject.security.api.Organization)31 Test (org.junit.Test)30 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)29 UserDirectoryService (org.opencastproject.security.api.UserDirectoryService)29 Workspace (org.opencastproject.workspace.api.Workspace)29 MediaPackage (org.opencastproject.mediapackage.MediaPackage)22 InputStream (java.io.InputStream)21 URI (java.net.URI)21 File (java.io.File)20 ArrayList (java.util.ArrayList)20 ServiceRegistryInMemoryImpl (org.opencastproject.serviceregistry.api.ServiceRegistryInMemoryImpl)18 MessageSender (org.opencastproject.message.broker.api.MessageSender)16 AuthorizationService (org.opencastproject.security.api.AuthorizationService)16 IOException (java.io.IOException)15