Compare commits

...

10 Commits

Author SHA1 Message Date
Travis CI User
ea3ac8166d [maven-release-plugin][skip ci]prepare release acs-community-packaging-6.2.2-RC1 2020-10-22 11:02:18 +00:00
Denis Ungureanu
3503b8e45f MNT-21871 : [Security] Multiple jackson-databind vulnerabilities (#1077)
- jackson upgrade to 2.10.5
   - upgrade alfresco libraries
   - print the last 200 lines from alfresco.log when alfresco (docker container) does not start
   - add metadata keystore properties in the docker compose files
   - add keystore file as distribution resource (only for tests)
   - copy keystore into the alfresco docker file
   - exclude baseDir from the distribution archive
   - include distribution module to the communityDocker maven profile - its target is used by the docker-alfresco module to create the docker image
2020-10-14 15:00:23 +03:00
Alexandru-Eusebiu Epure
28ef9bb0d5 ATS-825 : Updated T-engines to 2.3.5 (#1050) 2020-09-28 12:23:55 +03:00
CezarLeahu
2ccf55c81d ACS-550 Update *latest* image from the *develop* branch (Quay&DockerHub) 2020-09-04 15:55:17 +03:00
Angel Borroy
fc77880b0c SEARCH-2258: Update Search Services to 2.0.0 (#1008) 2020-08-21 19:05:39 +02:00
Ayman Harake
6be05950ec ATS-817: Updated T-engines to 2.3.4 (#982) 2020-08-07 09:36:24 +01:00
Ayman Harake
9c027929a9 ATS-811: Updated T-engines to 2.3.3 (#975) 2020-08-04 08:46:29 +01:00
Erik Knizat
50be336cea REPO-5235: Unfork tika
* use alf-repo and alf-data-model with unforked tika and enforce the same version of gson as what tika uses
2020-07-27 16:42:27 +01:00
Alexandru-Eusebiu Epure
66664d40de MNT-21602 : Revive DownloadContentServlet.java (#910)
* MNT-21602 : Revive DownloadContentServlet.java
   Remove doHEAD method from DownloadContentServlet
   doGET method now redirects to V1 REST - GET /nodes/{nodeId}
   Removed leftover org.alfresco.web.app.servlet.UploadContentServlet, org.alfresco.web.app.servlet.DownloadRawContentServlet and org.alfresco.web.app.servlet.GuestDownloadContentServlet from web.xml as those servlet implementation does not exist.
   Refactor javadoc.
   Add TAS tests to Rest-API/DownloadContentServletTests class
   Restrict DownloadContentServlet to allow only nodes from the workspace://SpacesStore/

* Add downloadContentServlet mapping in web.xml
2020-07-08 14:31:16 +03:00
Nebil Kisa
2ed4dc48ce ACS-386 - Update ACS projects to PotgreSQL v11.7 (#902) 2020-07-07 13:33:18 +01:00
23 changed files with 552 additions and 33 deletions

View File

@@ -27,6 +27,8 @@ branches:
stages:
- name: test
if: commit_message !~ /\[skip tests\]/
- name: docker_latest
if: fork = false AND type != pull_request AND branch = develop
- release
- publish
@@ -101,6 +103,11 @@ jobs:
- ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
script:
- travis_wait 30 mvn install -q -f tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
- stage: docker_latest
name: "Update Docker latest images"
script: travis_retry travis_wait 30 mvn -B -V clean install -DskipTests -Dmaven.javadoc.skip=true -Pmaster
- stage: Release
name: "Maven release"
if: commit_message ~= /\[release\]/ AND fork = false AND branch =~ ^(master|develop)$ AND type != pull_request

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -75,6 +75,14 @@
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>keystore/**</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources/keystore</directory>
<targetPath>keystore</targetPath>
<filtering>false</filtering>
</resource>
</resources>
<plugins>

View File

@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>

View File

@@ -14,6 +14,7 @@ ARG TOMCAT_DIR=/usr/local/tomcat
# Create prerequisite to store tools and properties
RUN mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension && \
mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore && \
mkdir ${TOMCAT_DIR}/alfresco-mmt
RUN touch ${TOMCAT_DIR}/shared/classes/alfresco-global.properties
@@ -68,6 +69,9 @@ RUN yum install -y fontconfig-2.13.0-4.3.el7 \
dejavu-sans-fonts-2.33-6.el7 && \
yum clean all
# Copy default keystore
COPY target/distribution/keystore/metadata-keystore/keystore ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore/
# The standard configuration is to have all Tomcat files owned by root with group GROUPNAME and whilst owner has read/write privileges,
# group only has restricted permissions and world has no permissions.
RUN mkdir -p ${TOMCAT_DIR}/conf/Catalina/localhost && \

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -145,6 +145,13 @@
<type>war</type>
<outputDirectory>${project.build.directory}/war/_vti_bin</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-content-services-community-distribution</artifactId>
<version>${project.version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}/distribution</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>

27
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>acs-community-packaging</artifactId>
<name>Alfresco Content Services Community Packaging</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>pom</packaging>
<parent>
@@ -15,7 +15,7 @@
<connection>scm:git:https://github.com/Alfresco/acs-community-packaging.git</connection>
<developerConnection>scm:git:https://github.com/Alfresco/acs-community-packaging.git</developerConnection>
<url>https://github.com/Alfresco/acs-community-packaging</url>
<tag>HEAD</tag>
<tag>acs-community-packaging-6.2.2-RC1</tag>
</scm>
<distributionManagement>
@@ -34,10 +34,10 @@
<version.edition>Community</version.edition>
<image.tag>latest</image.tag>
<dependency.alfresco-remote-api.version>7.147</dependency.alfresco-remote-api.version>
<dependency.alfresco-repository.version>7.200</dependency.alfresco-repository.version>
<dependency.alfresco-data-model.version>8.50.18</dependency.alfresco-data-model.version>
<dependency.alfresco-core.version>7.34</dependency.alfresco-core.version>
<dependency.alfresco-remote-api.version>7.156</dependency.alfresco-remote-api.version>
<dependency.alfresco-repository.version>7.219</dependency.alfresco-repository.version>
<dependency.alfresco-data-model.version>8.50.21</dependency.alfresco-data-model.version>
<dependency.alfresco-core.version>7.35</dependency.alfresco-core.version>
<dependency.alfresco-hb-data-sender.version>1.0.12</dependency.alfresco-hb-data-sender.version>
@@ -53,8 +53,8 @@
<dependency.spring.version>5.1.15.RELEASE</dependency.spring.version>
<dependency.fabric8.version>4.4.0</dependency.fabric8.version>
<dependency.jackson.version>2.10.2</dependency.jackson.version>
<dependency.jackson-databind.version>2.10.1</dependency.jackson-databind.version>
<dependency.jackson.version>2.10.5</dependency.jackson.version>
<dependency.jackson-databind.version>2.10.5</dependency.jackson-databind.version>
<dependency.cxf.version>3.3.6</dependency.cxf.version>
<!-- Alfresco Share version -->
@@ -71,7 +71,7 @@
<alfresco.package.name>alfresco-community</alfresco.package.name>
<alfresco.distribution.name>${alfresco.package.name}-distribution</alfresco.distribution.name>
<dependency.postgresql.version>42.2.12</dependency.postgresql.version>
<dependency.postgresql.version>42.2.14</dependency.postgresql.version>
<dependency.tas-utility.version>3.0.20</dependency.tas-utility.version>
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
@@ -97,6 +97,7 @@
<id>communityDocker</id>
<modules>
<module>war</module>
<module>distribution</module>
<module>docker-alfresco</module>
</modules>
</profile>
@@ -548,11 +549,11 @@
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<!-- Newer metadata-extractor, used in TIKA, see ACS-370 -->
<!--REPO-5235 -->
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.13.0</version>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>

View File

@@ -1,4 +1,4 @@
TRANSFORMERS_TAG=2.3.1
SOLR6_TAG=1.4.2
POSTGRES_TAG=11.4
TRANSFORMERS_TAG=2.3.5
SOLR6_TAG=2.0.0
POSTGRES_TAG=11.7
ACTIVEMQ_TAG=5.15.8

View File

@@ -11,6 +11,16 @@ services:
environment:
CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
# Some properties are built in Dockerfile because of cron expressions
JAVA_TOOL_OPTIONS: "
-Dencryption.keystore.type=JCEKS
-Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
-Dencryption.keyAlgorithm=DESede
-Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=oKIWzVdEdA
-Dmetadata-keystore.metadata.algorithm=DESede
"
JAVA_OPTS :
"
-Ddb.driver=org.postgresql.Driver

View File

@@ -10,6 +10,16 @@ services:
image: alfresco/alfresco-content-repository-community:latest
environment:
CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
JAVA_TOOL_OPTIONS: "
-Dencryption.keystore.type=JCEKS
-Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
-Dencryption.keyAlgorithm=DESede
-Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=oKIWzVdEdA
-Dmetadata-keystore.metadata.algorithm=DESede
"
JAVA_OPTS :
"
-Ddb.driver=org.postgresql.Driver

View File

@@ -1,13 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>pom</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -27,5 +27,9 @@ if (("$COUNTER" < "$TIMEOUT")) ; then
else
echo "Waited $COUNTER seconds"
echo "Alfresco Could not start in time."
docker ps -a
ALFCONTAINER=`docker ps -a | grep _alfresco | awk '{ print $1 }'`
echo "Last 200 lines from alfresco.log on container $ALFCONTAINER:"
docker logs --tail=200 $ALFCONTAINER
exit 1
fi

View File

@@ -4,13 +4,13 @@
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-cmis-test</artifactId>
<name>content-repository-community-cmis-test</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -4,13 +4,13 @@
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-email-test</artifactId>
<name>content-repository-community-email-test</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -4,13 +4,13 @@
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-integration-test</artifactId>
<name>content-repository-community-integration-test</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -4,13 +4,13 @@
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-restapi-test</artifactId>
<name>content-repository-community-restapi-test</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -0,0 +1,324 @@
package org.alfresco.rest.servlet;
import io.restassured.RestAssured;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestRequest;
import org.alfresco.rest.core.RestResponse;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.commons.codec.binary.Base64;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
public class DownloadContentServletTests extends RestTest
{
private static final String CONTENT_DISPOSITION = "Content-Disposition";
private static final String FILENAME_HEADER = "filename=\"%s\"";
private static final String ATTACHMENT = "attachment";
private static final String FILE_CONTENT = "The content of the file.";
private static String downloadContentServletAttach = "alfresco/d/a/workspace/SpacesStore/";
private static String downloadContentServletDirect = "alfresco/d/d/workspace/SpacesStore/";
private UserModel testUser;
private FileModel testContentFile;
private String authHeaderEncoded;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
SiteModel testSite = dataSite.usingUser(testUser).createPublicRandomSite();
FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
testContentFile = dataContent.usingUser(testUser).usingResource(testFolder)
.createContent(new FileModel("hotOuside", FileType.TEXT_PLAIN, FILE_CONTENT));
String authHeader = String.format("%s:%s", testUser.getUsername(), testUser.getPassword());
authHeaderEncoded = new String(Base64.encodeBase64(authHeader.getBytes()));
RestAssured.basePath = "";
restClient.configureRequestSpec().setBasePath(RestAssured.basePath);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and attach short descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortAttachShort()
{
authenticateTestUser();
RestRequest request = RestRequest.simpleRequest(
HttpMethod.GET, downloadContentServletAttach + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and attach long descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortAttachLong()
{
authenticateTestUser();
String downloadContentServletAttachLong = "alfresco/d/attach/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentServletAttachLong + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and direct short descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortDirectShort()
{
authenticateTestUser();
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentServletDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and direct long descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortDirectLong()
{
authenticateTestUser();
String downloadContentServletDirectLong = "alfresco/d/direct/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentServletDirectLong + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using long descriptor and attach short descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSLongAttachShort()
{
authenticateTestUser();
String downloadContentLongServletAttach = "alfresco/download/a/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLongServletAttach + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using long descriptor and attach long descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSLongAttachLong()
{
authenticateTestUser();
String downloadContentLongServletAttachLong = "alfresco/download/attach/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLongServletAttachLong + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using long descriptor and direct short descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSLongDirectShort()
{
authenticateTestUser();
String downloadContentLongServletDirect = "alfresco/download/d/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLongServletDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using long descriptor and direct long descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSLongDirectLong()
{
authenticateTestUser();
String downloadContentLongServletDirectLong = "alfresco/download/direct/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLongServletDirectLong + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and attach short uppercase descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortAttachUppercaseShort()
{
authenticateTestUser();
String downloadContentAttachUppercase = "alfresco/d/A/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentAttachUppercase + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using short descriptor and direct short uppercase descriptor.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSShortDirectUppercaseShort()
{
authenticateTestUser();
String downloadContentDirectUppercase = "alfresco/d/D/workspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentDirectUppercase + testContentFile.getNodeRef() + "/" + testContentFile.getName());
RestResponse response = restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.OK);
assertEquals(FILE_CONTENT, response.getResponse().body().asString());
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, ATTACHMENT);
restClient.assertHeaderValueContains(CONTENT_DISPOSITION, String.format(FILENAME_HEADER, testContentFile.getName()));
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using attach without specifying {storeType}.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSAttachWithoutStoreType()
{
authenticateTestUser();
String downloadContentLessPathAttach = "alfresco/d/a/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLessPathAttach + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using direct without specifying {storeType}.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSDirectWithoutStoreType()
{
authenticateTestUser();
String downloadContentLessPathDirect = "alfresco/d/d/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLessPathDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using direct without specifying {storeType}.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSDirectWithInvalidStoreType()
{
authenticateTestUser();
String downloadContentLessPathDirect = "alfresco/download/d/badWorkspace/SpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLessPathDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using direct without specifying {storeType}.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSDirectWithInvalidStoreId()
{
authenticateTestUser();
String downloadContentLessPathDirect = "alfresco/download/d/workspace/badSpacesStore/";
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentLessPathDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using attach without authentication.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSAttachWithoutAuthentication()
{
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentServletAttach + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@TestRail(section = { TestGroup.REST_API },
executionType = ExecutionType.REGRESSION,
description = "Verify DownloadContentServlet retrieve content using direct without authentication.")
@Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.ENTERPRISE})
@Bug(id ="MNT-21602", status=Bug.Status.FIXED)
public void verifyDCSDirectWithoutAuthentication()
{
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET,
downloadContentServletDirect + testContentFile.getNodeRef() + "/" + testContentFile.getName());
restClient.process(request);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
private void authenticateTestUser()
{
restClient.configureRequestSpec()
.addHeader("Authorization", String.format("Basic %s", authHeaderEncoded))
.build();
}
}

View File

@@ -14,6 +14,7 @@
<package name="org.alfresco.rest.comments.*"/>
<package name="org.alfresco.rest.downloads.*"/>
<package name="org.alfresco.rest.favorites.*"/>
<package name="org.alfresco.rest.servlet.*"/>
</packages>
</test>
</suite>

View File

@@ -4,13 +4,13 @@
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-webdav-test</artifactId>
<name>content-repository-community-webdav-test</name>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.2.2-SNAPSHOT</version>
<version>6.2.2-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -0,0 +1,128 @@
/*
* #%L
* Alfresco Repository WAR Community
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.web.app.servlet;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.URLDecoder;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Servlet responsible for streaming node content from the repo directly to the response stream.
* The appropriate mimetype is calculated based on filename extension.
* <p>
* The URL to the servlet should be generated thus:
* <pre>/alfresco/download/attach/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf</pre>
* or
* <pre>/alfresco/download/direct/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf</pre></p>
* <p>
* The 'attach' or 'direct' element is used to indicate whether to display the stream directly
* in the browser or download it as a file attachment.</p>
* <p>
* Since ACS 6.X, this Servlet redirects to GET /nodes/{nodeId}/content V1 REST API.
*
*
* @author Kevin Roast
* @author gavinc
*/
public class DownloadContentServlet extends HttpServlet
{
private static final long serialVersionUID = -576405943603122206L;
private static Log logger = LogFactory.getLog(DownloadContentServlet.class);
private static final String URL_ATTACH = "a";
private static final String URL_ATTACH_LONG = "attach";
private static final String URL_DIRECT = "d";
private static final String URL_DIRECT_LONG = "direct";
/**
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest, HttpServletResponse)
*/
protected void doGet(final HttpServletRequest req, final HttpServletResponse res)
throws IOException
{
if (logger.isDebugEnabled())
{
String queryString = req.getQueryString();
logger.debug("Authenticating (GET) request to URL: " + req.getRequestURI() +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
// remove request context.
String requestURI = req.getRequestURI();
requestURI = requestURI.substring(req.getContextPath().length());
StringTokenizer t = new StringTokenizer(requestURI, "/");
int tokenCount = t.countTokens();
t.nextToken(); // skip servlet name
// expect a minimum of 6 URL tokens.
// /d/{attach|direct}/{storeType}/{storeId}/{nodeId}/{nodeName}
if(tokenCount < 6)
{
throw new IllegalArgumentException("Download URL did not contain all required args: " + requestURI);
}
// attachment mode (either 'attach' or 'direct')
String attachToken = t.nextToken();
boolean isAttachment = URL_ATTACH.equalsIgnoreCase(attachToken) || URL_ATTACH_LONG.equalsIgnoreCase(attachToken);
boolean isDirect = URL_DIRECT.equalsIgnoreCase(attachToken) || URL_DIRECT_LONG.equalsIgnoreCase(attachToken);
if (!(isAttachment || isDirect))
{
throw new IllegalArgumentException("Attachment mode is not properly specified: " + requestURI);
}
// allow only nodes from workspace://SpaceStore/ storeRef
StoreRef storeRef = new StoreRef(URLDecoder.decode(t.nextToken()), URLDecoder.decode(t.nextToken()));
boolean isWorkspaceStoreType = storeRef.getProtocol().equalsIgnoreCase("workspace");
boolean isSpacesStoreStoreId = storeRef.getIdentifier().equalsIgnoreCase("SpacesStore");
if (!isWorkspaceStoreType || !isSpacesStoreStoreId)
{
throw new IllegalArgumentException("Servlet accepts only nodes from workspace://SpaceStore/ storeRef: " + requestURI);
}
String nodeId = URLDecoder.decode(t.nextToken());
// build redirect URL to V1 GET /nodes/{nodeId}/content
String redirectUrl = String
.format("%s/api/-default-/public/alfresco/versions/1/nodes/%s/content?attachment=%b",
req.getContextPath(), nodeId, isAttachment);
if (logger.isDebugEnabled())
{
logger.debug("Request redirected to URL: " + redirectUrl);
}
res.sendRedirect(redirectUrl);
}
}

View File

@@ -243,6 +243,10 @@
</listener>
<!-- Enterprise listener placeholder -->
<servlet>
<servlet-name>downloadContent</servlet-name>
<servlet-class>org.alfresco.web.app.servlet.DownloadContentServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>WebDAV</servlet-name>
@@ -384,6 +388,16 @@
<!-- Enterprise servlet placeholder -->
<servlet-mapping>
<servlet-name>downloadContent</servlet-name>
<url-pattern>/download/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>downloadContent</servlet-name>
<url-pattern>/d/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>WebDAV</servlet-name>
<url-pattern>/webdav/*</url-pattern>