Files
alfresco-community-repo/source/test-java/org/alfresco/rest/api/tests/TestPeople.java
Raluca Munteanu 386a4aca06 Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-04-26 13:03:25 +00:00

90 lines
3.3 KiB
Java

package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.rest.api.tests.RepoService.SiteInformation;
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
import org.alfresco.rest.api.tests.RepoService.TestSite;
import org.alfresco.rest.api.tests.client.PublicApiClient.People;
import org.alfresco.rest.api.tests.client.PublicApiException;
import org.alfresco.rest.api.tests.client.RequestContext;
import org.alfresco.rest.api.tests.client.data.Person;
import org.alfresco.rest.api.tests.client.data.SiteRole;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.apache.commons.httpclient.HttpStatus;
import org.junit.Test;
public class TestPeople extends EnterpriseTestApi
{
@Test
public void testPeople() throws Exception
{
Iterator<TestNetwork> accountsIt = getTestFixture().getNetworksIt();
final TestNetwork account1 = accountsIt.next();
Iterator<String> personIt1 = account1.getPersonIds().iterator();
final String person1 = personIt1.next();
final String person2 = personIt1.next();
final TestNetwork account2 = accountsIt.next();
Iterator<String> personIt2 = account2.getPersonIds().iterator();
final String person3 = personIt2.next();
People peopleProxy = publicApiClient.people();
// Test Case cloud-2192
// should be able to see oneself
{
publicApiClient.setRequestContext(new RequestContext(account1.getId(), person1));
Person resp = peopleProxy.getPerson(person1);
Person person1Entity = repoService.getPerson(person1);
check(person1Entity, resp);
}
// should be able to see another user in the same domain, and be able to see full profile
{
publicApiClient.setRequestContext(new RequestContext(account1.getId(), person2));
Person resp = peopleProxy.getPerson(person1);
Person person1Entity = repoService.getPerson(person1);
check(person1Entity, resp);
}
// "-me-" user
{
publicApiClient.setRequestContext(new RequestContext(account1.getId(), person1));
Person resp = peopleProxy.getPerson(org.alfresco.rest.api.People.DEFAULT_USER);
Person person1Entity = repoService.getPerson(person1);
check(person1Entity, resp);
}
// shouldn't be able to see another user in another domain
publicApiClient.setRequestContext(new RequestContext(account1.getId(), person3));
try
{
peopleProxy.getPerson(person1);
fail("");
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getHttpResponse().getStatusCode());
}
RepoService.TestPerson testP = account1.createUser();
String personId = testP.getId();
String desc = "<B>Nice person</B>";
account1.addUserDescription(personId, desc);
publicApiClient.setRequestContext(new RequestContext(account1.getId(), personId));
Person resp = publicApiClient.people().getPerson(personId);
assertEquals(resp.getId(), personId);
assertEquals(resp.getDescription(), desc);
}
}