use of org.alfresco.rest.api.tests.client.RequestContext in project alfresco-remote-api by Alfresco.
the class TestPeople method testUpdatePersonEnabledNonAdminNotAllowed.
@Test
public void testUpdatePersonEnabledNonAdminNotAllowed() throws PublicApiException {
final String personId = account3.createUser().getId();
publicApiClient.setRequestContext(new RequestContext(account3.getId(), personId));
people.update("people", personId, null, null, "{\n" + " \"enabled\": \"false\"\n" + "}", null, "Expected 403 response when updating " + personId, 403);
}
use of org.alfresco.rest.api.tests.client.RequestContext in project alfresco-remote-api by Alfresco.
the class TestPeople method testUpdatePersonUsingPartialUpdate.
@Test
public void testUpdatePersonUsingPartialUpdate() throws PublicApiException {
final String personId = account3.createUser().getId();
publicApiClient.setRequestContext(new RequestContext(account3.getId(), account3Admin, "admin"));
String updatedFirstName = "Updated firstName";
HttpResponse response = people.update("people", personId, null, null, "{\n" + " \"firstName\": \"" + updatedFirstName + "\"\n" + "}", null, "Expected 200 response when updating " + personId, 200);
Person updatedPerson = Person.parsePerson((JSONObject) response.getJsonResponse().get("entry"));
assertEquals(updatedFirstName, updatedPerson.getFirstName());
}
use of org.alfresco.rest.api.tests.client.RequestContext in project alfresco-remote-api by Alfresco.
the class TestPeople method testUpdatePersonCanUpdateThemself.
@Test
public void testUpdatePersonCanUpdateThemself() throws PublicApiException {
final String personId = account1PersonIt.next();
publicApiClient.setRequestContext(new RequestContext(account1.getId(), personId));
// Explicitly using the person's ID
{
Person updatedPerson = people.update(personId, qjson("{ `firstName`: `Matt` }"), 200);
assertEquals("Matt", updatedPerson.getFirstName());
}
// "-me-" user
{
Person updatedPerson = people.update("-me-", qjson("{ `firstName`: `John` }"), 200);
assertEquals("John", updatedPerson.getFirstName());
}
// TODO: temp fix, set back to orig firstName
publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin"));
people.update(personId, qjson("{ `firstName`:`Bill` }"), 200);
// -ve test: check that required/mandatory/non-null fields cannot be unset (or empty string)
{
people.update("people", personId, null, null, qjson("{ `firstName`:`` }"), null, "Expected 400 response when updating " + personId, 400);
people.update("people", personId, null, null, qjson("{ `email`:`` }"), null, "Expected 400 response when updating " + personId, 400);
people.update("people", personId, null, null, qjson("{ `emailNotificationsEnabled`:`` }"), null, "Expected 400 response when updating " + personId, 400);
}
}
use of org.alfresco.rest.api.tests.client.RequestContext in project alfresco-remote-api by Alfresco.
the class TestPeople method testPagingAndSortingByFirstNameAsc.
/**
* Tests the capability to sort and paginate the list of people orderBy =
* firstName ASC skip = 1, count = 3
*
* @throws Exception
*/
@Test
public void testPagingAndSortingByFirstNameAsc() throws Exception {
publicApiClient.setRequestContext(new RequestContext(account4.getId(), account4Admin, "admin"));
// paging
int skipCount = 1;
int maxItems = 3;
int totalResults = 5;
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
// orderBy=firstName ASC
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName", true, 200);
List<Person> expectedList = new LinkedList<>();
expectedList.add(personAlice);
expectedList.add(personAliceD);
expectedList.add(personBen);
checkList(expectedList, paging.getExpectedPaging(), resp);
}
use of org.alfresco.rest.api.tests.client.RequestContext in project alfresco-remote-api by Alfresco.
the class TestPeople method testPagingAndSortingByFirstNameAndLastName.
/**
* Tests the capability to sort and paginate the list of people orderBy =
* both firstName and lastName ASC skip = 1, count = 3
*
* @throws Exception
*/
@Test
public void testPagingAndSortingByFirstNameAndLastName() throws Exception {
publicApiClient.setRequestContext(new RequestContext(account4.getId(), account4Admin, "admin"));
// paging
int skipCount = 1;
int maxItems = 3;
int totalResults = 5;
PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
// orderBy=firstName,lastName ASC
PublicApiClient.ListResponse<Person> resp = listPeople(paging, "firstName,lastName", true, 200);
List<Person> expectedList = new LinkedList<>();
expectedList.add((Person) personAliceD);
expectedList.add((Person) personAlice);
expectedList.add((Person) personBen);
checkList(expectedList, paging.getExpectedPaging(), resp);
}
Aggregations