Search in sources :

Example 16 with PersonService

use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.

the class TestPeople method setUp.

@Before
public void setUp() throws Exception {
    people = publicApiClient.people();
    accountsIt = getTestFixture().getNetworksIt();
    account1 = accountsIt.next();
    account2 = accountsIt.next();
    // Networks are very expensive to create, so do this once only and store statically.
    if (account3 == null) {
        account3 = createNetwork("account3");
    }
    if (account4 == null) {
        // Use account 4 only for the sorting and paging tests, so that the data doesn't change between tests.
        account4 = createNetwork("account4");
        account4Admin = "admin@" + account4.getId();
        publicApiClient.setRequestContext(new RequestContext(account4.getId(), account4Admin, "admin"));
        personAlice = new Person();
        personAlice.setUserName("alice@" + account4.getId());
        personAlice.setId("alice@" + account4.getId());
        personAlice.setFirstName("Alice");
        personAlice.setLastName("Smith");
        personAlice.setEmail("alison.smith@example.com");
        personAlice.setPassword("password");
        personAlice.setEnabled(true);
        personAlice.setProperties(Collections.singletonMap("papi:lunch", "Magical sandwich"));
        people.create(personAlice);
        personAliceD = new Person();
        personAliceD.setUserName("aliced@" + account4.getId());
        personAliceD.setId("aliced@" + account4.getId());
        personAliceD.setFirstName("Alice");
        personAliceD.setLastName("Davis");
        personAliceD.setEmail("alison.davis@example.com");
        personAliceD.setPassword("password");
        personAliceD.setEnabled(true);
        people.create(personAliceD);
        personBen = new Person();
        personBen.setUserName("ben@" + account4.getId());
        personBen.setId("ben@" + account4.getId());
        personBen.setFirstName("Ben");
        personBen.setLastName("Carson");
        personBen.setEmail("ben.smythe@example.com");
        personBen.setPassword("password");
        personBen.setEnabled(true);
        people.create(personBen);
    }
    account1Admin = "admin@" + account1.getId();
    account2Admin = "admin@" + account2.getId();
    account3Admin = "admin@" + account3.getId();
    account1PersonIt = account1.getPersonIds().iterator();
    account2PersonIt = account2.getPersonIds().iterator();
    nodeService = applicationContext.getBean("NodeService", NodeService.class);
    personService = applicationContext.getBean("PersonService", PersonService.class);
    // Capture authentication pre-test, so we can restore it again afterwards.
    AuthenticationUtil.pushAuthentication();
}
Also used : NodeService(org.alfresco.service.cmr.repository.NodeService) PersonService(org.alfresco.service.cmr.security.PersonService) RequestContext(org.alfresco.rest.api.tests.client.RequestContext) Person(org.alfresco.rest.api.tests.client.data.Person) Before(org.junit.Before)

Aggregations

PersonService (org.alfresco.service.cmr.security.PersonService)16 NodeRef (org.alfresco.service.cmr.repository.NodeRef)8 NodeService (org.alfresco.service.cmr.repository.NodeService)7 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)7 Before (org.junit.Before)4 Serializable (java.io.Serializable)3 TestPersonManager (org.alfresco.repo.security.person.TestPersonManager)3 QName (org.alfresco.service.namespace.QName)3 ApplicationContext (org.springframework.context.ApplicationContext)3 HashMap (java.util.HashMap)2 UserTransaction (javax.transaction.UserTransaction)2 TemplateNode (org.alfresco.repo.template.TemplateNode)2 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)2 ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)2 ContentService (org.alfresco.service.cmr.repository.ContentService)2 SearchService (org.alfresco.service.cmr.search.SearchService)2 AuthenticationService (org.alfresco.service.cmr.security.AuthenticationService)2 AuthorityService (org.alfresco.service.cmr.security.AuthorityService)2 User (org.alfresco.web.bean.repository.User)2 InputStream (java.io.InputStream)1