use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testInvitationSanityCheck.
/**
* End to end sanity check of web site invitation.
*
* Nominated and Moderated invitations.
*
* @throws Exception
*/
public void testInvitationSanityCheck() throws Exception {
String shortName = GUID.generate();
String secondShortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
createSite("myPreset", secondShortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
String inviteComments = "Please sir, let me in";
String userName = USER_TWO;
String roleName = SiteModel.SITE_CONSUMER;
String inviteeFirstName = "Buffy";
String inviteeLastName = "Summers";
String inviteeEmail = "buffy@sunnydale";
String inviteeUserName = userName;
String serverPath = "http://localhost:8081/share/";
String acceptURL = "page/accept-invite";
String rejectURL = "page/reject-invite";
// Create a new moderated invitation
String moderatedId = createModeratedInvitation(secondShortName, inviteComments, userName, roleName);
// Get the moderated invitation
sendRequest(new GetRequest(URL_SITES + "/" + secondShortName + "/invitations/" + moderatedId), 200);
// search for the moderated invitation
sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + userName), 200);
// Create a nominated invitation
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201);
// Search for all invitations on this site
sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations"), 200);
// cancel the moderated invitation
sendRequest(new DeleteRequest(URL_SITES + "/" + secondShortName + "/invitations/" + moderatedId), 200);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testUpdateSite.
public void testUpdateSite() throws Exception {
// Create a site
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Update the site
result.put("title", "abs123abc");
result.put("description", "123abc123");
result.put("visibility", SiteVisibility.PRIVATE.toString());
Response response = sendRequest(new PutRequest(URL_SITES + "/" + shortName, result.toString(), "application/json"), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
assertFalse(result.getBoolean("isPublic"));
assertEquals(SiteVisibility.PRIVATE.toString(), result.get("visibility"));
// Try and get the site and double check it's changed
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
assertFalse(result.getBoolean("isPublic"));
assertEquals(SiteVisibility.PRIVATE.toString(), result.get("visibility"));
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testGetMemberInfo.
public void testGetMemberInfo() throws Exception {
String testGroup = "SiteServiceTestGroupA";
String testGroupName = "GROUP_" + testGroup;
if (!authorityService.authorityExists(testGroupName)) {
this.authenticationComponent.setSystemUserAsCurrentUser();
testGroupName = authorityService.createAuthority(AuthorityType.GROUP, testGroup, testGroup, authorityService.getDefaultZones());
}
if (!authorityService.getContainedAuthorities(AuthorityType.USER, testGroupName, true).contains(USER_TWO)) {
this.authenticationComponent.setSystemUserAsCurrentUser();
this.authorityService.addAuthority(testGroupName, USER_TWO);
}
this.authenticationComponent.setCurrentUser(USER_ONE);
// CRUD a membership group for a web site
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Build the JSON membership object
JSONObject membership = new JSONObject();
membership.put("role", SiteModel.SITE_CONSUMER);
JSONObject group = new JSONObject();
group.put("fullName", testGroupName);
membership.put("group", group);
// Create a new group membership
{
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject newMember = new JSONObject(response.getContentAsString());
// Validate the return value
assertEquals("role not correct", SiteModel.SITE_CONSUMER, newMember.getString("role"));
JSONObject newGroup = newMember.getJSONObject("authority");
assertNotNull(newGroup);
assertEquals("full name not correct", testGroupName, newGroup.getString("fullName"));
assertEquals("authorityType not correct", "GROUP", newGroup.getString("authorityType"));
}
// Now List memberships
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "?authorityType=USER"), 200);
JSONArray listResult = new JSONArray(response.getContentAsString());
assertNotNull(listResult);
assertEquals(2, listResult.length());
for (int i = 0; i < listResult.length(); i++) {
JSONObject json = listResult.getJSONObject(i);
if (USER_ONE.equals(json.getJSONObject("authority").get("fullName"))) {
assertEquals("user one is Not member of any group", false, json.get("isMemberOfGroup"));
} else {
assertEquals("full name not correct", USER_TWO, json.getJSONObject("authority").get("fullName"));
assertEquals("user two is member of a SiteServiceTestGroupA group", true, json.get("isMemberOfGroup"));
}
}
}
// cleanup
if (authorityService.authorityExists(testGroupName)) {
this.authenticationComponent.setSystemUserAsCurrentUser();
this.authorityService.deleteAuthority(testGroupName);
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testDeleteSite.
public void testDeleteSite() throws Exception {
// Delete non-existent site
sendRequest(new DeleteRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Get the site
sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
// Delete the site
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 200);
// Get the site
sendRequest(new GetRequest(URL_SITES + "/" + shortName), 404);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testGetSite.
public void testGetSite() throws Exception {
// Get a site that doesn't exist
sendRequest(new GetRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site and get it
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
}
Aggregations