mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
* ACS-1830 - Test requestContentDirectUrl for Nodes REST API endpoint -add test for RequestContentDirectUrl -update the license headers to 2021 Co-authored-by: Iulian Aftene <iulian.aftene@ness.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -68,6 +68,7 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
|
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -136,6 +137,8 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
|||||||
protected static PersonService personService;
|
protected static PersonService personService;
|
||||||
|
|
||||||
protected final String RUNID = System.currentTimeMillis()+"";
|
protected final String RUNID = System.currentTimeMillis()+"";
|
||||||
|
|
||||||
|
private static final String REQUEST_NODE_DIRECT_ACCESS_URL = "requestNodeDirectAccessUrl";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
@@ -211,6 +214,11 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
|||||||
setRequestContext(null);
|
setRequestContext(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getRequestContentDirectUrl(String nodeId)
|
||||||
|
{
|
||||||
|
return URL_NODES + "/" + nodeId + "/" + REQUEST_NODE_DIRECT_ACCESS_URL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The api scope. either public or private
|
* The api scope. either public or private
|
||||||
*
|
*
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -6250,5 +6250,33 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertFalse((Boolean) constraintParameters.get("requiresMatch"));
|
assertFalse((Boolean) constraintParameters.get("requiresMatch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequestContentDirectUrl() throws Exception
|
||||||
|
{
|
||||||
|
setRequestContext(user1);
|
||||||
|
|
||||||
|
// Use existing test file
|
||||||
|
String fileName = "quick-1.txt";
|
||||||
|
File file = getResourceFile(fileName);
|
||||||
|
|
||||||
|
MultiPartBuilder multiPartBuilder = MultiPartBuilder.create().setFileData(new MultiPartBuilder.FileData(fileName, file));
|
||||||
|
MultiPartBuilder.MultiPartRequest reqBody = multiPartBuilder.build();
|
||||||
|
|
||||||
|
// Upload text content
|
||||||
|
HttpResponse response = post(getNodeChildrenUrl(Nodes.PATH_MY), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||||
|
Document document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||||
|
|
||||||
|
final String contentNodeId = document.getId();
|
||||||
|
|
||||||
|
// Check the upload response
|
||||||
|
assertEquals(fileName, document.getName());
|
||||||
|
ContentInfo contentInfo = document.getContent();
|
||||||
|
assertNotNull(contentInfo);
|
||||||
|
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentInfo.getMimeType());
|
||||||
|
|
||||||
|
|
||||||
|
getSingle(getRequestContentDirectUrl(contentNodeId), null, null, null, 405);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user