mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	Compare commits
	
		
			30 Commits
		
	
	
		
			17.66
			...
			fix/admin-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 53ecbaa74f | ||
|  | bc5aabbf37 | ||
|  | 501d9204a9 | ||
|  | 924005e94e | ||
|  | 3a34c42d2f | ||
|  | 332af85227 | ||
|  | 556c13eba0 | ||
|  | 3caf6bf9f3 | ||
|  | b5fcc5370a | ||
|  | 29007871e8 | ||
|  | 12df503cc2 | ||
|  | e3a9e9c034 | ||
|  | d116cf397b | ||
|  | 271c123a00 | ||
|  | 5bae1ca9b6 | ||
|  | f84c82c6a2 | ||
|  | c639eec1df | ||
|  | d2e561dc95 | ||
|  | 54347fbbee | ||
|  | ab0d482179 | ||
|  | 5fed5292d9 | ||
|  | 1e8944a310 | ||
|  | b97b6751cc | ||
|  | af97aca661 | ||
|  | 368acf4724 | ||
|  | 2341f0290e | ||
|  | 2e4f5d5726 | ||
|  | be118c25ba | ||
|  | 601b743388 | ||
|  | 3c3c3b2666 | 
							
								
								
									
										680
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										680
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -51,346 +51,346 @@ jobs: | ||||
|       install: skip | ||||
|       script: travis_retry travis_wait 80 bash scripts/travis/prepare.sh | ||||
|  | ||||
|     - name: "Source Clear Scan (SCA)" | ||||
|       stage: test | ||||
|       if: branch = master OR branch =~ /release\/.*/ | ||||
|       # Run Veracode | ||||
|       install: skip | ||||
|       script: travis_wait 30 bash scripts/travis/source_clear.sh | ||||
|  | ||||
|     - name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       script: | ||||
|         - travis_retry mvn -B test -pl core,data-model -am -DfailIfNoTests=false | ||||
|         - travis_retry mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false | ||||
|  | ||||
|     - name: "Repository - AppContext01TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext01TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext02TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext02TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext03TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext03TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext04TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext04TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext05TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - mkdir -p "${HOME}/tmp" | ||||
|         - cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp" | ||||
|         - export HOST_IP=$(hostname  -I | cut -f1 -d' ') | ||||
|         - docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext05TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" | ||||
|  | ||||
|     - name: "Repository - AppContext06TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext06TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContextExtraTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContextExtraTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - MiscContextTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=MiscContextTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - SearchTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=SearchTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dindex.subsystem.name=solr6 | ||||
|  | ||||
|     - name: "Repository - MariaDB 10.2.18 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.2.18 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
|  | ||||
|     - name: "Repository - MariaDB 10.4 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.4 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
|  | ||||
|     - name: "Repository - MariaDB 10.5 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.5 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
|  | ||||
|     - name: "Repository - MariaDB 10.6 tests" | ||||
|       # We run tests on the latest version of MariaDB on pull requests plus the normal master and release branches - ignored on feature branches | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.6 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
|  | ||||
|     - name: "Repository - MySQL 8 tests" | ||||
|       # We run tests on the latest version of MySQL on pull requests plus the normal master and release branches - ignored on feature branches | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco  mysql:8 --transaction-isolation='READ-COMMITTED' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - PostgreSQL 13.7 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.7 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - PostgreSQL 14.4 tests" | ||||
|       # We only run DB tests on the latest version of PostgreSQL on feature branches | ||||
|       if: commit_message !~ /\[skip db\]/ OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - Messaging tests" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false | ||||
|  | ||||
|     - name: "Remote-api - AppContext01TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Remote-api - AppContext02TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Remote-api - AppContext03TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Remote-api - AppContext04TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|         - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Remote-api - AppContextExtraTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
|       script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "REST API TAS tests part1" | ||||
|       # TAS tests are generally skipped on feature branches as they will be repeated on the enterprise repo or community packaging builds | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "REST API TAS tests part2" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "REST API TAS tests part3" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "CMIS TAS tests - BROWSER binding" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "CMIS TAS tests - ATOM binding" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "CMIS TAS tests - WEBSERVICES binding" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Email TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 30 mvn -B verify -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "WebDAV TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 30 mvn -B verify -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Integration TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
|       script: travis_wait 30 mvn -B verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Share Services - ShareServicesTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
|       script: travis_wait 20 mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 01 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 02 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 03 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 04 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 01 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 02 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 03 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 04 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Community Rest API Tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       addons: | ||||
|         artifacts: | ||||
|           paths: | ||||
|             - ./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports/rm-automation-community-rest-api.log | ||||
|             - alfresco.log | ||||
|             - solr.log | ||||
|           target_paths: community/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NAME} | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco" | ||||
|       script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags | ||||
|       after_script: bash amps/ags/travis/scripts/getLogs.sh | ||||
| #    - name: "Source Clear Scan (SCA)" | ||||
| #      stage: test | ||||
| #      if: branch = master OR branch =~ /release\/.*/ | ||||
| #      # Run Veracode | ||||
| #      install: skip | ||||
| #      script: travis_wait 30 bash scripts/travis/source_clear.sh | ||||
| # | ||||
| #    - name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      script: | ||||
| #        - travis_retry mvn -B test -pl core,data-model -am -DfailIfNoTests=false | ||||
| #        - travis_retry mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false | ||||
| # | ||||
| #    - name: "Repository - AppContext01TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext01TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext02TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext02TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext03TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext03TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext04TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext04TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext05TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - mkdir -p "${HOME}/tmp" | ||||
| #        - cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp" | ||||
| #        - export HOST_IP=$(hostname  -I | cut -f1 -d' ') | ||||
| #        - docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext05TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" | ||||
| # | ||||
| #    - name: "Repository - AppContext06TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext06TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContextExtraTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContextExtraTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - MiscContextTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=MiscContextTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - SearchTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=SearchTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dindex.subsystem.name=solr6 | ||||
| # | ||||
| #    - name: "Repository - MariaDB 10.2.18 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.2.18 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
| # | ||||
| #    - name: "Repository - MariaDB 10.4 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.4 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
| # | ||||
| #    - name: "Repository - MariaDB 10.5 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.5 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
| # | ||||
| #    - name: "Repository - MariaDB 10.6 tests" | ||||
| #      # We run tests on the latest version of MariaDB on pull requests plus the normal master and release branches - ignored on feature branches | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.6 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
| # | ||||
| #    - name: "Repository - MySQL 8 tests" | ||||
| #      # We run tests on the latest version of MySQL on pull requests plus the normal master and release branches - ignored on feature branches | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco  mysql:8 --transaction-isolation='READ-COMMITTED' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - PostgreSQL 13.7 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.7 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - PostgreSQL 14.4 tests" | ||||
| #      # We only run DB tests on the latest version of PostgreSQL on feature branches | ||||
| #      if: commit_message !~ /\[skip db\]/ OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - Messaging tests" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false | ||||
| # | ||||
| #    - name: "Remote-api - AppContext01TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Remote-api - AppContext02TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Remote-api - AppContext03TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Remote-api - AppContext04TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Remote-api - AppContextExtraTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "REST API TAS tests part1" | ||||
| #      # TAS tests are generally skipped on feature branches as they will be repeated on the enterprise repo or community packaging builds | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "REST API TAS tests part2" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "REST API TAS tests part3" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "CMIS TAS tests - BROWSER binding" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "CMIS TAS tests - ATOM binding" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "CMIS TAS tests - WEBSERVICES binding" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Email TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 30 mvn -B verify -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "WebDAV TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 30 mvn -B verify -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Integration TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" | ||||
| #      script: travis_wait 30 mvn -B verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Share Services - ShareServicesTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #      script: travis_wait 20 mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 01 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 02 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 03 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 04 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 01 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 02 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 03 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 04 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Community Rest API Tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      addons: | ||||
| #        artifacts: | ||||
| #          paths: | ||||
| #            - ./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports/rm-automation-community-rest-api.log | ||||
| #            - alfresco.log | ||||
| #            - solr.log | ||||
| #          target_paths: community/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NAME} | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco" | ||||
| #      script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags | ||||
| #      after_script: bash amps/ags/travis/scripts/getLogs.sh | ||||
|  | ||||
|     - name: "Push to Nexus" | ||||
|       stage: release | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-automation-community-repo</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <build> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <build> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -40,6 +40,7 @@ import org.json.JSONObject; | ||||
| import org.junit.Assert; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.Response; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.ArrayList; | ||||
| @@ -194,13 +195,13 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content"); | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content"); | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         // uri with relative path at the end | ||||
|         String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2"; | ||||
| @@ -212,7 +213,50 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content) | ||||
|     public void testForcedAttachment() throws Exception | ||||
|     { | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef testhtml = createNodeWithTextContent(rootFolder, "testhtml", ContentModel.TYPE_CONTENT, "testhtml content", MimetypeMap.MIMETYPE_HTML); | ||||
|         NodeRef testpdf = createNodeWithTextContent(rootFolder, "testpdf", ContentModel.TYPE_CONTENT, "testpdf content", MimetypeMap.MIMETYPE_PDF); | ||||
|  | ||||
|         String uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=false"; | ||||
|         GetRequest req = new GetRequest(uri); | ||||
|         Response res = sendRequest(req, 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=false"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content, String mimetype) | ||||
|     { | ||||
|         NodeRef nodeRef = createNode(parentNode, nodeCmName, nodeType); | ||||
|  | ||||
| @@ -220,7 +264,7 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         if (content != null) | ||||
|         { | ||||
|             ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); | ||||
|             writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|             writer.setMimetype(mimetype); | ||||
|             writer.setEncoding("UTF-8"); | ||||
|             writer.putContent(content); | ||||
|         } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo</artifactId> | ||||
|       <version>17.66</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <dependencies> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
|   | ||||
| @@ -9,6 +9,6 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
| </project> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -27,9 +27,9 @@ package org.alfresco.rest.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createActionModel; | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteConsumer; | ||||
| import static org.alfresco.utility.constants.UserRole.*; | ||||
| import static org.alfresco.utility.model.FileModel.getRandomFileModel; | ||||
| import static org.alfresco.utility.model.FileType.TEXT_PLAIN; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| @@ -45,6 +45,7 @@ import java.util.stream.IntStream; | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.utility.constants.UserRole; | ||||
| import org.alfresco.utility.model.FileModel; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| @@ -162,41 +163,42 @@ public class CreateRulesTests extends RestTest | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user without write permission for the folder cannot create a rule in it. */ | ||||
|     public void requireWritePermissionToCreateRule() | ||||
|     /** Check that a Collaborator cannot create a rule in a private folder. */ | ||||
|     public void siteCollaboratorCannotCreateRule() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder"); | ||||
|         UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|  | ||||
|         STEP("Create a collaborator and check they cannot create a rule in the private folder"); | ||||
|         UserModel collaborator = dataUser.createRandomTestUser(); | ||||
|         dataUser.addUserToSite(collaborator, privateSite, SiteCollaborator); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(collaborator).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|         testRolePermissionsWith(SiteCollaborator); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user consumer permission for the folder cannot create a rule in it. */ | ||||
|     public void failToCreateRuleAsSiteConsumer() | ||||
|     /** Check that a Contributor cannot create a rule in a private folder. */ | ||||
|     public void siteContributorCannotCreateRule() | ||||
|     { | ||||
|         STEP("Create a consumer and check they cannot create a rule in the public folder"); | ||||
|         UserModel consumer = dataUser.createRandomTestUser(); | ||||
|         dataUser.addUserToSite(consumer, site, SiteConsumer); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(consumer).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|         testRolePermissionsWith(SiteContributor); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a Consumer cannot create a rule in a private folder. */ | ||||
|     public void siteConsumerCannotCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteConsumer); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a siteManager can create a rule in a private folder. */ | ||||
|     public void siteManagerCanCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteManager) | ||||
|                 .assertThat().field("id").isNotNull() | ||||
|                 .assertThat().field("name").is("testRule"); | ||||
|         restClient.assertStatusCodeIs(CREATED); | ||||
|     } | ||||
|  | ||||
|     /** Check we can't create a rule under a document node. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void tryToCreateRuleUnderDocument() | ||||
| @@ -249,4 +251,18 @@ public class CreateRulesTests extends RestTest | ||||
|         restClient.assertStatusCodeIs(BAD_REQUEST); | ||||
|         restClient.assertLastError().containsSummary("Rule name is a mandatory parameter"); | ||||
|     } | ||||
|  | ||||
|     public RestRuleModel testRolePermissionsWith(UserRole userRole) | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder"); | ||||
|         SiteModel privateSite = dataSite.usingUser(user).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(user).usingSite(privateSite).createFolder(); | ||||
|  | ||||
|         STEP(String.format("Add a user with '%s' role in the private site's folder", userRole.toString())); | ||||
|         UserModel userWithRole = dataUser.createRandomTestUser(); | ||||
|         dataUser.addUserToSite(userWithRole, privateSite, userRole); | ||||
|         RestRuleModel ruleModel = createRuleModel("testRule", List.of(createActionModel())); | ||||
|  | ||||
|         return restClient.authenticateUser(userWithRole).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,161 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Repository | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.rules; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
| import static org.springframework.http.HttpStatus.OK; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.rest.model.RestRuleSetModel; | ||||
| import org.alfresco.rest.model.RestRuleSetModelsCollection; | ||||
| 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.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for GET /nodes/{nodeId}/rule-sets and /nodes/{nodeId}/rule-sets/{ruleSetId}. | ||||
|  */ | ||||
| @Test (groups = { TestGroup.RULES }) | ||||
| public class GetRuleSetsTests extends RestTest | ||||
| { | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|     private FolderModel ruleFolder; | ||||
|     private RestRuleModel rule; | ||||
|  | ||||
|     @BeforeClass (alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         STEP("Create a user, site and folder."); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|         ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Create a rule in the folder."); | ||||
|         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||
|         rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                        .createSingleRule(ruleModel); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get an empty list of rule sets. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getEmptyRuleSetsList() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Get the rule sets for the folder"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() | ||||
|                                                          .usingNode(folder).getListOfRuleSets(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         assertTrue("Expected no rule sets to be present.", ruleSets.isEmpty()); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a list of rule sets. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetsList() | ||||
|     { | ||||
|         STEP("Get the rule sets for the folder"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getListOfRuleSets(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSets.assertThat().entriesListCountIs(1); | ||||
|         ruleSets.getEntries().get(0).onModel() | ||||
|                 .assertThat().field("id").isNotNull(); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load rule sets for a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getRuleSetsForNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load rule sets for a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getListOfRuleSets(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a rule set by its id. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetById() | ||||
|     { | ||||
|         STEP("Get the rule sets for the folder and find the rule set id"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getListOfRuleSets(); | ||||
|         ruleSets.assertThat().entriesListCountIs(1); | ||||
|         String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); | ||||
|  | ||||
|         STEP("Get the rule set using its rule set id"); | ||||
|         RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                              .getRuleSet(ruleSetId); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSet.assertThat().field("id").is(ruleSetId); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a rule set using the "-default-" synonym. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getDefaultRuleSetById() | ||||
|     { | ||||
|         STEP("Get the default rule set for the folder"); | ||||
|         RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getDefaultRuleSet(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSet.assertThat().field("id").isNotNull(); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load the default rule set for a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getDefaultRuleSetForNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load a rule set for a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getDefaultRuleSet(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we get 404 for a non-existing rule set id. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetByNonExistingId() | ||||
|     { | ||||
|         STEP("Get the rule set using fake rule set id"); | ||||
|         String ruleSetId = "fake-rule-set-id"; | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).getRuleSet(ruleSetId); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
| } | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
							
								
								
									
										14
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
| <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>alfresco-community-repo</artifactId> | ||||
|     <version>17.66</version> | ||||
|     <version>17.75-SNAPSHOT</version> | ||||
|     <packaging>pom</packaging> | ||||
|     <name>Alfresco Community Repo Parent</name> | ||||
|  | ||||
| @@ -53,8 +53,8 @@ | ||||
|         <dependency.activiti.version>5.23.0</dependency.activiti.version> | ||||
|         <dependency.alfresco-transform-service.version>1.5.3</dependency.alfresco-transform-service.version> | ||||
|         <dependency.alfresco-transform-core.version>2.6.0</dependency.alfresco-transform-core.version> | ||||
|         <dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version> | ||||
|         <dependency.acs-event-model.version>0.0.15</dependency.acs-event-model.version> | ||||
|         <dependency.alfresco-greenmail.version>6.4</dependency.alfresco-greenmail.version> | ||||
|         <dependency.acs-event-model.version>0.0.16</dependency.acs-event-model.version> | ||||
|  | ||||
|         <dependency.spring.version>5.3.22</dependency.spring.version> | ||||
|         <dependency.antlr.version>3.5.2</dependency.antlr.version> | ||||
| @@ -84,7 +84,7 @@ | ||||
|         <dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version> | ||||
|         <dependency.keycloak.version>15.0.2</dependency.keycloak.version> | ||||
|         <dependency.jboss.logging.version>3.5.0.Final</dependency.jboss.logging.version> | ||||
|         <dependency.camel.version>3.18.0</dependency.camel.version> <!-- when bumping this version, please keep track/sync with included netty.io dependencies (can cause dependency conflicts)--> | ||||
|         <dependency.camel.version>3.15.0</dependency.camel.version> <!-- when bumping this version, please keep track/sync with included netty.io dependencies (can cause dependency conflicts)--> | ||||
|         <dependency.activemq.version>5.17.1</dependency.activemq.version> | ||||
|         <dependency.apache-compress.version>1.21</dependency.apache-compress.version> | ||||
|         <dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version> | ||||
| @@ -114,13 +114,13 @@ | ||||
|         <alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version> | ||||
|         <license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version> | ||||
|  | ||||
|         <dependency.postgresql.version>42.4.0</dependency.postgresql.version> | ||||
|         <dependency.postgresql.version>42.4.1</dependency.postgresql.version> | ||||
|         <dependency.mysql.version>8.0.30</dependency.mysql.version> | ||||
|         <dependency.mysql-image.version>8</dependency.mysql-image.version> | ||||
|         <dependency.mariadb.version>2.7.4</dependency.mariadb.version> | ||||
|         <dependency.tas-utility.version>3.0.49</dependency.tas-utility.version> | ||||
|         <dependency.rest-assured.version>3.3.0</dependency.rest-assured.version> | ||||
|         <dependency.tas-restapi.version>1.100</dependency.tas-restapi.version> | ||||
|         <dependency.tas-restapi.version>1.101</dependency.tas-restapi.version> | ||||
|         <dependency.tas-cmis.version>1.31</dependency.tas-cmis.version> | ||||
|         <dependency.tas-email.version>1.8</dependency.tas-email.version> | ||||
|         <dependency.tas-webdav.version>1.6</dependency.tas-webdav.version> | ||||
| @@ -148,7 +148,7 @@ | ||||
|         <connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection> | ||||
|         <developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection> | ||||
|         <url>https://github.com/Alfresco/alfresco-community-repo</url> | ||||
|         <tag>17.66</tag> | ||||
|         <tag>HEAD</tag> | ||||
|     </scm> | ||||
|  | ||||
|     <distributionManagement> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
| @@ -130,7 +130,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-server</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|             <exclusions> | ||||
|                 <exclusion> | ||||
| @@ -142,19 +142,19 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-security</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-webapp</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.alfresco.cmis.client</groupId> | ||||
|             <artifactId>alfresco-opencmis-extension</artifactId> | ||||
|             <version>2.0</version> | ||||
|             <version>2.1</version> | ||||
|             <scope>test</scope> | ||||
|             <exclusions> | ||||
|               <!-- Duplicates classes from jakarta.transaction:jakarta.transaction-api --> | ||||
|   | ||||
| @@ -0,0 +1,64 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.repo.web.scripts; | ||||
|  | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.MimetypeService; | ||||
| import org.springframework.extensions.webscripts.WebScriptRequest; | ||||
|  | ||||
| public class MimeTypeUtil | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * Get the file mimetype from the file ContentReader, and if its null then set the mimetype to binary by default | ||||
|      * and try to get the correct one from file extension | ||||
|      * | ||||
|      * | ||||
|      * @param reader            reader of the file in the request | ||||
|      * @param req               request relating to the file | ||||
|      * @param mimetypeService   MimetypeService | ||||
|      * | ||||
|      * @return  mimetype of the file as a string | ||||
|      */ | ||||
|     public static String determineMimetype(ContentReader reader, WebScriptRequest req, MimetypeService mimetypeService) | ||||
|     { | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             String extensionPath = req.getExtensionPath(); | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         return mimetype; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -26,14 +26,18 @@ | ||||
| package org.alfresco.repo.web.scripts.content; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import javax.servlet.ServletContext; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.dictionary.DictionaryService; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.ContentService; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.NamespaceService; | ||||
| @@ -65,6 +69,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|     private NamespaceService namespaceService; | ||||
|     private ContentService contentService; | ||||
|  | ||||
|     private List<String> nonAttachContentTypes = Collections.emptyList(); | ||||
|  | ||||
|     /** | ||||
|      * @param nonAttachContentTypes List<String> | ||||
|      */ | ||||
|     public void setNonAttachContentTypes(List<String> nonAttachContentTypes) | ||||
|     { | ||||
|         if (nonAttachContentTypes != null && !nonAttachContentTypes.isEmpty()) | ||||
|         { | ||||
|             this.nonAttachContentTypes = nonAttachContentTypes; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param servletContext ServletContext | ||||
|      */ | ||||
| @@ -121,9 +138,7 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|         { | ||||
|             throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); | ||||
|         } | ||||
|          | ||||
|         // determine attachment | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|  | ||||
|          | ||||
|         // render content | ||||
|         QName propertyQName = ContentModel.PROP_CONTENT; | ||||
| @@ -140,6 +155,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|                 propertyQName = QName.createQName(propertyName, namespaceService); | ||||
|             } | ||||
|         } | ||||
|         // determine attachment and force download for specific mimetypes - see PRODSEC-5862 | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|         ContentReader reader = contentService.getReader(nodeRef, propertyQName); | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         if (!attach) | ||||
|         { | ||||
|             if (nonAttachContentTypes == null || !nonAttachContentTypes.contains(mimetype)) | ||||
|             { | ||||
|                 attach = true; | ||||
|                 logger.warn("Ignored a=false for " + nodeRef.getId() + " since " + mimetype + " is not in the whitelist for non-attach content types"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Stream the content | ||||
|         streamContentLocal(req, res, nodeRef, attach, propertyQName, null); | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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% | ||||
|  */ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.repo.web.scripts.content; | ||||
|  | ||||
| import java.io.IOException; | ||||
| @@ -33,7 +33,7 @@ import java.util.Map; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.QName; | ||||
| @@ -79,18 +79,7 @@ public class ContentInfo extends StreamContent | ||||
|         delegate.setAttachment(req, res, attach, attachFileName); | ||||
|  | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         // set mimetype for the content and the character encoding + length for the stream | ||||
|         res.setContentType(mimetype); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -43,6 +43,7 @@ import javax.servlet.http.HttpServletResponse; | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.content.filestore.FileContentReader; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.sync.repo.events.EventPublisher; | ||||
| import org.alfresco.repo.web.util.HttpRangeProcessor; | ||||
| import org.alfresco.rest.framework.resource.content.CacheDirective; | ||||
| @@ -361,18 +362,7 @@ public class ContentStreamer implements ResourceLoaderAware | ||||
|         setAttachment(req, res, attach, attachFileName); | ||||
|      | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|          | ||||
|         res.setHeader(HEADER_ACCEPT_RANGES, "bytes"); | ||||
|         try | ||||
|   | ||||
							
								
								
									
										61
									
								
								remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
|  | ||||
| /** | ||||
|  * Rule sets API. | ||||
|  */ | ||||
| @Experimental | ||||
| public interface RuleSets | ||||
| { | ||||
|     /** | ||||
|      * Get rule sets for a folder. | ||||
|      * | ||||
|      * @param folderNodeId Folder node ID | ||||
|      * @param paging {@link Paging} information | ||||
|      * @param includes List of fields to include in the rule set | ||||
|      * @return {@link CollectionWithPagingInfo} containing a list page of rule sets | ||||
|      */ | ||||
|     CollectionWithPagingInfo<RuleSet> getRuleSets(String folderNodeId, List<String> includes, Paging paging); | ||||
|  | ||||
|     /** | ||||
|      * Get the rule set with the given ID and check associations with the folder node. | ||||
|      * | ||||
|      * @param folderNodeId Folder node ID | ||||
|      * @param ruleSetId Rule set ID | ||||
|      * @param includes List of fields to include in the rule set | ||||
|      * @return {@link RuleSet} definition | ||||
|      */ | ||||
|     RuleSet getRuleSetById(String folderNodeId, String ruleSetId, List<String> includes); | ||||
| } | ||||
| @@ -23,123 +23,33 @@ | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| 
 | ||||
| package org.alfresco.rest.api.impl; | ||||
| package org.alfresco.rest.api.impl.rules; | ||||
| 
 | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; | ||||
| import static org.alfresco.service.cmr.security.PermissionService.CHANGE_PERMISSIONS; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.rule.RuleModel; | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.Rules; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.ListPage; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.alfresco.service.cmr.security.PermissionService; | ||||
| import org.alfresco.service.namespace.QName; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| @Experimental | ||||
| public class RulesImpl implements Rules | ||||
| /** Responsible for validating nodes when working with rules. */ | ||||
| public class NodeValidator | ||||
| { | ||||
|     private static final Logger LOGGER = LoggerFactory.getLogger(RulesImpl.class); | ||||
|     private static final String RULE_SET_EXPECTED_TYPE_NAME = "rule set"; | ||||
| 
 | ||||
|     private Nodes nodes; | ||||
| 
 | ||||
|     private PermissionService permissionService; | ||||
| 
 | ||||
|     private RuleService ruleService; | ||||
| 
 | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<Rule> getRules(final String folderNodeId, final String ruleSetId, final Paging paging) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
| 
 | ||||
|         final boolean isShared = isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         final List<Rule> rules = ruleService.getRules(folderNodeRef).stream() | ||||
|             .map(ruleModel -> Rule.from(ruleModel, isShared)) | ||||
|             .collect(Collectors.toList()); | ||||
| 
 | ||||
|         return ListPage.of(rules, paging); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Rule getRuleById(final String folderNodeId, final String ruleSetId, final String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validateRuleNode(ruleId, ruleSetNodeRef); | ||||
| 
 | ||||
|         return Rule.from(ruleService.getRule(ruleNodeRef), isRuleSetNotNullAndShared(ruleSetNodeRef)); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public List<Rule> createRules(final String folderNodeId, final String ruleSetId, final List<Rule> rules) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validateFolderNode(folderNodeId, true); | ||||
|         // Don't validate the ruleset node if -default- is passed since we may need to create it. | ||||
|         final NodeRef ruleSetNodeRef = (RuleSet.isNotDefaultId(ruleSetId)) ? validateRuleSetNode(ruleSetId, folderNodeRef) : null; | ||||
| 
 | ||||
|         return rules.stream() | ||||
|                     .map(rule -> rule.toServiceModel(nodes)) | ||||
|                     .map(rule -> ruleService.saveRule(folderNodeRef, rule)) | ||||
|                     .map(rule -> Rule.from(rule, isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef))) | ||||
|                     .collect(Collectors.toList()); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public Rule updateRuleById(String folderNodeId, String ruleSetId, String ruleId, Rule rule) | ||||
|     { | ||||
|         LOGGER.debug("Updating rule in folder {}, rule set {}, rule {} to {}", folderNodeId, ruleSetId, ruleId, rule); | ||||
| 
 | ||||
|         NodeRef folderNodeRef = validateFolderNode(folderNodeId, true); | ||||
|         NodeRef ruleSetNodeRef = validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         validateRuleNode(ruleId, ruleSetNodeRef); | ||||
| 
 | ||||
|         boolean shared = isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         return Rule.from(ruleService.saveRule(folderNodeRef, rule.toServiceModel(nodes)), shared); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void deleteRuleById(String folderNodeId, String ruleSetId, String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validateFolderNode(folderNodeId, true); | ||||
|         final NodeRef ruleSetNodeRef = validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|         final org.alfresco.service.cmr.rule.Rule rule = ruleService.getRule(ruleNodeRef); | ||||
|         ruleService.removeRule(folderNodeRef, rule); | ||||
|     } | ||||
| 
 | ||||
|     public void setNodes(Nodes nodes) | ||||
|     { | ||||
|         this.nodes = nodes; | ||||
|     } | ||||
| 
 | ||||
|     public void setPermissionService(PermissionService permissionService) | ||||
|     { | ||||
|         this.permissionService = permissionService; | ||||
|     } | ||||
| 
 | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
|     private PermissionService permissionService; | ||||
| 
 | ||||
|     /** | ||||
|      * Validates if folder node exists and the user has permission to use it. | ||||
| @@ -150,7 +60,7 @@ public class RulesImpl implements Rules | ||||
|      * @throws InvalidArgumentException if node is not of an expected type | ||||
|      * @throws PermissionDeniedException if the user doesn't have the appropriate permission for the folder. | ||||
|      */ | ||||
|     private NodeRef validateFolderNode(final String folderNodeId, boolean requireChangePermission) | ||||
|     public NodeRef validateFolderNode(final String folderNodeId, boolean requireChangePermission) | ||||
|     { | ||||
|         final NodeRef nodeRef = nodes.validateOrLookupNode(folderNodeId, null); | ||||
|         if (requireChangePermission) | ||||
| @@ -180,7 +90,7 @@ public class RulesImpl implements Rules | ||||
|      * @return rule set node reference | ||||
|      * @throws InvalidArgumentException in case of not matching associated folder node | ||||
|      */ | ||||
|     private NodeRef validateRuleSetNode(final String ruleSetId, final NodeRef associatedFolderNodeRef) | ||||
|     public NodeRef validateRuleSetNode(final String ruleSetId, final NodeRef associatedFolderNodeRef) | ||||
|     { | ||||
|         if (RuleSet.isDefaultId(ruleSetId)) | ||||
|         { | ||||
| @@ -194,13 +104,15 @@ public class RulesImpl implements Rules | ||||
|         } | ||||
| 
 | ||||
|         final NodeRef ruleSetNodeRef = validateNode(ruleSetId, ContentModel.TYPE_SYSTEM_FOLDER, RULE_SET_EXPECTED_TYPE_NAME); | ||||
|         if (!ruleService.isRuleSetAssociatedWithFolder(ruleSetNodeRef, associatedFolderNodeRef)) { | ||||
|         if (!ruleService.isRuleSetAssociatedWithFolder(ruleSetNodeRef, associatedFolderNodeRef)) | ||||
|         { | ||||
|             throw new InvalidArgumentException("Rule set is not associated with folder node!"); | ||||
|         } | ||||
| 
 | ||||
|         return ruleSetNodeRef; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Validates if rule node exists and associated rule set node matches. | ||||
|      * | ||||
| @@ -209,7 +121,7 @@ public class RulesImpl implements Rules | ||||
|      * @return rule node reference | ||||
|      * @throws InvalidArgumentException in case of not matching associated rule set node | ||||
|      */ | ||||
|     private NodeRef validateRuleNode(final String ruleId, final NodeRef associatedRuleSetNodeRef) | ||||
|     public NodeRef validateRuleNode(final String ruleId, final NodeRef associatedRuleSetNodeRef) | ||||
|     { | ||||
|         final NodeRef ruleNodeRef = validateNode(ruleId, RuleModel.TYPE_RULE, null); | ||||
|         if (associatedRuleSetNodeRef != null && !ruleService.isRuleAssociatedWithRuleSet(ruleNodeRef, associatedRuleSetNodeRef)) | ||||
| @@ -231,13 +143,14 @@ public class RulesImpl implements Rules | ||||
|     private void verifyNodeType(final NodeRef nodeRef, final QName expectedType, final String expectedTypeName) | ||||
|     { | ||||
|         final Set<QName> expectedTypes = Set.of(expectedType); | ||||
|         if (!nodes.nodeMatches(nodeRef, expectedTypes, null)) { | ||||
|             final String expectedTypeLocalName = (expectedTypeName != null)? expectedTypeName : expectedType.getLocalName(); | ||||
|         if (!nodes.nodeMatches(nodeRef, expectedTypes, null)) | ||||
|         { | ||||
|             final String expectedTypeLocalName = (expectedTypeName != null) ? expectedTypeName : expectedType.getLocalName(); | ||||
|             throw new InvalidArgumentException(String.format("NodeId of a %s is expected!", expectedTypeLocalName)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef, final NodeRef folderNodeRef) | ||||
|     public boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef, final NodeRef folderNodeRef) | ||||
|     { | ||||
|         if (ruleSetNodeRef == null && folderNodeRef != null) | ||||
|         { | ||||
| @@ -250,8 +163,23 @@ public class RulesImpl implements Rules | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef) | ||||
|     public boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef) | ||||
|     { | ||||
|         return ruleSetNodeRef != null && ruleService.isRuleSetShared(ruleSetNodeRef); | ||||
|     } | ||||
| 
 | ||||
|     public void setPermissionService(PermissionService permissionService) | ||||
|     { | ||||
|         this.permissionService = permissionService; | ||||
|     } | ||||
| 
 | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
| 
 | ||||
|     public void setNodes(Nodes nodes) | ||||
|     { | ||||
|         this.nodes = nodes; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,80 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| import org.alfresco.rest.api.RuleSets; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.ListPage; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
|  | ||||
| @Experimental | ||||
| public class RuleSetsImpl implements RuleSets | ||||
| { | ||||
|     private RuleService ruleService; | ||||
|     private NodeValidator validator; | ||||
|  | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<RuleSet> getRuleSets(String folderNodeId, List<String> includes, Paging paging) | ||||
|     { | ||||
|         NodeRef folderNode = validator.validateFolderNode(folderNodeId, false); | ||||
|  | ||||
|         NodeRef ruleSetNode = ruleService.getRuleSetNode(folderNode); | ||||
|         List<RuleSet> ruleSets = Optional.ofNullable(ruleSetNode) | ||||
|                                          .map(NodeRef::getId) | ||||
|                                          .map(RuleSet::of).stream().collect(toList()); | ||||
|  | ||||
|         return ListPage.of(ruleSets, paging); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public RuleSet getRuleSetById(String folderNodeId, String ruleSetId, List<String> includes) | ||||
|     { | ||||
|         NodeRef folderNode = validator.validateFolderNode(folderNodeId, false); | ||||
|         NodeRef ruleSetNode = validator.validateRuleSetNode(ruleSetId, folderNode); | ||||
|  | ||||
|         return RuleSet.of(ruleSetNode.getId()); | ||||
|     } | ||||
|  | ||||
|     public void setValidator(NodeValidator validator) | ||||
|     { | ||||
|         this.validator = validator; | ||||
|     } | ||||
|  | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,129 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl.rules; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.Rules; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.ListPage; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| @Experimental | ||||
| public class RulesImpl implements Rules | ||||
| { | ||||
|     private static final Logger LOGGER = LoggerFactory.getLogger(RulesImpl.class); | ||||
|  | ||||
|     private Nodes nodes; | ||||
|     private RuleService ruleService; | ||||
|     private NodeValidator validator; | ||||
|  | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<Rule> getRules(final String folderNodeId, final String ruleSetId, final Paging paging) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|  | ||||
|         final boolean isShared = validator.isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         final List<Rule> rules = ruleService.getRules(folderNodeRef).stream() | ||||
|             .map(ruleModel -> Rule.from(ruleModel, isShared)) | ||||
|             .collect(Collectors.toList()); | ||||
|  | ||||
|         return ListPage.of(rules, paging); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Rule getRuleById(final String folderNodeId, final String ruleSetId, final String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|  | ||||
|         return Rule.from(ruleService.getRule(ruleNodeRef), validator.isRuleSetNotNullAndShared(ruleSetNodeRef)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<Rule> createRules(final String folderNodeId, final String ruleSetId, final List<Rule> rules) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         // Don't validate the ruleset node if -default- is passed since we may need to create it. | ||||
|         final NodeRef ruleSetNodeRef = (RuleSet.isNotDefaultId(ruleSetId)) ? validator.validateRuleSetNode(ruleSetId, folderNodeRef) : null; | ||||
|  | ||||
|         return rules.stream() | ||||
|                     .map(rule -> rule.toServiceModel(nodes)) | ||||
|                     .map(rule -> ruleService.saveRule(folderNodeRef, rule)) | ||||
|                     .map(rule -> Rule.from(rule, validator.isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef))) | ||||
|                     .collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Rule updateRuleById(String folderNodeId, String ruleSetId, String ruleId, Rule rule) | ||||
|     { | ||||
|         LOGGER.debug("Updating rule in folder {}, rule set {}, rule {} to {}", folderNodeId, ruleSetId, ruleId, rule); | ||||
|  | ||||
|         NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|  | ||||
|         boolean shared = validator.isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         return Rule.from(ruleService.saveRule(folderNodeRef, rule.toServiceModel(nodes)), shared); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteRuleById(String folderNodeId, String ruleSetId, String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|         final org.alfresco.service.cmr.rule.Rule rule = ruleService.getRule(ruleNodeRef); | ||||
|         ruleService.removeRule(folderNodeRef, rule); | ||||
|     } | ||||
|  | ||||
|     public void setNodes(Nodes nodes) | ||||
|     { | ||||
|         this.nodes = nodes; | ||||
|     } | ||||
|  | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
|  | ||||
|     public void setValidator(NodeValidator validator) | ||||
|     { | ||||
|         this.validator = validator; | ||||
|     } | ||||
| } | ||||
| @@ -44,14 +44,6 @@ public class RuleSet | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     public boolean isNotDefaultId() { | ||||
|         return isNotDefaultId(this.id); | ||||
|     } | ||||
|  | ||||
|     public boolean isDefaultId() { | ||||
|         return isDefaultId(this.id); | ||||
|     } | ||||
|  | ||||
|     public static boolean isNotDefaultId(final String id) { | ||||
|         return !isDefaultId(id); | ||||
|     } | ||||
|   | ||||
| @@ -26,15 +26,84 @@ | ||||
|  | ||||
| package org.alfresco.rest.api.nodes; | ||||
|  | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.alfresco.rest.api.RuleSets; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.WebApiDescription; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.RelationshipResource; | ||||
| import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.rest.framework.resource.parameters.Parameters; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.util.PropertyCheck; | ||||
| import org.springframework.beans.factory.InitializingBean; | ||||
|  | ||||
| /** | ||||
|  * Folder node rule sets. | ||||
|  * | ||||
|  */ | ||||
| @Experimental | ||||
| @RelationshipResource(name = "rule-sets", entityResource = NodesEntityResource.class, title = "Folder node rule sets") | ||||
| public class NodeRuleSetsRelation | ||||
| public class NodeRuleSetsRelation implements RelationshipResourceAction.Read<RuleSet>, | ||||
|                                              RelationshipResourceAction.ReadById<RuleSet>, | ||||
|                                              InitializingBean | ||||
| { | ||||
|     private RuleSets ruleSets; | ||||
|  | ||||
|     @Override | ||||
|     public void afterPropertiesSet() throws Exception | ||||
|     { | ||||
|         PropertyCheck.mandatory(this, "ruleSets", ruleSets); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * List rule sets for given folder. | ||||
|      * <p> | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets | ||||
|      * | ||||
|      * @param folderNodeId The id of the folder node. | ||||
|      * @param parameters Contains paging information and information about which fields to include | ||||
|      * @return {@link CollectionWithPagingInfo} containing a page of rule sets | ||||
|      */ | ||||
|     @WebApiDescription ( | ||||
|             title = "Get rule sets for a folder", | ||||
|             description = "Returns a paged list of rule sets for given node", | ||||
|             successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<RuleSet> readAll(String folderNodeId, Parameters parameters) | ||||
|     { | ||||
|         return ruleSets.getRuleSets(folderNodeId, parameters.getInclude(), parameters.getPaging()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get single folder rule for given node's, rule set's and rule's IDs. | ||||
|      * <p> | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets/{ruleSetId} | ||||
|      * | ||||
|      * @param folderNodeId - entity resource context for this relationship | ||||
|      * @param ruleSetId - rule set node ID (associated with folder node) | ||||
|      * @param parameters Contains information about which fields to include | ||||
|      * @return {@link RuleSet} definition | ||||
|      * @throws RelationshipResourceNotFoundException in case resource was not found | ||||
|      */ | ||||
|     @WebApiDescription ( | ||||
|             title = "Get rule set", | ||||
|             description = "Returns a single rule set for the given node", | ||||
|             successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public RuleSet readById(String folderNodeId, String ruleSetId, Parameters parameters) throws RelationshipResourceNotFoundException | ||||
|     { | ||||
|         return ruleSets.getRuleSetById(folderNodeId, ruleSetId, parameters.getInclude()); | ||||
|     } | ||||
|  | ||||
|     public void setRuleSets(RuleSets ruleSets) | ||||
|     { | ||||
|         this.ruleSets = ruleSets; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -850,9 +850,38 @@ | ||||
|         </property> | ||||
|     </bean> | ||||
|  | ||||
|     <bean id="rules" class="org.alfresco.rest.api.impl.RulesImpl"> | ||||
|     <bean id="nodeValidator" class="org.alfresco.rest.api.impl.rules.NodeValidator"> | ||||
|         <property name="nodes" ref="Nodes" /> | ||||
|         <property name="permissionService" ref="PermissionService"/> | ||||
|         <property name="permissionService" ref="PermissionService" /> | ||||
|         <property name="ruleService" ref="RuleService" /> | ||||
|     </bean> | ||||
|  | ||||
|     <bean class="org.alfresco.rest.api.nodes.NodeRulesRelation"> | ||||
|         <property name="rules" ref="Rules" /> | ||||
|     </bean> | ||||
|  | ||||
|     <bean id="ruleSets" class="org.alfresco.rest.api.impl.rules.RuleSetsImpl"> | ||||
|         <property name="validator" ref="nodeValidator" /> | ||||
|         <property name="ruleService" ref="RuleService" /> | ||||
|     </bean> | ||||
|  | ||||
|     <bean id="RuleSets" class="org.springframework.aop.framework.ProxyFactoryBean"> | ||||
|         <property name="proxyInterfaces" value="org.alfresco.rest.api.RuleSets" /> | ||||
|         <property name="target" ref="ruleSets" /> | ||||
|         <property name="interceptorNames"> | ||||
|             <list> | ||||
|                 <idref bean="legacyExceptionInterceptor" /> | ||||
|             </list> | ||||
|         </property> | ||||
|     </bean> | ||||
|  | ||||
|     <bean class="org.alfresco.rest.api.nodes.NodeRuleSetsRelation"> | ||||
|         <property name="ruleSets" ref="RuleSets" /> | ||||
|     </bean> | ||||
|  | ||||
|     <bean id="rules" class="org.alfresco.rest.api.impl.rules.RulesImpl"> | ||||
|         <property name="nodes" ref="Nodes" /> | ||||
|         <property name="validator" ref="nodeValidator"/> | ||||
|         <property name="ruleService" ref="RuleService" /> | ||||
|     </bean> | ||||
|  | ||||
| @@ -866,10 +895,6 @@ | ||||
|         </property> | ||||
|     </bean> | ||||
|  | ||||
|     <bean class="org.alfresco.rest.api.nodes.NodeRulesRelation"> | ||||
|         <property name="rules" ref="Rules" /> | ||||
|     </bean> | ||||
|  | ||||
|     <bean id="publicapi.mimeTypePropertyLookup" class="org.alfresco.rest.api.lookups.MimeTypePropertyLookup"> | ||||
|         <property name="serviceRegistry" ref="ServiceRegistry"/> | ||||
|         <property name="supported"> | ||||
|   | ||||
| @@ -249,6 +249,7 @@ | ||||
|       <property name="delegate" ref="webscript.content.streamer" /> | ||||
|       <property name="contentService" ref="contentService" /> | ||||
|       <property name="repository" ref="repositoryHelper" /> | ||||
|       <property name="nonAttachContentTypes" value="#{T(java.util.Arrays).asList('${content.nonAttach.mimetypes}')}" /> | ||||
|    </bean> | ||||
|     | ||||
|    <!--  Content Info --> | ||||
|   | ||||
| @@ -66,13 +66,17 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|     { | ||||
|         super.setUp(); | ||||
|  | ||||
|         this.authenticationService = (MutableAuthenticationService) getServer().getApplicationContext() | ||||
|                 .getBean("AuthenticationService"); | ||||
|         this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); | ||||
|         this.personService = (PersonService) getServer().getApplicationContext().getBean("PersonService"); | ||||
|         this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); | ||||
|         this.contentService = (ContentService) getServer().getApplicationContext().getBean("ContentService"); | ||||
|         AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); | ||||
|         createUser(USER_ONE); | ||||
|  | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|     } | ||||
|  | ||||
|     private void createUser(String userName) | ||||
| @@ -117,18 +121,13 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|      */ | ||||
|     public void testRelativePath() throws Exception | ||||
|     { | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content"); | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content"); | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         // uri with relative path at the end | ||||
|         String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2"; | ||||
| @@ -138,7 +137,46 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|         Assert.assertEquals("doc2 file content", resp.getContentAsString()); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content) | ||||
|  | ||||
|  | ||||
|     public void testForcedAttachment() throws Exception | ||||
|     { | ||||
|         NodeRef testhtml = createNodeWithTextContent(rootFolder, "testhtml", ContentModel.TYPE_CONTENT, "testhtml content", MimetypeMap.MIMETYPE_HTML); | ||||
|         NodeRef testpdf = createNodeWithTextContent(rootFolder, "testpdf", ContentModel.TYPE_CONTENT, "testpdf content", MimetypeMap.MIMETYPE_PDF); | ||||
|  | ||||
|         String uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=false"; | ||||
|         GetRequest req = new GetRequest(uri); | ||||
|         Response res = sendRequest(req, 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=false"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content, String mimetype) | ||||
|     { | ||||
|         NodeRef nodeRef = createNode(parentNode, nodeCmName, nodeType); | ||||
|  | ||||
| @@ -146,7 +184,7 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|         if (content != null) | ||||
|         { | ||||
|             ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); | ||||
|             writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|             writer.setMimetype(mimetype); | ||||
|             writer.setEncoding("UTF-8"); | ||||
|             writer.putContent(content); | ||||
|         } | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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% | ||||
|  */ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.repo.web.util; | ||||
|  | ||||
| import java.io.BufferedReader; | ||||
| @@ -32,6 +32,7 @@ import java.io.InputStreamReader; | ||||
| import java.net.InetAddress; | ||||
| import java.net.ServerSocket; | ||||
| import java.net.Socket; | ||||
| import java.util.Arrays; | ||||
| import java.util.Date; | ||||
|  | ||||
| import javax.servlet.ServletContext; | ||||
| @@ -44,7 +45,8 @@ import org.alfresco.util.TempFileProvider; | ||||
| import org.alfresco.util.WebApplicationContextLoader; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.eclipse.jetty.security.HashLoginService; | ||||
| import org.eclipse.jetty.http.UriCompliance; | ||||
| import org.eclipse.jetty.server.HttpConnectionFactory; | ||||
| import org.eclipse.jetty.server.Server; | ||||
| import org.eclipse.jetty.webapp.WebAppContext; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| @@ -145,6 +147,8 @@ public abstract class AbstractJettyComponent implements JettyComponent | ||||
| 		     | ||||
| 		    configureWebAppContext(webAppContext); | ||||
|  | ||||
| 			ignoreAmbiguousLinks(server); | ||||
|  | ||||
| 		    server.start(); | ||||
|  | ||||
| 			if(logger.isDebugEnabled()) | ||||
| @@ -203,15 +207,27 @@ public abstract class AbstractJettyComponent implements JettyComponent | ||||
| 				} | ||||
| 			}     | ||||
| 		}); | ||||
| 	     | ||||
| 	    // with a login-config in web.xml, jetty seems to require this in order to start successfully | ||||
| 	    webAppContext.getSecurityHandler().setLoginService(new HashLoginService()); | ||||
|  | ||||
| 	    // arbitrary temporary file location | ||||
| 	    File tmp = new File(TempFileProvider.getSystemTempDir(), String.valueOf(System.currentTimeMillis())); | ||||
| 	    webAppContext.setResourceBase(tmp.getAbsolutePath());		 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * In newer jetty versions there is a stricter check for links e.g. "//" is not allowed, which clashes | ||||
| 	 * with some of our tests, because even a NodeRef triggers it - "workspace://..." | ||||
| 	 * Since Jetty is only used in tests it's alright to block this behaviour. | ||||
| 	 * | ||||
| 	 * @param server | ||||
| 	 */ | ||||
| 	private void ignoreAmbiguousLinks(Server server) { | ||||
| 		Arrays.stream(server.getConnectors()) | ||||
| 				.flatMap(c -> c.getConnectionFactories().stream()) | ||||
| 				.filter(cf -> cf instanceof HttpConnectionFactory) | ||||
| 				.map(cf -> (HttpConnectionFactory) cf) | ||||
| 				.forEach(hcf -> hcf.getHttpConfiguration().setUriCompliance(UriCompliance.RFC3986)); | ||||
| 	} | ||||
|  | ||||
| 	public void shutdown() | ||||
| 	{ | ||||
| 		try | ||||
|   | ||||
| @@ -26,9 +26,10 @@ | ||||
|  | ||||
| package org.alfresco.rest.api; | ||||
|  | ||||
| import org.alfresco.rest.api.impl.RulesImplTest; | ||||
| import org.alfresco.rest.api.impl.rules.NodeValidatorTest; | ||||
| import org.alfresco.rest.api.model.rules.ActionTest; | ||||
| import org.alfresco.rest.api.model.rules.CompositeConditionTest; | ||||
| import org.alfresco.rest.api.impl.rules.RulesImplTest; | ||||
| import org.alfresco.rest.api.model.rules.RuleTest; | ||||
| import org.alfresco.rest.api.model.rules.SimpleConditionTest; | ||||
| import org.alfresco.rest.api.nodes.NodeRulesRelationTest; | ||||
| @@ -41,6 +42,7 @@ import org.junit.runners.Suite; | ||||
| @Suite.SuiteClasses({ | ||||
|     NodeRulesRelationTest.class, | ||||
|     RulesImplTest.class, | ||||
|     NodeValidatorTest.class, | ||||
|     RuleTest.class, | ||||
|     ActionTest.class, | ||||
|     SimpleConditionTest.class, | ||||
|   | ||||
| @@ -1,667 +0,0 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl; | ||||
|  | ||||
| import static java.util.Collections.emptyList; | ||||
|  | ||||
| import static org.alfresco.rest.api.model.rules.RuleSet.DEFAULT_ID; | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.DENIED; | ||||
| import static org.alfresco.service.cmr.security.PermissionService.CHANGE_PERMISSIONS; | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.isNull; | ||||
| import static org.mockito.BDDMockito.given; | ||||
| import static org.mockito.BDDMockito.then; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.times; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| import junit.framework.TestCase; | ||||
| import org.alfresco.repo.action.ActionImpl; | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.model.rules.CompositeCondition; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.action.Action; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.repository.StoreRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.alfresco.service.cmr.security.PermissionService; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.mockito.InjectMocks; | ||||
| import org.mockito.Mock; | ||||
| import org.mockito.MockitoAnnotations; | ||||
| import org.mockito.junit.MockitoJUnitRunner; | ||||
|  | ||||
| @Experimental | ||||
| @RunWith(MockitoJUnitRunner.class) | ||||
| public class RulesImplTest extends TestCase | ||||
| { | ||||
|     private static final String FOLDER_NODE_ID = "dummy-folder-node-id"; | ||||
|     private static final String RULE_SET_ID = "dummy-rule-set-id"; | ||||
|     private static final String RULE_ID = "dummy-rule-id"; | ||||
|     private static final NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, FOLDER_NODE_ID); | ||||
|     private static final NodeRef ruleSetNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_SET_ID); | ||||
|     private static final NodeRef ruleNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_ID); | ||||
|     private static final Paging paging = Paging.DEFAULT; | ||||
|     private static final Action action = new ActionImpl(folderNodeRef, "actionId", "actionDefinitionName"); | ||||
|     private static final String RULE_NAME = "Rule name"; | ||||
|  | ||||
|     @Mock | ||||
|     private Nodes nodesMock; | ||||
|  | ||||
|     @Mock | ||||
|     private PermissionService permissionServiceMock; | ||||
|  | ||||
|     @Mock | ||||
|     private RuleService ruleServiceMock; | ||||
|  | ||||
|     @InjectMocks | ||||
|     private RulesImpl rules; | ||||
|  | ||||
|     @Before | ||||
|     @Override | ||||
|     public void setUp() throws Exception | ||||
|     { | ||||
|         MockitoAnnotations.openMocks(this); | ||||
|  | ||||
|         given(nodesMock.validateOrLookupNode(eq(FOLDER_NODE_ID), any())).willReturn(folderNodeRef); | ||||
|         given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef); | ||||
|         given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef); | ||||
|         given(nodesMock.nodeMatches(any(), any(), any())).willReturn(true); | ||||
|         given(permissionServiceMock.hasReadPermission(any())).willReturn(ALLOWED); | ||||
|         given(permissionServiceMock.hasPermission(any(), any())).willReturn(ALLOWED); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRules() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.getRules(any())).willReturn(List.of(createRule(RULE_ID))); | ||||
|  | ||||
|         // when | ||||
|         final CollectionWithPagingInfo<Rule> rulesPage = rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().getRules(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rulesPage) | ||||
|                 .isNotNull() | ||||
|             .extracting(CollectionWithPagingInfo::getCollection) | ||||
|                 .isNotNull() | ||||
|             .extracting(Collection::size) | ||||
|                 .isEqualTo(1); | ||||
|         assertThat(rulesPage.getCollection().stream().findFirst().orElse(null)) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesForDefaultRuleSet() | ||||
|     { | ||||
|         given(ruleServiceMock.getRuleSetNode(any())).willReturn(ruleSetNodeRef); | ||||
|         given(ruleServiceMock.getRules(any())).willReturn(List.of(createRule(RULE_ID))); | ||||
|  | ||||
|         // when | ||||
|         final CollectionWithPagingInfo<Rule> rulesPage = rules.getRules(FOLDER_NODE_ID, DEFAULT_ID, paging); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().getRules(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rulesPage) | ||||
|                 .isNotNull() | ||||
|             .extracting(CollectionWithPagingInfo::getCollection) | ||||
|                 .isNotNull() | ||||
|             .extracting(Collection::size) | ||||
|                 .isEqualTo(1); | ||||
|         assertThat(rulesPage.getCollection().stream().findFirst().orElse(null)) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesForNotExistingFolderNode() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(eq(folderNodeRef), any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesForNotExistingRuleSetNode() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(eq(folderNodeRef), any(), any())).willReturn(true); | ||||
|         given(nodesMock.nodeMatches(eq(ruleSetNodeRef), any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesForNotExistingDefaultRuleSetNode() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(eq(folderNodeRef), any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.getRuleSetNode(folderNodeRef)).willReturn(null); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(RelationshipResourceNotFoundException.class).isThrownBy( | ||||
|                 () -> rules.getRules(FOLDER_NODE_ID, DEFAULT_ID, paging)); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesForNotAssociatedRuleSetToFolder() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRulesWithoutReadPermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasReadPermission(any())).willReturn(DENIED); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy( | ||||
|             () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleById() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.getRule(any())).willReturn(createRule(RULE_ID)); | ||||
|  | ||||
|         // when | ||||
|         final Rule rule = rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().getRule(ruleNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rule) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleByIdForDefaultRuleSet() | ||||
|     { | ||||
|         final String defaultRuleSetId = "-default-"; | ||||
|         given(ruleServiceMock.getRuleSetNode(any())).willReturn(ruleSetNodeRef); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.getRule(any())).willReturn(createRule(RULE_ID)); | ||||
|  | ||||
|         // when | ||||
|         final Rule rule = rules.getRuleById(FOLDER_NODE_ID, defaultRuleSetId, RULE_ID); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().getRule(ruleNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rule) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleByIdForNotAssociatedRuleToRuleSet() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     /** Create a single rule. */ | ||||
|     @Test | ||||
|     public void testSaveRules() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         List<Rule> ruleList = List.of(ruleBody); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         List<Rule> expected = List.of(Rule.from(serviceRule, false)); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     /** Check that when passing the default rule set then we don't perform any validation around the rule set node. */ | ||||
|     @Test | ||||
|     public void testSaveRules_defaultRuleSet() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         List<Rule> ruleList = List.of(ruleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         given(ruleServiceMock.getRuleSetNode(any())).willReturn(ruleSetNodeRef); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), DEFAULT_ID, ruleList); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         List<Rule> expected = List.of(Rule.from(serviceRule, false)); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testSaveRules_ruleSetNotAssociatedWithFolder() | ||||
|     { | ||||
|         Rule rule = Rule.builder().name(RULE_NAME).create(); | ||||
|         List<Rule> ruleList = List.of(rule); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef)).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|                 () -> rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testSaveRules_emptyRuleList() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         List<Rule> ruleList = emptyList(); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = this.rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(actual).isEqualTo(emptyList()); | ||||
|     } | ||||
|  | ||||
|     /** Create three rules in a single call and check they are all passed to the RuleService. */ | ||||
|     @Test | ||||
|     public void testSaveRules_createMultipleRules() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         List<Rule> ruleBodyList = new ArrayList<>(); | ||||
|         List<Rule> expected = new ArrayList<>(); | ||||
|         for (String ruleId : List.of("A", "B", "C")) | ||||
|         { | ||||
|             Rule ruleBody = mock(Rule.class); | ||||
|             ruleBodyList.add(ruleBody); | ||||
|             org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|             given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|             org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|             given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|             NodeRef ruleNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, ruleId); | ||||
|             given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|             given(serviceRule.getAction()).willReturn(action); | ||||
|             expected.add(Rule.from(serviceRule, false)); | ||||
|         } | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleBodyList); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         for (Rule ruleBody : ruleBodyList) | ||||
|         { | ||||
|             then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         } | ||||
|         then(ruleServiceMock).should(times(ruleBodyList.size())).isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     /** Try to create a rule without CHANGE permission and check an exception is thrown. */ | ||||
|     @Test | ||||
|     public void testSaveRules_noChangePermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasPermission(folderNodeRef, CHANGE_PERMISSIONS)).willReturn(DENIED); | ||||
|  | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         List<Rule> ruleList = List.of(ruleBody); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy(() -> | ||||
|                 rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     /** Check that we can update a rule. */ | ||||
|     @Test | ||||
|     public void testUpdateRules() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef)).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleSetShared(ruleSetNodeRef)).willReturn(true); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         Rule updatedRule = rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, ruleBody); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, serviceRuleBody); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|  | ||||
|         Rule expected = Rule.builder().id(RULE_ID) | ||||
|                                       .enabled(true) | ||||
|                                       .shared(true) | ||||
|                                       .triggers(emptyList()) | ||||
|                                       .conditions(CompositeCondition.builder().inverted(false).create()) | ||||
|                                       .create(); | ||||
|         assertThat(updatedRule).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     /** Check that we get an error if the rule set is not a child of the folder. */ | ||||
|     @Test | ||||
|     public void testUpdateRules_ruleSetNotInFolder() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef)).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy(() -> | ||||
|                 rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, ruleBody)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     /** Check that we get an error if the rule is not a child of the rule set. */ | ||||
|     @Test | ||||
|     public void testUpdateRules_ruleNotInRuleSet() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef)).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy(() -> | ||||
|                 rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, ruleBody)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     /** Try to update a rule without CHANGE permission and check an exception is thrown. */ | ||||
|     @Test | ||||
|     public void testUpdateRules_noChangePermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasPermission(folderNodeRef, CHANGE_PERMISSIONS)).willReturn(DENIED); | ||||
|  | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy(() -> | ||||
|                 rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, ruleBody)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById() { | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         org.alfresco.service.cmr.rule.Rule rule = createRule(RULE_ID); | ||||
|         given(ruleServiceMock.getRule(any())).willReturn(rule); | ||||
|  | ||||
|         //when | ||||
|         rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).should().getRule(ruleNodeRef); | ||||
|         then(ruleServiceMock).should().removeRule(folderNodeRef, rule); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_NonExistingRuleId() { | ||||
|         given(nodesMock.validateNode(RULE_ID)).willThrow(new EntityNotFoundException(RULE_ID)); | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_RuleIdNotInRuleSet() { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(false); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_NonExistingRuleSetId() { | ||||
|         given(nodesMock.validateNode(RULE_SET_ID)).willThrow(new EntityNotFoundException(RULE_SET_ID)); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_RuleSetNotInFolder() { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(false); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().nodeMatches(eq(folderNodeRef), any(), isNull()); | ||||
|         then(nodesMock).should().nodeMatches(eq(ruleSetNodeRef), any(), isNull()); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_NonExistingFolderId() { | ||||
|         given(nodesMock.validateOrLookupNode(FOLDER_NODE_ID, null)).willThrow(new EntityNotFoundException(RULE_ID)); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     /** Try to delete a rule without CHANGE permission and check an exception is thrown. */ | ||||
|     @Test | ||||
|     public void testDeleteRuleById_noChangePermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasPermission(folderNodeRef, CHANGE_PERMISSIONS)).willReturn(DENIED); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy(() -> | ||||
|                 rules.deleteRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID)); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     private static org.alfresco.service.cmr.rule.Rule createRule(final String id) { | ||||
|         final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id); | ||||
|         final org.alfresco.service.cmr.rule.Rule rule = new org.alfresco.service.cmr.rule.Rule(); | ||||
|         rule.setNodeRef(nodeRef); | ||||
|         rule.setRuleType("ruleType"); | ||||
|         rule.setAction(action); | ||||
|  | ||||
|         return rule; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,379 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl.rules; | ||||
|  | ||||
| import static org.alfresco.model.ContentModel.TYPE_FOLDER; | ||||
| import static org.alfresco.model.ContentModel.TYPE_SYSTEM_FOLDER; | ||||
| import static org.alfresco.repo.rule.RuleModel.TYPE_RULE; | ||||
| import static org.alfresco.rest.api.model.rules.RuleSet.DEFAULT_ID; | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.DENIED; | ||||
| import static org.alfresco.service.cmr.security.PermissionService.CHANGE_PERMISSIONS; | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.BDDMockito.given; | ||||
| import static org.mockito.BDDMockito.then; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.repository.StoreRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.alfresco.service.cmr.security.PermissionService; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.mockito.InjectMocks; | ||||
| import org.mockito.Mock; | ||||
| import org.mockito.MockitoAnnotations; | ||||
|  | ||||
| public class NodeValidatorTest | ||||
| { | ||||
|  | ||||
|     private static final String FOLDER_NODE_ID = "dummy-folder-node-id"; | ||||
|     private static final String RULE_SET_ID = "dummy-rule-set-id"; | ||||
|     private static final String RULE_ID = "dummy-rule-id"; | ||||
|     private static final NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, FOLDER_NODE_ID); | ||||
|     private static final NodeRef ruleSetNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_SET_ID); | ||||
|     private static final NodeRef ruleNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_ID); | ||||
|  | ||||
|     @Mock | ||||
|     private Nodes nodesMock; | ||||
|  | ||||
|     @Mock | ||||
|     private PermissionService permissionServiceMock; | ||||
|  | ||||
|     @Mock | ||||
|     private RuleService ruleServiceMock; | ||||
|  | ||||
|     @InjectMocks | ||||
|     private NodeValidator nodeValidator; | ||||
|  | ||||
|     @Before | ||||
|     public void setUp() throws Exception | ||||
|     { | ||||
|         MockitoAnnotations.openMocks(this); | ||||
|         given(nodesMock.validateOrLookupNode(eq(FOLDER_NODE_ID), any())).willReturn(folderNodeRef); | ||||
|         given(nodesMock.validateNode(RULE_SET_ID)).willReturn(ruleSetNodeRef); | ||||
|         given(nodesMock.validateNode(RULE_ID)).willReturn(ruleNodeRef); | ||||
|         given(nodesMock.nodeMatches(any(), any(), any())).willReturn(true); | ||||
|         given(permissionServiceMock.hasReadPermission(any())).willReturn(ALLOWED); | ||||
|         given(permissionServiceMock.hasPermission(any(), any())).willReturn(ALLOWED); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateFolderNode() | ||||
|     { | ||||
|         // when | ||||
|         final NodeRef nodeRef = nodeValidator.validateFolderNode(FOLDER_NODE_ID, false); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(nodeRef).isNotNull().isEqualTo(folderNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateFolderNode_notExistingFolder() | ||||
|     { | ||||
|         given(nodesMock.validateOrLookupNode(any(), any())).willThrow(new EntityNotFoundException(FOLDER_NODE_ID)); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateFolderNode_notMatchingTypeFolder() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(any(), eq(Set.of(TYPE_FOLDER)), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false)); | ||||
|  | ||||
|         then(nodesMock).should().validateOrLookupNode(FOLDER_NODE_ID, null); | ||||
|         then(nodesMock).should().nodeMatches(folderNodeRef, Set.of(TYPE_FOLDER), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateFolderNode_noReadPermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasReadPermission(any())).willReturn(DENIED); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateFolderNode(FOLDER_NODE_ID, false)); | ||||
|  | ||||
|         then(permissionServiceMock).should().hasReadPermission(folderNodeRef); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateFolderNode_noChangePermission() | ||||
|     { | ||||
|         given(permissionServiceMock.hasPermission(any(), any())).willReturn(DENIED); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(PermissionDeniedException.class).isThrownBy(() -> | ||||
|             nodeValidator.validateFolderNode(folderNodeRef.getId(), true)); | ||||
|  | ||||
|         then(permissionServiceMock).should().hasPermission(folderNodeRef, CHANGE_PERMISSIONS); | ||||
|         then(permissionServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void validateRuleSetNode() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(true); | ||||
|  | ||||
|         // when | ||||
|         final NodeRef nodeRef = nodeValidator.validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().nodeMatches(ruleSetNodeRef, Set.of(TYPE_SYSTEM_FOLDER), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(nodeRef).isNotNull().isEqualTo(ruleSetNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void validateRuleSetNode_defaultId() | ||||
|     { | ||||
|         given(ruleServiceMock.getRuleSetNode(any())).willReturn(ruleSetNodeRef); | ||||
|  | ||||
|         // when | ||||
|         final NodeRef nodeRef = nodeValidator.validateRuleSetNode(DEFAULT_ID, folderNodeRef); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(nodesMock).shouldHaveNoInteractions(); | ||||
|         then(permissionServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(nodeRef).isNotNull().isEqualTo(ruleSetNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleSetNode_notExistingRuleSet() | ||||
|     { | ||||
|         given(nodesMock.validateNode(RULE_SET_ID)).willThrow(new EntityNotFoundException(RULE_SET_ID)); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleSetNode(RULE_SET_ID, folderNodeRef)); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleSetNode_notMatchingTypeSystemFolder() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(any(), eq(Set.of(TYPE_SYSTEM_FOLDER)), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleSetNode(RULE_SET_ID, folderNodeRef)); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_SET_ID); | ||||
|         then(nodesMock).should().nodeMatches(ruleSetNodeRef, Set.of(TYPE_SYSTEM_FOLDER), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleSetNode_notExistingDefaultRuleSet() | ||||
|     { | ||||
|         given(ruleServiceMock.getRuleSetNode(folderNodeRef)).willReturn(null); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(RelationshipResourceNotFoundException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleSetNode(DEFAULT_ID, folderNodeRef)); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(nodesMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleSetNode_notAssociatedRuleSetToFolder() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetAssociatedWithFolder(any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleSetNode(RULE_SET_ID, folderNodeRef)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetAssociatedWithFolder(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void validateRuleNode() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(true); | ||||
|  | ||||
|         // when | ||||
|         final NodeRef nodeRef = nodeValidator.validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(ruleNodeRef, Set.of(TYPE_RULE), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         then(permissionServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(nodeRef).isNotNull().isEqualTo(ruleNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void validateRuleNode_nullRuleSet() | ||||
|     { | ||||
|         // when | ||||
|         final NodeRef nodeRef = nodeValidator.validateRuleNode(RULE_ID, null); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(ruleNodeRef, Set.of(TYPE_RULE), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         then(permissionServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(nodeRef).isNotNull().isEqualTo(ruleNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleNode_notExistingRule() | ||||
|     { | ||||
|         given(nodesMock.validateNode(RULE_ID)).willThrow(new EntityNotFoundException(RULE_ID)); | ||||
|  | ||||
|         //when | ||||
|         assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleNode(RULE_ID, ruleSetNodeRef)); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleNode_notMatchingTypeRule() | ||||
|     { | ||||
|         given(nodesMock.nodeMatches(any(), eq(Set.of(TYPE_RULE)), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleNode(RULE_ID, ruleSetNodeRef)); | ||||
|  | ||||
|         then(nodesMock).should().validateNode(RULE_ID); | ||||
|         then(nodesMock).should().nodeMatches(ruleNodeRef, Set.of(TYPE_RULE), null); | ||||
|         then(nodesMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testValidateRuleNode_notAssociatedRuleToRuleSet() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleAssociatedWithRuleSet(any(), any())).willReturn(false); | ||||
|  | ||||
|         // when | ||||
|         assertThatExceptionOfType(InvalidArgumentException.class).isThrownBy( | ||||
|             () -> nodeValidator.validateRuleNode(RULE_ID, ruleSetNodeRef)); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleAssociatedWithRuleSet(ruleNodeRef, ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testIsRuleSetNotNullAndShared() | ||||
|     { | ||||
|         given(ruleServiceMock.isRuleSetShared(any())).willReturn(true); | ||||
|  | ||||
|         // when | ||||
|         final boolean shared = nodeValidator.isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         assertThat(shared).isTrue(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testIsRuleSetNotNullAndShared_nullRuleSetNode() | ||||
|     { | ||||
|         // when | ||||
|         final boolean shared = nodeValidator.isRuleSetNotNullAndShared(null); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|  | ||||
|         assertThat(shared).isFalse(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testIsRuleSetNotNullAndShared_withoutRuleSetAndWithFolder() | ||||
|     { | ||||
|         given(ruleServiceMock.getRuleSetNode(any())).willReturn(ruleSetNodeRef); | ||||
|  | ||||
|         // when | ||||
|         nodeValidator.isRuleSetNotNullAndShared(null, folderNodeRef); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(folderNodeRef); | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testIsRuleSetNotNullAndShared_withRuleSetAndWithFolder() | ||||
|     { | ||||
|         // when | ||||
|         nodeValidator.isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|  | ||||
|         then(ruleServiceMock).should().isRuleSetShared(ruleSetNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,133 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl.rules; | ||||
|  | ||||
| import static java.util.Collections.emptyList; | ||||
|  | ||||
| import static org.mockito.ArgumentMatchers.anyBoolean; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.BDDMockito.given; | ||||
| import static org.mockito.BDDMockito.then; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| import junit.framework.TestCase; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.repository.StoreRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.mockito.InjectMocks; | ||||
| import org.mockito.Mock; | ||||
| import org.mockito.MockitoAnnotations; | ||||
| import org.mockito.junit.MockitoJUnitRunner; | ||||
|  | ||||
| /** Unit tests for {@link RuleSetsImpl}. */ | ||||
| @Experimental | ||||
| @RunWith (MockitoJUnitRunner.class) | ||||
| public class RuleSetsImplTest extends TestCase | ||||
| { | ||||
|     private static final String FOLDER_ID = "dummy-folder-id"; | ||||
|     private static final String RULE_SET_ID = "dummy-rule-set-id"; | ||||
|     private static final NodeRef FOLDER_NODE = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, FOLDER_ID); | ||||
|     private static final NodeRef RULE_SET_NODE = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_SET_ID); | ||||
|     private static final Paging PAGING = Paging.DEFAULT; | ||||
|  | ||||
|     @InjectMocks | ||||
|     private RuleSetsImpl ruleSets; | ||||
|     @Mock | ||||
|     private NodeValidator nodeValidatorMock; | ||||
|     @Mock | ||||
|     private RuleService ruleServiceMock; | ||||
|  | ||||
|     @Before | ||||
|     @Override | ||||
|     public void setUp() | ||||
|     { | ||||
|         MockitoAnnotations.openMocks(this); | ||||
|  | ||||
|         given(nodeValidatorMock.validateFolderNode(eq(FOLDER_ID), anyBoolean())).willReturn(FOLDER_NODE); | ||||
|         //given(nodeValidatorMock.validateFolderNode(eq(RULE_SET_ID), anyBoolean())).willReturn(RULE_SET_NODE); | ||||
|         given(nodeValidatorMock.validateRuleSetNode(RULE_SET_ID, FOLDER_NODE)).willReturn(RULE_SET_NODE); | ||||
|  | ||||
|         given(ruleServiceMock.getRuleSetNode(FOLDER_NODE)).willReturn(RULE_SET_NODE); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleSets() | ||||
|     { | ||||
|         // Call the method under test. | ||||
|         CollectionWithPagingInfo<RuleSet> actual = ruleSets.getRuleSets(FOLDER_ID, null, PAGING); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(FOLDER_NODE); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         Collection<RuleSet> expected = List.of(RuleSet.of(RULE_SET_ID)); | ||||
|         assertEquals(expected, actual.getCollection()); | ||||
|         assertEquals(PAGING, actual.getPaging()); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetZeroRuleSets() | ||||
|     { | ||||
|         // Simulate no rule sets for the folder. | ||||
|         given(ruleServiceMock.getRuleSetNode(FOLDER_NODE)).willReturn(null); | ||||
|  | ||||
|         // Call the method under test. | ||||
|         CollectionWithPagingInfo<RuleSet> actual = ruleSets.getRuleSets(FOLDER_ID, null, PAGING); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRuleSetNode(FOLDER_NODE); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         assertEquals(emptyList(), actual.getCollection()); | ||||
|         assertEquals(PAGING, actual.getPaging()); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleSetById() | ||||
|     { | ||||
|         // Call the method under test. | ||||
|         RuleSet actual = ruleSets.getRuleSetById(FOLDER_ID, RULE_SET_ID, null); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, FOLDER_NODE); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|         assertEquals(RuleSet.of(RULE_SET_ID), actual); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,614 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.impl.rules; | ||||
|  | ||||
| import static java.util.Collections.emptyList; | ||||
|  | ||||
| import static org.alfresco.rest.api.model.rules.RuleSet.DEFAULT_ID; | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyBoolean; | ||||
| import static org.mockito.BDDMockito.given; | ||||
| import static org.mockito.BDDMockito.then; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.times; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| import junit.framework.TestCase; | ||||
| import org.alfresco.repo.action.ActionImpl; | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.model.rules.CompositeCondition; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.action.Action; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.repository.StoreRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.mockito.InjectMocks; | ||||
| import org.mockito.Mock; | ||||
| import org.mockito.Mockito; | ||||
| import org.mockito.MockitoAnnotations; | ||||
| import org.mockito.junit.MockitoJUnitRunner; | ||||
|  | ||||
| @Experimental | ||||
| @RunWith(MockitoJUnitRunner.class) | ||||
| public class RulesImplTest extends TestCase | ||||
| { | ||||
|     private static final String FOLDER_NODE_ID = "dummy-folder-node-id"; | ||||
|     private static final String RULE_SET_ID = "dummy-rule-set-id"; | ||||
|     private static final String RULE_ID = "dummy-rule-id"; | ||||
|     private static final NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, FOLDER_NODE_ID); | ||||
|     private static final NodeRef ruleSetNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_SET_ID); | ||||
|     private static final NodeRef ruleNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, RULE_ID); | ||||
|     private static final Paging paging = Paging.DEFAULT; | ||||
|     private static final Action action = new ActionImpl(folderNodeRef, "actionId", "actionDefinitionName"); | ||||
|  | ||||
|     @Mock | ||||
|     private Nodes nodesMock; | ||||
|  | ||||
|     @Mock | ||||
|     private NodeValidator nodeValidatorMock; | ||||
|  | ||||
|     @Mock | ||||
|     private RuleService ruleServiceMock; | ||||
|  | ||||
|     @InjectMocks | ||||
|     private RulesImpl rules; | ||||
|  | ||||
|     @Before | ||||
|     @Override | ||||
|     public void setUp() throws Exception | ||||
|     { | ||||
|         MockitoAnnotations.openMocks(this); | ||||
|         given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|         given(nodeValidatorMock.validateRuleSetNode(any(), any())).willReturn(ruleSetNodeRef); | ||||
|         given(nodeValidatorMock.validateRuleNode(any(), any())).willReturn(ruleNodeRef); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRules() | ||||
|     { | ||||
|         given(ruleServiceMock.getRules(any())).willReturn(List.of(createRule(RULE_ID))); | ||||
|  | ||||
|         // when | ||||
|         final CollectionWithPagingInfo<Rule> rulesPage = rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().getRules(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rulesPage) | ||||
|                 .isNotNull() | ||||
|             .extracting(CollectionWithPagingInfo::getCollection) | ||||
|                 .isNotNull() | ||||
|             .extracting(Collection::size) | ||||
|                 .isEqualTo(1); | ||||
|         assertThat(rulesPage.getCollection().stream().findFirst().orElse(null)) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRules_emptyResult() | ||||
|     { | ||||
|         given(ruleServiceMock.getRules(any())).willReturn(emptyList()); | ||||
|  | ||||
|         // when | ||||
|         final CollectionWithPagingInfo<Rule> rulesPage = rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging); | ||||
|  | ||||
|         then(ruleServiceMock).should().getRules(folderNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rulesPage) | ||||
|             .isNotNull() | ||||
|             .extracting(CollectionWithPagingInfo::getCollection) | ||||
|             .isNotNull() | ||||
|             .extracting(Collection::isEmpty) | ||||
|             .isEqualTo(true); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRules_invalidFolder() | ||||
|     { | ||||
|         for (Exception exception : folderValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRules_invalidRuleSet() | ||||
|     { | ||||
|         for (Exception exception : ruleSetValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.getRules(FOLDER_NODE_ID, RULE_SET_ID, paging)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleById() | ||||
|     { | ||||
|         given(ruleServiceMock.getRule(any())).willReturn(createRule(RULE_ID)); | ||||
|  | ||||
|         // when | ||||
|         final Rule rule = rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(nodesMock).shouldHaveNoInteractions(); | ||||
|         then(ruleServiceMock).should().getRule(ruleNodeRef); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(rule) | ||||
|                 .isNotNull() | ||||
|             .extracting(Rule::getId) | ||||
|                 .isEqualTo(RULE_ID); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleById_invalidFolder() | ||||
|     { | ||||
|         for (Exception exception : folderValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleById_invalidRuleSet() | ||||
|     { | ||||
|         for (Exception exception : ruleSetValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testGetRuleById_invalidRule() | ||||
|     { | ||||
|         for (Exception exception : ruleValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willReturn(ruleSetNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.getRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, false); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** Create a single rule. */ | ||||
|     @Test | ||||
|     public void testCreateRules() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         List<Rule> ruleList = List.of(ruleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         List<Rule> expected = List.of(Rule.from(serviceRule, false)); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     /** Check that when passing the default rule set then we don't perform any validation around the rule set node. */ | ||||
|     @Test | ||||
|     public void testCreateRules_defaultRuleSet() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         List<Rule> ruleList = List.of(ruleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), DEFAULT_ID, ruleList); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(null, folderNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         List<Rule> expected = List.of(Rule.from(serviceRule, false)); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testCreateRules_emptyRuleList() | ||||
|     { | ||||
|         List<Rule> ruleList = emptyList(); | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleList); | ||||
|  | ||||
|         then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         assertThat(actual).isEqualTo(emptyList()); | ||||
|     } | ||||
|  | ||||
|     /** Create three rules in a single call and check they are all passed to the RuleService. */ | ||||
|     @Test | ||||
|     public void testCreateRules_createMultipleRules() | ||||
|     { | ||||
|         List<Rule> ruleBodyList = new ArrayList<>(); | ||||
|         List<Rule> expected = new ArrayList<>(); | ||||
|         for (String ruleId : List.of("A", "B", "C")) | ||||
|         { | ||||
|             Rule ruleBody = mock(Rule.class); | ||||
|             ruleBodyList.add(ruleBody); | ||||
|             org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|             given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|             org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|             given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|             NodeRef ruleNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, ruleId); | ||||
|             given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|             given(serviceRule.getAction()).willReturn(action); | ||||
|             expected.add(Rule.from(serviceRule, false)); | ||||
|         } | ||||
|  | ||||
|         // when | ||||
|         List<Rule> actual = rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), ruleBodyList); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should(times(ruleBodyList.size())).isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         for (Rule ruleBody : ruleBodyList) | ||||
|         { | ||||
|             then(ruleServiceMock).should().saveRule(folderNodeRef, ruleBody.toServiceModel(nodesMock)); | ||||
|         } | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|         assertThat(actual).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testCreateRules_invalidFolder() | ||||
|     { | ||||
|         for (Exception exception : folderValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), emptyList())); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testCreateRules_invalidRuleSet() | ||||
|     { | ||||
|         for (Exception exception : ruleSetValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.createRules(folderNodeRef.getId(), ruleSetNodeRef.getId(), emptyList())); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** Check that we can update a rule. */ | ||||
|     @Test | ||||
|     public void testUpdateRuleById() | ||||
|     { | ||||
|         Rule ruleBody = mock(Rule.class); | ||||
|         given(nodeValidatorMock.isRuleSetNotNullAndShared(any(), any())).willReturn(true); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRuleBody = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleBody.toServiceModel(nodesMock)).willReturn(serviceRuleBody); | ||||
|         org.alfresco.service.cmr.rule.Rule serviceRule = mock(org.alfresco.service.cmr.rule.Rule.class); | ||||
|         given(ruleServiceMock.saveRule(folderNodeRef, serviceRuleBody)).willReturn(serviceRule); | ||||
|         given(serviceRule.getNodeRef()).willReturn(ruleNodeRef); | ||||
|         given(serviceRule.getAction()).willReturn(action); | ||||
|  | ||||
|         // when | ||||
|         Rule updatedRule = rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, ruleBody); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|         then(nodeValidatorMock).should().isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(ruleServiceMock).should().saveRule(folderNodeRef, serviceRuleBody); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|  | ||||
|  | ||||
|         Rule expected = Rule.builder().id(RULE_ID) | ||||
|                                       .enabled(true) | ||||
|                                       .shared(true) | ||||
|                                       .triggers(emptyList()) | ||||
|                                       .conditions(CompositeCondition.builder().inverted(false).create()) | ||||
|                                       .create(); | ||||
|         assertThat(updatedRule).isEqualTo(expected); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testUpdateRuleById_invalidFolder() | ||||
|     { | ||||
|         for (Exception exception : folderValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, mock(Rule.class))); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testUpdateRuleById_invalidRuleSet() | ||||
|     { | ||||
|         for (Exception exception : ruleSetValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, mock(Rule.class))); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testUpdateRuleById_invalidRule() | ||||
|     { | ||||
|         for (Exception exception : ruleValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willReturn(ruleSetNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.updateRuleById(folderNodeRef.getId(), ruleSetNodeRef.getId(), RULE_ID, mock(Rule.class))); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById() { | ||||
|         org.alfresco.service.cmr.rule.Rule rule = createRule(RULE_ID); | ||||
|         given(ruleServiceMock.getRule(any())).willReturn(rule); | ||||
|  | ||||
|         //when | ||||
|         rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID); | ||||
|  | ||||
|         then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|         then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|         then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|         then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|         then(nodesMock).shouldHaveNoInteractions(); | ||||
|         then(ruleServiceMock).should().getRule(ruleNodeRef); | ||||
|         then(ruleServiceMock).should().removeRule(folderNodeRef, rule); | ||||
|         then(ruleServiceMock).shouldHaveNoMoreInteractions(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_invalidFolder() | ||||
|     { | ||||
|         for (Exception exception : folderValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_invalidRuleSet() | ||||
|     { | ||||
|         for (Exception exception : ruleSetValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testDeleteRuleById_invalidRule() | ||||
|     { | ||||
|         for (Exception exception : ruleValidationExceptions()) | ||||
|         { | ||||
|             Mockito.reset(nodeValidatorMock); | ||||
|             given(nodeValidatorMock.validateFolderNode(any(), anyBoolean())).willReturn(folderNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleSetNode(any(), any())).willReturn(ruleSetNodeRef); | ||||
|             given(nodeValidatorMock.validateRuleNode(any(), any())).willThrow(exception); | ||||
|  | ||||
|             // when | ||||
|             assertThatExceptionOfType(exception.getClass()).isThrownBy( | ||||
|                 () -> rules.deleteRuleById(FOLDER_NODE_ID, RULE_SET_ID, RULE_ID)); | ||||
|  | ||||
|             then(nodeValidatorMock).should().validateFolderNode(FOLDER_NODE_ID, true); | ||||
|             then(nodeValidatorMock).should().validateRuleSetNode(RULE_SET_ID, folderNodeRef); | ||||
|             then(nodeValidatorMock).should().validateRuleNode(RULE_ID, ruleSetNodeRef); | ||||
|             then(nodeValidatorMock).shouldHaveNoMoreInteractions(); | ||||
|             then(ruleServiceMock).shouldHaveNoInteractions(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private static org.alfresco.service.cmr.rule.Rule createRule(final String id) { | ||||
|         final NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id); | ||||
|         final org.alfresco.service.cmr.rule.Rule rule = new org.alfresco.service.cmr.rule.Rule(); | ||||
|         rule.setNodeRef(nodeRef); | ||||
|         rule.setRuleType("ruleType"); | ||||
|         rule.setAction(action); | ||||
|  | ||||
|         return rule; | ||||
|     } | ||||
|  | ||||
|     private static List<Exception> folderValidationExceptions() | ||||
|     { | ||||
|         return List.of( | ||||
|             new EntityNotFoundException(FOLDER_NODE_ID), | ||||
|             new InvalidArgumentException(), | ||||
|             new PermissionDeniedException() | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     private static List<Exception> ruleSetValidationExceptions() | ||||
|     { | ||||
|         return List.of( | ||||
|             new EntityNotFoundException(RULE_SET_ID), | ||||
|             new InvalidArgumentException(), | ||||
|             new RelationshipResourceNotFoundException(RULE_SET_ID, "fake-relationship-id") | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     private static List<Exception> ruleValidationExceptions() | ||||
|     { | ||||
|         return List.of( | ||||
|             new EntityNotFoundException(RULE_ID), | ||||
|             new InvalidArgumentException(), | ||||
|             new RelationshipResourceNotFoundException(RULE_ID, "fake-relationship-id") | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| @@ -1,34 +1,30 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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% | ||||
|  */ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.tests; | ||||
|  | ||||
| import org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet; | ||||
| import org.eclipse.jetty.servlet.ServletHolder; | ||||
| import org.eclipse.jetty.webapp.WebAppContext; | ||||
|  | ||||
| /** | ||||
|  * Manages an embedded jetty server, hooking it up to the repository spring context and providing  | ||||
|  * authenticated, tenant-based access through the tenant servlet. | ||||
| @@ -42,15 +38,4 @@ public class EnterpriseJettyComponent extends PublicApiJettyComponent | ||||
| 	{ | ||||
| 		super(port, contextPath, configLocations, classLocations); | ||||
| 	} | ||||
| 	 | ||||
| 	@Override | ||||
| 	protected void configureWebAppContext(WebAppContext webAppContext) | ||||
| 	{ | ||||
| 		super.configureWebAppContext(webAppContext); | ||||
|  | ||||
| 	    // the tenant servlet with alfresco managed authentication | ||||
| 	    ServletHolder servletHolder = new ServletHolder(CmisAtomPubServlet.class); | ||||
| 	    servletHolder.setInitParameter("callContextHandler", "org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler"); | ||||
| 	    webAppContext.addServlet(servletHolder, "/cmisatom/*"); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -123,7 +123,7 @@ public class ModulePackagesApiTest extends AbstractBaseApiTest | ||||
|         assertNotNull(response); | ||||
|         assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusCode()); | ||||
|         assertEquals("no-cache", response.getHeaders().get("Cache-Control")); | ||||
|         assertEquals("application/json;charset=UTF-8", response.getHeaders().get("Content-Type")); | ||||
|         assertEquals("application/json;charset=utf-8", response.getHeaders().get("Content-Type")); | ||||
|  | ||||
|         PublicApiClient.ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse()); | ||||
|         assertNotNull(errorResponse); | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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% | ||||
|  */ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 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.rest.api.tests; | ||||
|  | ||||
| import org.alfresco.repo.web.util.AbstractJettyComponent; | ||||
| @@ -48,63 +48,16 @@ public class PublicApiJettyComponent extends AbstractJettyComponent | ||||
| 	@Override | ||||
| 	protected void configureWebAppContext(WebAppContext webAppContext) | ||||
| 	{ | ||||
| //		ServletContext servletContext = webAppContext.getServletContext(); | ||||
|  | ||||
| 	    // the tenant servlet with alfresco managed authentication | ||||
| 	    ServletHolder servletHolder = new ServletHolder(PublicApiWebScriptServlet.class); | ||||
| 	    servletHolder.setInitParameter("authenticator", "publicapi.authenticator"); | ||||
| 	    webAppContext.addServlet(servletHolder, "/" + publicApiServletName + "/*"); | ||||
| 	     | ||||
| //	    DependencyInjectedFilter apiFilter = (DependencyInjectedFilter)getApplicationContext().getBean("publicAPICMISFilter"); | ||||
| //	    BeanProxyFilter filter = new BeanProxyFilter(servletContext, apiFilter); | ||||
| //	    FilterHolder filterHolder = new FilterHolder(filter); | ||||
| //	    webAppContext.addFilter(filterHolder, "/" + publicApiServletName + "/*", null); | ||||
|  | ||||
|  | ||||
| 	    // the tenant servlet with alfresco managed authentication | ||||
| 	    servletHolder = new ServletHolder(CmisAtomPubServlet.class); | ||||
| 	    servletHolder.setInitParameter("callContextHandler", "org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler"); | ||||
| 	    webAppContext.addServlet(servletHolder, "/cmisatom/*"); | ||||
| 		webAppContext.addServlet(servletHolder, "/cmisatom/*"); | ||||
| 	} | ||||
| 	 | ||||
| //	private static class BeanProxyFilter implements Filter | ||||
| //	{ | ||||
| //	    private DependencyInjectedFilter filter; | ||||
| //	    private ServletContext context;     | ||||
| //	     | ||||
| //	    private BeanProxyFilter(ServletContext context, DependencyInjectedFilter filter) | ||||
| //	    { | ||||
| //	    	this.context = context; | ||||
| //	    	this.filter = filter; | ||||
| //	    } | ||||
| // | ||||
| //	    /** | ||||
| //	     * Initialize the filter. | ||||
| //	     *  | ||||
| //	     * @param args | ||||
| //	     *            FilterConfig | ||||
| //	     * @throws ServletException | ||||
| //	     *             the servlet exception | ||||
| //	     * @exception ServletException | ||||
| //	     */ | ||||
| //	    public void init(FilterConfig args) throws ServletException | ||||
| //	    { | ||||
| //	    } | ||||
| // | ||||
| //	    /* (non-Javadoc) | ||||
| //	     * @see javax.servlet.Filter#destroy() | ||||
| //	     */ | ||||
| //	    public void destroy() | ||||
| //	    { | ||||
| //	        this.filter = null; | ||||
| //	    } | ||||
| // | ||||
| //	    /* (non-Javadoc) | ||||
| //	     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) | ||||
| //	     */ | ||||
| //	    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, | ||||
| //	            ServletException | ||||
| //	    { | ||||
| //	        this.filter.doFilter(this.context, request, response, chain); | ||||
| //	    } | ||||
| //	} | ||||
| } | ||||
|   | ||||
| @@ -303,7 +303,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); | ||||
|         Map<String, String> responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(file1_MimeType+";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(file1_MimeType+";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertEquals("attachment; filename=\"" + fileName1 + "\"; filename*=UTF-8''" + fileName1 + "", responseHeaders.get("Content-Disposition")); | ||||
|         String lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); | ||||
| @@ -319,7 +319,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(file1_MimeType+";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(file1_MimeType+";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertNull(responseHeaders.get("Content-Disposition")); | ||||
| @@ -330,7 +330,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertArrayEquals(content2Text.getBytes(), response.getResponseAsBytes()); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(file2_MimeType+";charset=ISO-8859-1", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(file2_MimeType+";charset=iso-8859-1", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); | ||||
|         assertEquals("attachment; filename=\"" + fileName2 + "\"; filename*=UTF-8''" + fileName2 + "", responseHeaders.get("Content-Disposition")); | ||||
| @@ -392,7 +392,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertTrue(response.getResponseAsBytes().length > 0); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG+";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG+";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         String docName = "doclib"; | ||||
| @@ -405,7 +405,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertTrue(response.getResponseAsBytes().length > 0); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG+";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG+";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertNull(responseHeaders.get("Content-Disposition")); | ||||
|         lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); | ||||
| @@ -816,7 +816,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); | ||||
|         Map<String, String> responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(file1_MimeType + ";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(file1_MimeType + ";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertEquals("attachment; filename=\"" + fileName1 + "\"; filename*=UTF-8''" + fileName1 + "", responseHeaders.get("Content-Disposition")); | ||||
|         String lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); | ||||
| @@ -832,7 +832,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertArrayEquals(file1_originalBytes, response.getResponseAsBytes()); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(file1_MimeType + ";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(file1_MimeType + ";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertNull(responseHeaders.get("Content-Disposition")); | ||||
| @@ -888,7 +888,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertTrue(response.getResponseAsBytes().length > 0); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get(LAST_MODIFIED_HEADER)); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         String docName = "doclib"; | ||||
| @@ -901,7 +901,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest | ||||
|         assertTrue(response.getResponseAsBytes().length > 0); | ||||
|         responseHeaders = response.getHeaders(); | ||||
|         assertNotNull(responseHeaders); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=UTF-8", responseHeaders.get("Content-Type")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_IMAGE_PNG + ";charset=utf-8", responseHeaders.get("Content-Type")); | ||||
|         assertNotNull(responseHeaders.get("Expires")); | ||||
|         assertNull(responseHeaders.get("Content-Disposition")); | ||||
|         lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.66</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user