use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class DictionaryRestApiTest method testGetClasses.
public void testGetClasses() throws Exception {
GetRequest req = new GetRequest(URL_SITES);
Response response = sendRequest(req, 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertTrue(result.length() > 0);
assertEquals(200, response.getStatus());
validatePropertiesConformity(result);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class DictionaryRestApiTest method testGetClassDetail.
public void testGetClassDetail() throws Exception {
GetRequest req = new GetRequest(URL_SITES + "/cm/thumbnailed");
Response response = sendRequest(req, 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertEquals(result.length() > 0, true);
assertEquals(200, response.getStatus());
validateAspectClass(result);
req = new GetRequest(URL_SITES + "/cm/cmobject");
response = sendRequest(req, 200);
result = new JSONObject(response.getContentAsString());
assertEquals(result.length() > 0, true);
assertEquals(200, response.getStatus());
validateTypeClass(result);
response = sendRequest(new GetRequest("/api/defclasses/cm/hi"), 404);
assertEquals(404, response.getStatus());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class DiscussionRestApiTest method checkForumPermissions.
private void checkForumPermissions(String siteName) throws Exception {
String url = "/api/forum/site/" + siteName + "/" + COMPONENT_DISCUSSION + "/posts";
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertTrue("The user sould have permission to create a new discussion.", result.getJSONObject("forumPermissions").getBoolean("create"));
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class DownloadRestApiTest method testCreateAndGetDownload.
@Test
public void testCreateAndGetDownload() throws UnsupportedEncodingException, IOException, JSONException {
// CReate the download
String postData = "[{ \"nodeRef\": \"" + rootFile + "\"}, { \"nodeRef\": \"" + rootFolder + "\"}]";
Response response = sendRequest(new PostRequest(URL_DOWNLOADS, postData, "application/json"), 200);
// Parse the response
JSONObject result = new JSONObject(response.getContentAsString());
NodeRef downloadNodeRef = new NodeRef(result.getString("nodeRef"));
// Get the status
String statusUrl = MessageFormat.format(URL_DOWNLOAD_STATUS, downloadNodeRef.getStoreRef().getProtocol(), downloadNodeRef.getStoreRef().getIdentifier(), downloadNodeRef.getId());
Response statusResponse = sendRequest(new GetRequest(statusUrl), 200);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class FacetRestApiTest method testNonSearchAdminUserCannotCreateUpdateSolrFacets.
public void testNonSearchAdminUserCannotCreateUpdateSolrFacets() throws Exception {
// Create a filter
final JSONObject filter = new JSONObject();
final String filterName = "filter" + System.currentTimeMillis();
filters.add(filterName);
filter.put("filterID", filterName);
filter.put("facetQName", "cm:test1");
filter.put("displayName", "facet-menu.facet.test1");
filter.put("displayControl", "alfresco/search/FacetFilters/test1");
filter.put("maxFilters", 5);
filter.put("hitThreshold", 1);
filter.put("minFilterValueLength", 4);
filter.put("sortBy", "ALPHABETICALLY");
// Non-Search-Admin tries to create a filter
AuthenticationUtil.runAs(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
// Post the filter
sendRequest(new PostRequest(POST_FACETS_URL, filter.toString(), "application/json"), 403);
return null;
}
}, NON_SEARCH_ADMIN_USER);
// Search-Admin creates a filter
AuthenticationUtil.runAs(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
// Post the filter
sendRequest(new PostRequest(POST_FACETS_URL, filter.toString(), "application/json"), 200);
return null;
}
}, SEARCH_ADMIN_USER);
// Non-Search-Admin tries to modify the filter
AuthenticationUtil.runAs(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
Response response = sendRequest(new GetRequest(GET_FACETS_URL + "/" + filterName), 200);
JSONObject jsonRsp = new JSONObject(new JSONTokener(response.getContentAsString()));
assertEquals(filterName, jsonRsp.getString("filterID"));
assertEquals(5, jsonRsp.getInt("maxFilters"));
// Now change the maxFilters value and try to update
jsonRsp.put("maxFilters", 10);
sendRequest(new PutRequest(PUT_FACETS_URL, jsonRsp.toString(), "application/json"), 403);
return null;
}
}, NON_SEARCH_ADMIN_USER);
}
Aggregations