mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3546adcff5 | ||
|
c18a874b75 | ||
|
89d0c2afde | ||
|
bf1ac5b21d | ||
|
1afdd7ec5c | ||
|
7b52746802 | ||
|
65717ca6fd | ||
|
2849af129c | ||
|
6304125c09 | ||
|
50f9e5df10 | ||
|
f7b6e90d98 | ||
|
a6cc2d9964 | ||
|
c39047debe | ||
|
4a8c235f58 | ||
|
273a99f70f | ||
|
0691cb0162 | ||
|
23465b70e2 | ||
|
a7ef5157e2 | ||
|
25459e9a34 | ||
|
5b459e5c2e | ||
|
d451207427 | ||
|
563404bc8b | ||
|
3fe14df13b | ||
|
359106f323 | ||
|
331ce2cc59 | ||
|
e6f8e71b96 | ||
|
f502fced88 | ||
|
75248b0118 | ||
|
ff93971e54 | ||
|
15b1a960b7 | ||
|
00b043d444 | ||
|
79709ce48e | ||
|
c135d5ea8f | ||
|
06871bce8a | ||
|
58e595ce13 | ||
|
333a7dca98 | ||
|
0c810f5e80 | ||
|
4d930a6f18 | ||
|
ff68f92455 | ||
|
c88353ccb7 | ||
|
6b94ee41d4 | ||
|
a414aa3064 | ||
|
7914e87f77 | ||
|
4f63b3871e | ||
|
876962db57 | ||
|
5e2ff120ae | ||
|
2d95ccc754 | ||
|
3de741a78e | ||
|
8993ec9d5c | ||
|
428a82c195 | ||
|
519ef19c83 | ||
|
f19849b547 | ||
|
d956a4f4aa | ||
|
71f649d1bd |
18
.github/dependabot.yml
vendored
18
.github/dependabot.yml
vendored
@@ -53,6 +53,24 @@ updates:
|
||||
- dependency-name: org.freemarker:freemarker
|
||||
versions:
|
||||
- "> 2.3.20-alfresco-patched-20200421"
|
||||
- dependency-name: org.keycloak:keycloak-adapter-core
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.keycloak:keycloak-adapter-spi
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.keycloak:keycloak-authz-client
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.keycloak:keycloak-common
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.keycloak:keycloak-core
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.keycloak:keycloak-servlet-adapter-spi
|
||||
versions:
|
||||
- "> 12.0.2"
|
||||
- dependency-name: org.eclipse.jetty:jetty-server
|
||||
versions:
|
||||
- 9.4.38.v20210224
|
||||
|
549
.github/workflows/ci.yml
vendored
549
.github/workflows/ci.yml
vendored
@@ -1,549 +0,0 @@
|
||||
name: Alfresco Community Repo CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- feature/**
|
||||
- fix/**
|
||||
- master
|
||||
- release/**
|
||||
push:
|
||||
branches:
|
||||
- feature/**
|
||||
- fix/**
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
LOG_WARN: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
CI_WORKSPACE: ${{ github.workspace }}
|
||||
TAS_ENVIRONMENT: ./packaging/tests/environment
|
||||
TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: "Prepare"
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Prepare maven cache and check compilation"
|
||||
run: bash ./scripts/ci/prepare.sh
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
veracode:
|
||||
name: "Source Clear Scan (SCA)"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
((github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/veracode@v1.33.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
srcclr-api-token: ${{ secrets.SRCCLR_API_TOKEN }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
all_unit_tests_suite:
|
||||
name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run tests"
|
||||
run: |
|
||||
mvn -B test -pl core,data-model -am -DfailIfNoTests=false
|
||||
mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
remote_api_app_context_test_suites:
|
||||
name: Remote-api - ${{ matrix.testSuite }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- testSuite: AppContext01TestSuite
|
||||
compose-profile: default
|
||||
- testSuite: AppContext02TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext03TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext04TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContextExtraTestSuite
|
||||
compose-profile: default
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set transformers tag"
|
||||
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl remote-api -Dtest=${{ matrix.testSuite }} -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mariadb_tests:
|
||||
name: Repository - MariaDB ${{ matrix.version }} tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) &&
|
||||
github.event_name != 'pull_request' &&
|
||||
!contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: ['10.2.18', '10.4', '10.5']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: Run MariaDB ${{ matrix.version }} database
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
|
||||
env:
|
||||
MARIADB_VERSION: ${{ matrix.version }}
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mariadb_10_6_tests:
|
||||
name: "Repository - MariaDB 10.6 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
|
||||
!contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run MariaDB 10.6 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
|
||||
env:
|
||||
MARIADB_VERSION: 10.6
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mysql_tests:
|
||||
name: Repository - MySQL 8 tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
|
||||
!contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run MySQL 8 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mysql up -d
|
||||
env:
|
||||
MYSQL_VERSION: 8
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_13_7_tests:
|
||||
name: "Repository - PostgreSQL 13.7 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request' &&
|
||||
!contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run PostgreSQL 13.7 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: 13.7
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_14_4_tests:
|
||||
name: "Repository - PostgreSQL 14.4 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(!contains(github.event.head_commit.message, '[skip db]') ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run PostgreSQL 14.4 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: 14.4
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_messaging_tests:
|
||||
name: Repository - Messaging tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run ActiveMQ"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile activemq up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_app_context_test_suites:
|
||||
name: Repository - ${{ matrix.testSuite }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- testSuite: AppContext01TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext02TestSuite
|
||||
compose-profile: default
|
||||
- testSuite: AppContext03TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext04TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext05TestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '"-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"'
|
||||
- testSuite: AppContext06TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContextExtraTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: MiscContextTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: SearchTestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '-Dindex.subsystem.name=solr6'
|
||||
- testSuite: MTLSTestSuite
|
||||
compose-profile: with-mtls-transform-core-aio
|
||||
mtls: true
|
||||
disabledHostnameVerification: false
|
||||
mvn-options: '-Dencryption.ssl.keystore.location=${CI_WORKSPACE}/keystores/alfresco/alfresco.keystore -Dencryption.ssl.truststore.location=${CI_WORKSPACE}/keystores/alfresco/alfresco.truststore'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set transformers tag"
|
||||
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: "Generate Keystores and Truststores for Mutual TLS configuration"
|
||||
if: ${{ matrix.mtls }}
|
||||
run: |
|
||||
git clone -b "master" --depth=1 "https://${{ secrets.BOT_GITHUB_USERNAME }}:${{ secrets.BOT_GITHUB_TOKEN }}@github.com/Alfresco/alfresco-ssl-generator.git"
|
||||
if ${{ matrix.disabledHostnameVerification }} ; then
|
||||
bash ${{ env.CI_WORKSPACE }}/alfresco-ssl-generator/scripts/ci/generate_keystores_wrong_hostnames.sh
|
||||
echo "HOSTNAME_VERIFICATION_DISABLED=true" >> "$GITHUB_ENV"
|
||||
else
|
||||
bash ${{ env.CI_WORKSPACE }}/alfresco-ssl-generator/scripts/ci/generate_keystores.sh
|
||||
echo "HOSTNAME_VERIFICATION_DISABLED=false" >> "$GITHUB_ENV"
|
||||
fi
|
||||
- name: "Set up the environment"
|
||||
run: |
|
||||
if [ -e ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh ]; then
|
||||
bash ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh
|
||||
fi
|
||||
docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=${{ matrix.testSuite }} -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco ${{ matrix.mvn-options }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
tas_tests:
|
||||
name: ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
!contains(github.event.head_commit.message, '[skip tas]')) ||
|
||||
contains(github.event.head_commit.message, '[tas]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- test-name: "REST API TAS tests part1"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part1
|
||||
- test-name: "REST API TAS tests part2"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part2
|
||||
- test-name: "REST API TAS tests part3"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part3
|
||||
- test-name: "CMIS TAS tests - BROWSER binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-browser
|
||||
- test-name: "CMIS TAS tests - ATOM binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-atom
|
||||
- test-name: "CMIS TAS tests - WEBSERVICES binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-webservices
|
||||
- test-name: "Email TAS tests"
|
||||
pom-dir: tas-email
|
||||
- test-name: "WebDAV TAS tests"
|
||||
pom-dir: tas-webdav
|
||||
- test-name: "Integration TAS tests"
|
||||
pom-dir: tas-integration
|
||||
env:
|
||||
REQUIRES_LOCAL_IMAGES: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set up the environment"
|
||||
run: |
|
||||
${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-minimal+transforms.yml
|
||||
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
- name: "Build TAS integration tests"
|
||||
if: ${{ matrix.test-name }} == 'Integration TAS tests'
|
||||
run: mvn install -pl :alfresco-community-repo-integration-test -am -DskipTests -Pall-tas-tests
|
||||
- name: "Run tests"
|
||||
id: tests
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn -B verify -f packaging/tests/${{ matrix.pom-dir }}/pom.xml -Pall-tas-tests,${{ matrix.test-profile }} -Denvironment=default -DrunBugs=false
|
||||
- name: "Print output after success"
|
||||
if: ${{ always() && steps.tests.outcome == 'success' }}
|
||||
run: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Print output after failure"
|
||||
if: ${{ always() && steps.tests.outcome == 'failure' }}
|
||||
run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
share_services_test_suite:
|
||||
name: Share Services - ShareServicesTestSuite
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run Postgres 14.4 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile postgres up -d
|
||||
- name: "Run tests"
|
||||
run: 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: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_postgresql_tests:
|
||||
name: AGS Integration Tests 0${{ matrix.part }} (PostgreSQL) ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
!contains(github.event.head_commit.message, '[skip ags]')) ||
|
||||
contains(github.event.head_commit.message, '[ags]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Verify"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_mysql_tests:
|
||||
name: AGS Integration Tests 0${{ matrix.part }} (MySQL) ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
!contains(github.event.head_commit.message, '[skip ags]')) ||
|
||||
contains(github.event.head_commit.message, '[ags on MySQL]')) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Verify"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_community_rest_api_tests:
|
||||
name: "AGS Community Rest API Tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
!contains(github.event.head_commit.message, '[skip ags]') && !contains(github.event.head_commit.message, '[skip tas]')) ||
|
||||
(contains(github.event.head_commit.message, '[ags]') && contains(github.event.head_commit.message, '[tas]'))) &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
env:
|
||||
REQUIRES_LOCAL_IMAGES: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set up the environment"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
${{ env.TAS_SCRIPTS }}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml
|
||||
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco"
|
||||
mvn -B install -pl :alfresco-governance-services-automation-community-rest-api -am -Pags -Pall-tas-tests -DskipTests
|
||||
- name: "Test"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests
|
||||
- name: "Configure AWS credentials"
|
||||
if: ${{ always() }}
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AGS_AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AGS_AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: "Upload artifacts to Amazon S3 bucket"
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
bash amps/ags/ci/scripts/getLogs.sh
|
||||
aws s3 cp --acl private alfresco.log s3://ags-travis-artifacts/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests/alfresco.log
|
||||
aws s3 cp --acl private solr.log s3://ags-travis-artifacts/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests/solr.log
|
||||
aws s3 cp --acl private ./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports/rm-automation-community-rest-api.log s3://ags-travis-artifacts/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests/rm-automation-community-rest-api.log
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
79
.github/workflows/master_release.yml
vendored
79
.github/workflows/master_release.yml
vendored
@@ -1,79 +0,0 @@
|
||||
name: Master/Release branch workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release/**
|
||||
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }}
|
||||
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
|
||||
jobs:
|
||||
run_ci:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
secrets: inherit
|
||||
push_to_nexus:
|
||||
name: "Push to Nexus"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run_ci]
|
||||
if: >
|
||||
!(failure() || cancelled()) &&
|
||||
!contains(github.event.head_commit.message, '[no release]') &&
|
||||
github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.33.0
|
||||
with:
|
||||
username: ${{ env.GIT_USERNAME }}
|
||||
email: ${{ env.GIT_EMAIL }}
|
||||
global: true
|
||||
- name: "Release"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash scripts/ci/verify_release_tag.sh
|
||||
bash scripts/ci/maven_release.sh
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
update_downstream:
|
||||
name: "Update alfresco-enterprise-repo"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [push_to_nexus]
|
||||
if: >
|
||||
!(failure() || cancelled()) &&
|
||||
!contains(github.event.head_commit.message, '[no downstream]') &&
|
||||
github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.33.0
|
||||
with:
|
||||
username: ${{ env.GIT_USERNAME }}
|
||||
email: ${{ env.GIT_EMAIL }}
|
||||
global: true
|
||||
- name: "Update downstream"
|
||||
run: bash ./scripts/ci/update_downstream.sh
|
||||
env:
|
||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
415
.travis.yml
Normal file
415
.travis.yml
Normal file
@@ -0,0 +1,415 @@
|
||||
---
|
||||
dist: focal
|
||||
language: java
|
||||
jdk: openjdk17
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- ${HOME}/.m2/repository
|
||||
|
||||
# the cache can grow constantly
|
||||
before_cache: bash scripts/travis/cleanup_cache.sh
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /release\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
|
||||
env:
|
||||
global:
|
||||
- TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)
|
||||
- TAS_SCRIPTS=../alfresco-community-repo/packaging/tests/scripts
|
||||
- TAS_ENVIRONMENT=./packaging/tests/environment
|
||||
- LOG_WARN="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
|
||||
|
||||
stages:
|
||||
- name: prepare
|
||||
if: commit_message !~ /\[skip tests\]/ AND commit_message !~ /\[force[^\]]*\]/
|
||||
- name: test
|
||||
if: commit_message !~ /\[skip tests\]/ AND commit_message !~ /\[force[^\]]*\]/
|
||||
- name: release
|
||||
if: commit_message !~ /\[no release\]/ AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND fork = false
|
||||
- name: update_downstream
|
||||
if: commit_message !~ /\[no downstream\]/ AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND fork = false
|
||||
|
||||
before_install: travis_retry bash scripts/travis/init.sh
|
||||
install: travis_retry travis_wait 40 bash scripts/travis/build.sh
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- name: "Prepare"
|
||||
stage: prepare
|
||||
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\/.*/) AND type != pull_request
|
||||
# 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-email"
|
||||
|
||||
- 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
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-webdav"
|
||||
|
||||
- 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"
|
||||
- travis_retry travis_wait 40 mvn install -pl :alfresco-community-repo-integration-test -am -DskipTests -Pall-tas-tests
|
||||
script: travis_wait 30 mvn -B verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-integration"
|
||||
|
||||
- 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
|
||||
install: skip
|
||||
before_script: bash scripts/travis/verify_release_tag.sh
|
||||
script: travis_wait 40 bash scripts/travis/maven_release.sh
|
||||
|
||||
- name: "Update alfresco-enterprise-repo"
|
||||
stage: update_downstream
|
||||
install: skip
|
||||
script: bash scripts/travis/update_downstream.sh
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# alfresco-community-repo
|
||||
|
||||
[](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml)
|
||||
[](https://travis-ci.com/Alfresco/alfresco-community-repo)
|
||||
|
||||
#### Alfresco Core
|
||||
|
||||
|
@@ -7,22 +7,14 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>rm-community</module>
|
||||
<module>rm-automation</module>
|
||||
</modules>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>all-tas-tests</id>
|
||||
<modules>
|
||||
<module>rm-automation</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
@@ -42,10 +42,15 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>${dependency.slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.rest.v0;
|
||||
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -37,7 +36,6 @@ import java.util.List;
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.util.PojoUtility;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -60,8 +58,6 @@ public class RMAuditAPI extends BaseAPI
|
||||
private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog";
|
||||
private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}";
|
||||
|
||||
private static final String RM_AUDIT_LOG_AS_RECORD = "{0}node/{1}/rmauditlog";
|
||||
|
||||
/**
|
||||
* Returns a list of rm audit entries .
|
||||
*
|
||||
@@ -88,21 +84,6 @@ public class RMAuditAPI extends BaseAPI
|
||||
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of rm audit entries .
|
||||
*
|
||||
* @param user The username of the user to use.
|
||||
* @param password The password of the user.
|
||||
* @param size Maximum number of log entries to return
|
||||
* @return return All return log entries
|
||||
*/
|
||||
public List<AuditEntry> getRMAuditLogAll(String user, String password, final int size) {
|
||||
String parameters = "size=" + size;
|
||||
JSONArray auditEntries = doGetRequest(user, password,
|
||||
MessageFormat.format(RM_AUDIT_LOG_API,"{0}", parameters)).getJSONObject("data").getJSONArray("entries");
|
||||
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of audit entries.
|
||||
*
|
||||
@@ -119,19 +100,5 @@ public class RMAuditAPI extends BaseAPI
|
||||
&& getRMAuditLog(username, password, 100, null).size() == 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the Audit Log as Record.
|
||||
*
|
||||
* @param username The username of the user to use.
|
||||
* @param password The password of the user.
|
||||
* @param recNodeRef The Record Node reference for which Audit log should be created as record
|
||||
* @param destinationNodeRef The Folder id Node reference where the html file should be placed
|
||||
* @throws AssertionError If the API call didn't create the Audit Log as Record.
|
||||
*/
|
||||
public HttpResponse logsAuditLogAsRecord(String username, String password, String recNodeRef, String destinationNodeRef) {
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("destination", destinationNodeRef);
|
||||
return doPostJsonRequest(username, password, SC_OK, requestParams, RM_AUDIT_LOG_AS_RECORD,recNodeRef);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -97,16 +97,4 @@ public class RecordFoldersAPI extends BaseAPI
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public HttpResponse reOpenRecordFolder(String user, String password, String recordFolder)
|
||||
{
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
|
||||
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "openRecordFolder");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -360,25 +360,4 @@ public class RecordsAPI extends BaseAPI
|
||||
{
|
||||
return getNodeRefSpacesStore() + getItemNodeRef(username, password, recordPath + "/" + recordName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reopens the record given as parameter
|
||||
*
|
||||
* @param user the user declaring the document as record
|
||||
* @param password the user's password
|
||||
* @param recordName the record name
|
||||
* @return The HTTP Response.
|
||||
*/
|
||||
|
||||
public HttpResponse reOpenRecord(String user, String password, String recordName)
|
||||
{
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
|
||||
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "undeclareRecord");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.audit;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.*;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.testng.AssertJUnit.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEvents;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.v0.HoldsAPI;
|
||||
import org.alfresco.rest.v0.service.RMAuditService;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
public class AuditHoldsTest extends BaseRMRestTest {
|
||||
private final String PREFIX = generateTestPrefix(AuditAddToHoldTests.class);
|
||||
private final String HOLD1 = PREFIX + "hold1";
|
||||
private SiteModel publicSite;
|
||||
private FileModel testFile;
|
||||
@Autowired
|
||||
private RMAuditService rmAuditService;
|
||||
@Autowired
|
||||
private HoldsAPI holdsAPI;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
private UserModel rmAdmin;
|
||||
private RecordCategory recordCategory;
|
||||
private RecordCategoryChild recordFolder1,recordFolder2;
|
||||
private List<AuditEntry> auditEntries;
|
||||
private String hold1NodeRef;
|
||||
public static final String RECORD_FOLDER_THREE = "record-folder-three";
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForAuditAddToHoldTests()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
||||
|
||||
STEP("Create a hold");
|
||||
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1, HOLD_REASON,
|
||||
HOLD_DESCRIPTION);
|
||||
|
||||
STEP("Create a collaboration site with a test file.");
|
||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
testFile = dataContent.usingAdmin().usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
STEP("Create a record category with 2 folders and 1 record");
|
||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
||||
recordFolder1 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder1");
|
||||
recordFolder2 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder2");
|
||||
Record recordToBeAdded = createElectronicRecord(recordFolder1.getId(), PREFIX + "record");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Add some items to the hold, then remove them from the hold");
|
||||
final List<String> itemsList = asList(testFile.getNodeRefWithoutVersion(), recordToBeAdded.getId(), recordFolder2.getId());
|
||||
final List<String> holdsList = Collections.singletonList(HOLD1);
|
||||
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), recordToBeAdded.getId(), HOLD1);
|
||||
holdsAPI.removeItemsFromHolds(rmAdmin.getUsername(), rmAdmin.getPassword(), itemsList, holdsList);
|
||||
|
||||
STEP("Delete the record folder that was held");
|
||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(recordFolder2.getId());
|
||||
|
||||
STEP("Rename the parent of the record that was held");
|
||||
RecordFolder recordFolder = RecordFolder.builder().name(RECORD_FOLDER_THREE).build();
|
||||
getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordFolder1.getId());
|
||||
}
|
||||
/**
|
||||
* Data provider with hold events that have links to held items
|
||||
*
|
||||
* @return the hold events
|
||||
*/
|
||||
@DataProvider (name = "holdsEvents")
|
||||
public Object[][] getHoldEvents()
|
||||
{
|
||||
return new AuditEvents[][]
|
||||
{
|
||||
{ ADD_TO_HOLD },
|
||||
{ REMOVE_FROM_HOLD }
|
||||
};
|
||||
}
|
||||
@Test (dataProvider = "holdsEvents")
|
||||
public void checkItemPathLink(AuditEvents event) {
|
||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), event);
|
||||
assertFalse("Audit results should not be empty",auditEntries.size()==0);
|
||||
final String auditedEvent = event + " - " + testFile.getName();
|
||||
assertTrue("Audit results should contain one " + auditedEvent + " event",auditEntries.stream().anyMatch(e -> e.getEvent().startsWith(event.eventDisplayName)));
|
||||
STEP("Check the audit log contains only an entry for add to hold.");
|
||||
assertThat(auditEntries, is(not(empty())));
|
||||
}
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void cleanup() {
|
||||
dataSite.usingAdmin().deleteSite(publicSite);
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordFolder(recordFolder2.getId());
|
||||
deleteRecordCategory(recordCategory.getId());
|
||||
rmAuditService.clearAuditLog();
|
||||
}
|
||||
}
|
@@ -1,244 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.AssertJUnit;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class ElectronicRecordAuditLogTest extends BaseRMRestTest {
|
||||
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
@Autowired
|
||||
private RecordsAPI recordApi;
|
||||
/* electronic record details */
|
||||
private static final String AUDIT_ELECTRONIC_RECORD = generateTestPrefix(ElectronicRecordAuditLogTest.class) + "electronic record";
|
||||
private static final String AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD = "Complete Reopen Electronic Record";
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private Record electronicRecord, electronicRecord2;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void electronicRecordsAuditLogSetup()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(),TITLE);
|
||||
|
||||
electronicRecord = createElectronicRecord(recordFolder1.getId(),AUDIT_ELECTRONIC_RECORD,rmAdmin.get());
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for newly filed electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void newElectronicRecordAudit() {
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
|
||||
// newly created record contains 2 events: "file to" and metadata update
|
||||
// the order in which object creation and metadata update are listed isn't always identical due to
|
||||
// both happening in the same transaction
|
||||
assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to")));
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "newElectronicRecordAudit",
|
||||
description = "Viewing electronic record audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void electronicRecordAuditIsEvent()
|
||||
{
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "electronicRecordAuditIsEvent",
|
||||
description = "Rename electronic record is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameElectronicRecord() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
Record renameElectronicRecord = createRecordModel("edited " + electronicRecord.getName(), "", "");
|
||||
|
||||
// rename record
|
||||
getRestAPIFactory().getRecordsAPI().updateRecord(renameElectronicRecord, electronicRecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test (
|
||||
dependsOnMethods = "newElectronicRecordAudit",
|
||||
description = "Complete and reopen electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void completeAndReopenElectronicRecord() {
|
||||
electronicRecord2 = createElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD);
|
||||
|
||||
// complete record
|
||||
recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
electronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames();
|
||||
// a record must be completed
|
||||
assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record")));
|
||||
|
||||
// Reopen record
|
||||
recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
electronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames();
|
||||
// a record mustn't be completed
|
||||
assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "completeAndReopenElectronicRecord",
|
||||
description = "File electronic record's audit log as record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void fileElectronicRecordAuditLogAsRecord()
|
||||
{
|
||||
// audit log is stored in the same folder, refresh it so that it appears in the list
|
||||
HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
getRecordNodeRef(electronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId()));
|
||||
JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse);
|
||||
Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString()
|
||||
.replace("workspace://SpacesStore/",""));
|
||||
// check audit log
|
||||
AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html"));
|
||||
AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD)));
|
||||
}
|
||||
|
||||
private String getFolderNodeRef(String folderId) {
|
||||
return "workspace://SpacesStore/" + folderId;
|
||||
}
|
||||
|
||||
private String getRecordNodeRef(String recordId) {
|
||||
return "workspace/SpacesStore/" + recordId;
|
||||
}
|
||||
|
||||
private JSONObject getAuditPropertyValues(HttpResponse httpResponse) {
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
String responseString = null;
|
||||
try {
|
||||
responseString = EntityUtils.toString(entity, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject result = new JSONObject(responseString);
|
||||
return result;
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
private void closeAuditLog() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void electronicRecordAuditLogCleanup() {
|
||||
deleteRecord(electronicRecord.getId());
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
}
|
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.AssertJUnit;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
||||
public class NonElectronicRecordAuditLogTest extends BaseRMRestTest {
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
@Autowired
|
||||
private RecordsAPI recordApi;
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private Record nonElectronicRecord , nonElectronicRecord2;
|
||||
private static final String AUDIT_NON_ELECTRONIC_RECORD = generateTestPrefix(NonElectronicRecordAuditLogTest.class) + "non electronic record";
|
||||
private static final String AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD = "Complete Reopen Non-Electronic Record";
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void nonElectronicRecordAuditLogSetup()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(),TITLE);
|
||||
nonElectronicRecord = createNonElectronicRecord(recordFolder1.getId(),AUDIT_NON_ELECTRONIC_RECORD,rmAdmin.get());
|
||||
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for newly filed non-electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void newNonElectronicRecordAudit()
|
||||
{
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
|
||||
// newly created record contains 3 events: "created object", "file to" and metadata update
|
||||
assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to")));
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
assertTrue("Created Object Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "newNonElectronicRecordAudit",
|
||||
description = "Viewing Non electronic record audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void nonElectronicRecordAuditIsEvent()
|
||||
{
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "nonElectronicRecordAuditIsEvent",
|
||||
description = "Rename electronic record is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameNonElectronicRecord()
|
||||
{
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
Record renameNonElectronicRecord = createRecordModel("edited " + nonElectronicRecord.getName(), "", "");
|
||||
|
||||
// rename record
|
||||
getRestAPIFactory().getRecordsAPI().updateRecord(renameNonElectronicRecord, nonElectronicRecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test (dependsOnMethods = "newNonElectronicRecordAudit",description = "Complete and reopen electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void completeAndReopenNonElectronicRecord()
|
||||
{
|
||||
nonElectronicRecord2 = createNonElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD);
|
||||
|
||||
// complete record
|
||||
recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
nonElectronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames();
|
||||
// a record must be completed
|
||||
assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record")));
|
||||
|
||||
// Reopen record
|
||||
recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
nonElectronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames();
|
||||
// a record mustn't be completed
|
||||
assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record")));
|
||||
|
||||
}
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "completeAndReopenNonElectronicRecord",
|
||||
description = "File electronic record's audit log as record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void fileNonElectronicRecordAuditLogAsRecord()
|
||||
{
|
||||
// audit log is stored in the same folder, refresh it so that it appears in the list
|
||||
HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
getRecordNodeRef(nonElectronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId()));
|
||||
JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse);
|
||||
Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString()
|
||||
.replace("workspace://SpacesStore/",""));
|
||||
// check audit log
|
||||
AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html"));
|
||||
AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD)));
|
||||
|
||||
}
|
||||
|
||||
private String getFolderNodeRef(String folderId) {
|
||||
return "workspace://SpacesStore/" + folderId;
|
||||
}
|
||||
|
||||
private String getRecordNodeRef(String recordId) {
|
||||
return "workspace/SpacesStore/" + recordId;
|
||||
}
|
||||
|
||||
private JSONObject getAuditPropertyValues(HttpResponse httpResponse) {
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
String responseString = null;
|
||||
try {
|
||||
responseString = EntityUtils.toString(entity, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject result = new JSONObject(responseString);
|
||||
return result;
|
||||
}
|
||||
@AfterMethod
|
||||
private void closeAuditLog() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void nonElectronicRecordAuditLogCleanup() {
|
||||
deleteRecord(nonElectronicRecord.getId());
|
||||
deleteRecord(nonElectronicRecord2.getId());
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
}
|
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
|
||||
public class RecordCategoryAuditLogTest extends BaseRMRestTest {
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
|
||||
private final String TEST_PREFIX = generateTestPrefix(RecordCategoryAuditLogTest.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private static final String AUDIT_CATEGORY = generateTestPrefix(RecordCategoryAuditLogTest.class) + "category";
|
||||
private RecordCategory recordCategoryAudit;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void recordCategoryAuditLogSetup() {
|
||||
STEP("Create RM Site");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2768")
|
||||
public void recordCategoryAudit() throws Exception {
|
||||
STEP("Create root level category");
|
||||
recordCategoryAudit = createRootCategory(AUDIT_CATEGORY);
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
// newly created record category contains 3 events: object creation, inherited permissions set to false and metadata update
|
||||
// the order in which object creation and metadata update are listed isn't always identical due to
|
||||
// both happening in the same transaction
|
||||
assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordCategoryAudit",
|
||||
description = "Viewing audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void recordCategoryAuditIsEvent() {
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordCategoryAuditIsEvent",
|
||||
description = "Record category rename is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameRecordCategory() {
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
RecordCategory rootRecordCategory = createRootCategory(categoryName);
|
||||
String newCategoryName = "Rename " + categoryName;
|
||||
RecordCategory recordCategoryUpdated = RecordCategory.builder().name(newCategoryName).build();
|
||||
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated, rootRecordCategory.getId());
|
||||
|
||||
assertStatusCode(OK);
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void electronicRecordAuditLogCleanup() {
|
||||
deleteRecordCategory(recordCategoryAudit.getId());
|
||||
dataUser.deleteUser(new UserModel(RM_ADMIN,
|
||||
getAdminUser().getPassword()));
|
||||
auditLog.clearAuditLog(getAdminUser().getUsername(), getAdminUser().getPassword());
|
||||
}
|
||||
}
|
||||
|
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordFolderModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class RecordFolderAuditLogTest extends BaseRMRestTest {
|
||||
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void recordFolderAuditLogSetup() {
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for empty record folder")
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void recordFolderAudit() {
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(), TITLE);
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordFolderAudit",
|
||||
description = "Viewing record folder audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void recordFolderAuditIsEvent() {
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordFolderAuditIsEvent",
|
||||
description = "Record folder rename is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void renameRecordFolder() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(), rmAdmin.get().getPassword());
|
||||
RecordFolder renameRecordFolder = createRecordFolderModel(category1.getId(), "edited");
|
||||
getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(renameRecordFolder, recordFolder1.getId());
|
||||
assertStatusCode(OK);
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
// assertTrue("Move To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Move to")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "recordFolderAudit",
|
||||
description = "Close and reopen folder")
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void closeReopenFolder() {
|
||||
//close folder
|
||||
recordFoldersAPI.closeRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(),
|
||||
recordFolder1.getName());
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Folder Close Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Close Record Folder")));
|
||||
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
//reopen folder
|
||||
recordFoldersAPI.reOpenRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(),
|
||||
recordFolder1.getName());
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Reopen Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Open Record Folder")));
|
||||
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
}
|
||||
@AfterMethod
|
||||
private void closeAuditLog()
|
||||
{
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass (alwaysRun = true)
|
||||
public void recordFolderAuditLogCleanup()
|
||||
{
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
|
||||
}
|
@@ -33,9 +33,7 @@ import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.json.JSONObject;
|
||||
@@ -99,10 +97,9 @@ public class InplaceRecordSearchTests extends BaseRMRestTest {
|
||||
@Test
|
||||
public void searchForInplaceRecord() {
|
||||
// And a document that isn't a record
|
||||
final String fileName = "File" + RandomData.getRandomAlphanumeric();
|
||||
uploadedDocbyCollabUser = dataContent.usingSite(privateSite)
|
||||
.usingUser(siteCollaborator)
|
||||
.createContent(new FileModel(fileName, FileType.fromName(fileName + "." + CMISUtil.DocumentType.TEXT_PLAIN.extention)));
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
assertNotNull(uploadedDocbyCollabUser.getNodeRef());
|
||||
|
||||
|
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.rules;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.CreateCategoriesTests;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
|
||||
public class CopyToRuleOnFoldersTest extends BaseRMRestTest {
|
||||
|
||||
private RecordCategory category;
|
||||
private RecordCategoryChild folder1,folder2;
|
||||
private final static String title = "Run in background";
|
||||
private final String TEST_PREFIX = generateTestPrefix(CopyToRuleOnFoldersTest.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private final String electronicRecord = TEST_PREFIX + "record_electronic_for_copyTo";
|
||||
private final String nonElectronicRecord = TEST_PREFIX + "record_non_electronic_for_copyTo";
|
||||
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2994")
|
||||
public void copyToRuleOnFoldersTest()
|
||||
{
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(true).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.COPY_TO.getActionValue()));
|
||||
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create record categories and record folders");
|
||||
category= createRootCategory(getRandomName("recordCategory"));
|
||||
String folder1 = createCategoryFolderInFilePlan().getId();
|
||||
String folder2 = createCategoryFolderInFilePlan().getId();
|
||||
|
||||
// create a rule on folder
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folder1, ruleDefinition);
|
||||
|
||||
// create electronic record in record folder
|
||||
String electronicRecordId = createElectronicRecord(folder1, ELECTRONIC_RECORD_NAME).getId();
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// create non-electronic record in record folder
|
||||
String nonElectronicRecord = createElectronicRecord(folder1, NONELECTRONIC_RECORD_NAME).getId();
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Move the electronic and non-electronic records from "Category with records"> "Folder with rule"
|
||||
// to "Copy Category with records" > "Folder with rule"
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(folder1)).copy(createBodyForMoveCopy(category.getId()));
|
||||
getRestAPIFactory().getNodeAPI(toContentModel( electronicRecord)).move(createBodyForMoveCopy(folder2));
|
||||
getRestAPIFactory().getNodeAPI(toContentModel( nonElectronicRecord)).move(createBodyForMoveCopy(folder2));
|
||||
|
||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
// Delete the record category
|
||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||
String recordCategoryId = category.getId();
|
||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||
recordsAPI.deleteRecord(electronicRecord);
|
||||
recordsAPI.deleteRecord(nonElectronicRecord);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,229 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.rules;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
@AlfrescoTest (jira = "APPS-36")
|
||||
public class FileAsRecordRuleTests extends BaseRMRestTest
|
||||
{
|
||||
private UserModel nonRMUser, rmManager;
|
||||
private RecordCategory category_manager, category_admin;
|
||||
private RecordCategoryChild folder_admin, folder_manager ;
|
||||
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String CATEGORY_ADMIN = "catAdmin" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private FolderModel testFolder;
|
||||
private FileModel document,inPlaceRecord;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
/**
|
||||
* Create preconditions:
|
||||
* 1. RM site is created
|
||||
* 2. Two users: user without RM role and a user with RM manager role
|
||||
* 3. Two Record categories with one folder each
|
||||
* 4. User with RM MANAGER role has Filling permission over one category
|
||||
* 5. A collaboration folder with rule set to declare and file as record to a record folder
|
||||
**/
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForDeclareFileAsRecordRuleTests()
|
||||
{
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create a user");
|
||||
nonRMUser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
STEP("Create a collaboration site");
|
||||
testSite = dataSite.usingUser(nonRMUser).createPublicRandomSite();
|
||||
|
||||
STEP("Create two categories with two folders");
|
||||
category_manager = createRootCategory(CATEGORY_MANAGER);
|
||||
category_admin = createRootCategory(CATEGORY_ADMIN);
|
||||
folder_admin = createFolder(category_admin.getId(),FOLDER_ADMIN);
|
||||
folder_manager = createFolder(category_manager.getId(),FOLDER_MANAGER);
|
||||
|
||||
STEP("Create an rm user and give filling permission over CATEGORY_MANAGER record category");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
rmManager = roleService.createCollaboratorWithRMRoleAndPermission(testSite, recordCategory,
|
||||
UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record to a record folder");
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
/**
|
||||
* Given I am a user that can create a rule on a folder in a collaboration site
|
||||
* When I am creating the rule
|
||||
* Then I have the option of adding a "Declare and File as Record" action to the rule
|
||||
* <p>
|
||||
* Given I am creating a rule
|
||||
* When I add the "Declare and File as Record" action to the rule
|
||||
* Then I am able to select the record folder I want the declared record to be filed to
|
||||
* <p>
|
||||
* Given I am configuring a "Declare and File as Record" action within a rule
|
||||
* And I have at least one records management role (eg RM User)
|
||||
* When I am selecting the record folder location to file the declared record to
|
||||
* Then I see the record folders in the file plan that I have file access to as the creator of the record
|
||||
**/
|
||||
@Test
|
||||
public void declareAsRecordRuleAsRMUserWithFilingPermissions() {
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(rmManager)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
/**
|
||||
* Given I am configuring a "Declare and File as Record" action within a rule
|
||||
* And I don't have a records management role
|
||||
* When I am selecting the record folder location to file the declared record to
|
||||
* Then I can see only the file plan
|
||||
*/
|
||||
@Test
|
||||
public void declareAsRecordRuleAsNonRMUser()
|
||||
{
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMUser)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMUser.getUsername(), nonRMUser.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have not selected a record folder location
|
||||
* When the rule is triggered
|
||||
* Then the file is declared as record to the UnFiled Records folder
|
||||
*/
|
||||
@Test
|
||||
public void triggerDeclareToUnfiledRuleAsNonRMUser()
|
||||
{
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
||||
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Create as nonRMUser a new file into the previous folder in order to trigger the rule");
|
||||
inPlaceRecord = dataContent.usingUser(nonRMUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
// Verify that declared record is in Unfilled Records Folder
|
||||
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(e -> e.getEntry().getId().equals(inPlaceRecord.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanupDeclareAsRecordRuleTests()
|
||||
{
|
||||
STEP("Delete the collaboration site");
|
||||
dataSite.usingUser(nonRMUser).deleteSite(testSite);
|
||||
|
||||
STEP("Delete Users");
|
||||
dataUser.deleteUser(nonRMUser);
|
||||
dataUser.deleteUser(rmManager);
|
||||
|
||||
STEP("Delete categories");
|
||||
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
||||
}
|
||||
}
|
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.rules;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
||||
|
||||
private UserModel nonRMuser, rmManager;
|
||||
private RecordCategory category_manager, category_admin;
|
||||
private RecordCategoryChild folder_admin, folder_manager ;
|
||||
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String CATEGORY_ADMIN = "catAdmin" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private FolderModel testFolder;
|
||||
private FileModel document,inPlaceRecord;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void createTestPrecondition()
|
||||
{
|
||||
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create a user");
|
||||
nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
STEP("Create a collaboration site");
|
||||
testSite = dataSite.usingUser(nonRMuser).createPublicRandomSite();
|
||||
|
||||
STEP("Create a document with the user without RM role");
|
||||
document = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMuser)
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
STEP("Create two categories with two folders");
|
||||
category_manager = createRootCategory(CATEGORY_MANAGER);
|
||||
category_admin = createRootCategory(CATEGORY_ADMIN);
|
||||
folder_admin = createFolder(category_admin.getId(),FOLDER_ADMIN);
|
||||
folder_manager = createFolder(category_manager.getId(),FOLDER_MANAGER);
|
||||
|
||||
|
||||
STEP("Create an rm user and give filling permission over CATEGORY_MANAGER record category");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId())
|
||||
.build();
|
||||
rmManager = roleService.createCollaboratorWithRMRoleAndPermission(testSite, recordCategory,
|
||||
UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
||||
|
||||
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file version as record to a record folder");
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void declareVersionAsRecordRuleAsRMUserWithFilingPermissions()
|
||||
{
|
||||
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(rmManager)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(rmManager.getUsername(), rmManager.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void declareVersionAsRecordRuleAsNonRMUser()
|
||||
{
|
||||
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMuser)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void triggerDeclareToUnfiledRuleAsNonRMUser() throws Exception {
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
||||
|
||||
|
||||
FileModel inplaceRecord = dataContent.usingSite(testSite).usingUser(nonRMuser)
|
||||
.createContent(new FileModel("declareAndFileToIntoUnfiledRecordFolder",
|
||||
FileType.TEXT_PLAIN));
|
||||
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + inplaceRecord.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Create as nonRMuser a new file into the previous folder in order to trigger the rule");
|
||||
inPlaceRecord = dataContent.usingUser(nonRMuser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
// verify the declared record is in Unfilled Records folder
|
||||
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(e -> e.getEntry().getId().equals(inplaceRecord.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanupDeclareVersionAsRecordRuleTests()
|
||||
{
|
||||
|
||||
STEP("Delete the collaboration site");
|
||||
dataSite.usingUser(nonRMuser).deleteSite(testSite);
|
||||
|
||||
STEP("Delete Users");
|
||||
dataUser.deleteUser(nonRMuser);
|
||||
dataUser.deleteUser(rmManager);
|
||||
|
||||
|
||||
STEP("Delete categories");
|
||||
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
||||
}
|
||||
|
||||
}
|
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.rm.community.rules;
|
||||
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.ConditionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.v0.HoldsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
|
||||
public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
|
||||
|
||||
private RecordCategoryChild recordFolder2;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private String nonElectronicId;
|
||||
|
||||
public Record electronicRecord;
|
||||
|
||||
private String ruleType = ConditionsOnRule.UPDATE.getWhenConditionValue();
|
||||
private UserModel rmAdmin;
|
||||
public RecordCategory RecordCategoryOne;
|
||||
private RecordCategoryChild recordFolder;
|
||||
public static final String RECORD_FOLDER_ONE = "record-folder-one";
|
||||
private final String TEST_PREFIX = generateTestPrefix(MoveToRuleOnFoldersTest.class);
|
||||
|
||||
private final String RECORD_CATEGORY_ONE = TEST_PREFIX + "category";
|
||||
|
||||
private final String recordName = "Test record";
|
||||
private final String recordTitle = recordName + " title";
|
||||
private final String recordDescription = recordName + " description";
|
||||
private Record nonElectrinicRecordModel;
|
||||
private RecordFolderAPI recordFolderAPI;
|
||||
public String title,description,box,file,shelf,storageLocation,name;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
@Autowired
|
||||
private HoldsAPI holdsAPI;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
public RecordsAPI recordsAPI;
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void precondition()
|
||||
{
|
||||
//create RM site
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
||||
//create root category, create folders , add electronic and non electronic records
|
||||
RecordCategoryOne = createRootCategory(RECORD_CATEGORY_ONE);
|
||||
recordFolder1=createRecordFolder(RecordCategoryOne.getId(), getRandomName("recFolder"));
|
||||
// recordFolder1_id = createRecordFolder(RecordCategoryOne.getId(), getRandomName("recFolder")).getId();
|
||||
recordFolder2 = createFolder(getAdminUser(),RecordCategoryOne.getId(),getRandomName("recFolder"));
|
||||
|
||||
|
||||
STEP("CREATE ELECTRONIC RECORD");
|
||||
recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||
electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder1.getId(), getFile(IMAGE_FILE));
|
||||
STEP("Check the electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
STEP("Create a non-electronic record by completing some of the fields");
|
||||
// Use these properties for non-electronic record to be created
|
||||
title = "Title " + getRandomAlphanumeric();
|
||||
description = "Description " + getRandomAlphanumeric();
|
||||
box = "Box "+ getRandomAlphanumeric();
|
||||
file = "File " + getRandomAlphanumeric();
|
||||
shelf = "Shelf " + getRandomAlphanumeric();
|
||||
storageLocation = "Storage Location " + getRandomAlphanumeric();
|
||||
name = "Record " + getRandomAlphanumeric();
|
||||
Random random = new Random();
|
||||
Integer numberOfCopies = random.nextInt(MAX_VALUE);
|
||||
Integer physicalSize = random.nextInt(MAX_VALUE);
|
||||
|
||||
// Set values of all available properties for the non electronic records
|
||||
nonElectrinicRecordModel = createFullNonElectronicRecordModel(name, title, description, box, file, shelf, storageLocation, numberOfCopies, physicalSize);
|
||||
// Create non-electronic record
|
||||
nonElectronicId = recordFolderAPI.createRecord(nonElectrinicRecordModel, recordFolder1.getId()).getId();
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MoveToRuleFoldersTest()
|
||||
{
|
||||
|
||||
String CatName=RecordCategoryOne.getName();
|
||||
String folder2name=recordFolder2.getName();
|
||||
String recfolder2_path="/"+CatName+"/"+folder2name;
|
||||
|
||||
STEP("create a rule MOVE_TO for folder 1");
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(true).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.MOVE_TO.getActionValue())).ruleType(ruleType).path(recfolder2_path);
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder1.getId() , ruleDefinition);
|
||||
|
||||
|
||||
|
||||
STEP("Update metadata for Non-Electronic Record");
|
||||
updateRecordMetadata();
|
||||
|
||||
STEP("Delete ELECTRONIC AND NON-ELECTRONIC RECORDS IN FOLDER 2");
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
recordsAPI.deleteRecord(electronicRecord.getId());
|
||||
assertStatusCode(NO_CONTENT);
|
||||
recordsAPI.deleteRecord(nonElectronicId);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
STEP("RULE CREATION FOR FOLDER 1 WITHOUT RUNNING IN BACKGROUND");
|
||||
|
||||
RuleDefinition ruleDefinition_notinbackground = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(false).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.MOVE_TO.getActionValue())).ruleType(ruleType).path(recfolder2_path);
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder1.getId() , ruleDefinition);
|
||||
|
||||
STEP("CREATE ELECTRONIC AND NON-ELECTRONIC RECORDS");
|
||||
electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder1.getId(), getFile(IMAGE_FILE));
|
||||
STEP("Check the electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
nonElectronicId = recordFolderAPI.createRecord(nonElectrinicRecordModel, recordFolder1.getId()).getId();
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("UPDATE METADATA");
|
||||
updateRecordMetadata();
|
||||
|
||||
STEP("CHECK IF ELECTRONIC AND NON-ELECTRONIC RECORDS MOVED TO FOLDER2");
|
||||
updateRecordMetadata();
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanMoveToRuleOnFoldersTest()
|
||||
{
|
||||
deleteRecordCategory(RecordCategoryOne.getId());
|
||||
|
||||
getDataUser().deleteUser(rmAdmin);
|
||||
}
|
||||
|
||||
private String getModifiedPropertyValue(String originalValue) {
|
||||
/* to be used to append to modifications */
|
||||
String MODIFIED_PREFIX = "modified_";
|
||||
return MODIFIED_PREFIX + originalValue;
|
||||
}
|
||||
private void updateRecordMetadata(){
|
||||
STEP("Update metadata for Non-Electronic Record");
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
Record nonelecrecord = recordsAPI.getRecord(nonElectronicId);
|
||||
String nonelecnewName = getModifiedPropertyValue(nonElectrinicRecordModel.getName());
|
||||
String nonelecnewTitle = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getTitle());
|
||||
String nonelecnewDescription = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(nonelecnewName, nonelecnewDescription, nonelecnewTitle),nonelecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
STEP("Update metadata for Electronic Record");
|
||||
Record elecrecord = recordsAPI.getRecord(electronicRecord.getId());
|
||||
String elecnewName = getModifiedPropertyValue(electronicRecord.getName());
|
||||
String elecnewTitle = getModifiedPropertyValue(electronicRecord.getProperties().getTitle());
|
||||
String elecnewDescription = getModifiedPropertyValue(electronicRecord.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(elecnewName, elecnewDescription, elecnewTitle),elecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
}
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ public class SearchDocumentsV1Test extends BaseRMRestTest
|
||||
cmisQueryModel.setLanguage("cmis");
|
||||
|
||||
RestRequestQueryModel aftsQueryModel = new RestRequestQueryModel();
|
||||
aftsQueryModel.setQuery("cm:name:*" + SEARCH_TERM + ".txt");
|
||||
aftsQueryModel.setQuery("cm:name:*" + SEARCH_TERM);
|
||||
aftsQueryModel.setLanguage("afts");
|
||||
|
||||
return new RestRequestQueryModel[][] {
|
||||
@@ -107,7 +107,7 @@ public class SearchDocumentsV1Test extends BaseRMRestTest
|
||||
private void waitIndexing() throws Exception
|
||||
{
|
||||
RestRequestQueryModel queryType = new RestRequestQueryModel();
|
||||
queryType.setQuery("cm:name:*" + SEARCH_TERM + ".txt");
|
||||
queryType.setQuery("cm:name:*" + SEARCH_TERM);
|
||||
queryType.setLanguage("afts");
|
||||
Utility.sleep(1000, 80000, () ->
|
||||
{
|
||||
|
@@ -50,7 +50,6 @@ import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.AssertJUnit;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@@ -67,6 +66,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.CUT_OFF_ASPECT;
|
||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.*;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -84,29 +84,26 @@ public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
private final static String TEST_PREFIX = generateTestPrefix(DispositionScheduleLinkedRecordsTest.class);
|
||||
private RecordCategory Category1;
|
||||
private RecordCategory Category1,catsameLevel1,catsameLevel2;
|
||||
private RecordCategoryChild CopyCatFolder,folder1,CatFolder,folder2;
|
||||
private static final String categoryRM3077 = TEST_PREFIX + "RM-3077_manager_sees_me";
|
||||
private static final String copyCategoryRM3077 = "Copy_of_" + categoryRM3077;
|
||||
private static final String folderRM3077 = "RM-3077_folder_"+ categoryRM3077;
|
||||
private static final String copyFolderRM3077 = "Copy_of_" + folderRM3077;
|
||||
private final String electronicRecord = "RM-2937 electronic 2 record";
|
||||
private final String folder = TEST_PREFIX + "RM-2937 folder ghosting";
|
||||
private static final String categoryRecordsRM2526 = TEST_PREFIX + "RM-2526_category_records_immediately";
|
||||
private static final String category2RecordsRM2526 = TEST_PREFIX + "RM-2526_category_2_records_1_day";
|
||||
private static final String firstCategoryRM3060 = TEST_PREFIX + "RM-3060_category_record";
|
||||
private static final String secondCategoryRM3060 = "Copy_of_" + firstCategoryRM3060;
|
||||
private static final String firstFolderRM3060 = TEST_PREFIX + "RM-3060_folder";
|
||||
private static final String secondFolderRM3060 = TEST_PREFIX + "RM-3060_disposition_on_Record_Level";
|
||||
private static final String electronicRecordRM3060 = TEST_PREFIX + "RM-3060_electronic_1_record";
|
||||
private static final String nonElectronicRecordRM3060 = TEST_PREFIX + "RM-3060_non-electronic_record";
|
||||
private static final String firstCategoryRM1622 = TEST_PREFIX + "RM-1622_category_record";
|
||||
private static final String secondCategoryRM1622 = "Copy_of_" + firstCategoryRM1622;;
|
||||
private static final String firstFolderRM1622 = TEST_PREFIX + "RM-1622_folder";
|
||||
private static final String electronicRecordRM1622 = TEST_PREFIX + "RM-1622_electronic_1_record";
|
||||
private static final String secondFolderRM1622 = TEST_PREFIX + "RM-1622_disposition_on_Record_Level";
|
||||
private static final String TRANSFER_LOCATION = TEST_PREFIX + "RM-3060_transferred_records";
|
||||
public static final String TRANSFER_TYPE = "rma:transferred";
|
||||
private FilePlan filePlanModel;
|
||||
private UserModel rmAdmin, rmManager;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupDispositionScheduleLinkedRecordsTest() {
|
||||
createRMSiteIfNotExists();
|
||||
@@ -136,195 +133,192 @@ public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
||||
* <p>
|
||||
* <p/> TestRail Test C775<p/>
|
||||
**/
|
||||
// @Ignore("ACS-5020")
|
||||
// @Test
|
||||
// @AlfrescoTest(jira = "RM-1622")
|
||||
// public void dispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
// STEP("Create record category");
|
||||
// Category1 = createRootCategory(categoryRM3077);
|
||||
//
|
||||
// //create retention schedule
|
||||
// dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
//
|
||||
// // add cut off step
|
||||
// dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
//
|
||||
// //create a copy of the category recordsCategory
|
||||
// String CopyCategoryId = copyCategory(getAdminUser(),Category1.getId(), copyCategoryRM3077);
|
||||
//
|
||||
// // create folders in both categories
|
||||
// CatFolder = createRecordFolder(Category1.getId(), folderRM3077);
|
||||
// CopyCatFolder = createRecordFolder(CopyCategoryId, copyFolderRM3077);
|
||||
//
|
||||
// // create record files
|
||||
// String electronicRecord = "RM-2801 electronic record";
|
||||
// Record elRecord = createElectronicRecord(CatFolder.getId(), electronicRecord);
|
||||
// String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), electronicRecord);
|
||||
//
|
||||
// String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
// Record nonElRecord = createNonElectronicRecord(CatFolder.getId(), nonElectronicRecord);
|
||||
// String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), nonElectronicRecord);
|
||||
//
|
||||
// // link the records to copy folder, then complete them
|
||||
// List<String> recordLists = new ArrayList<>();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + elRecord.getId());
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + nonElRecord.getId());
|
||||
//
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,copyCategoryRM3077 + "/" +
|
||||
// copyFolderRM3077, recordLists);
|
||||
// recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), elRecordFullName);
|
||||
// recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), nonElRecordFullName);
|
||||
//
|
||||
// // edit disposition date
|
||||
// recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),CatFolder.getName());
|
||||
//
|
||||
// // cut off the Folder
|
||||
// recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),CatFolder.getName());
|
||||
//
|
||||
// // Verify the Content
|
||||
// Node electronicNode = getNode(elRecord.getId());
|
||||
// assertTrue("The content of " + electronicRecord + " is available",
|
||||
// StringUtils.isEmpty(electronicNode.getNodeContent().getResponse().getBody().asString()));
|
||||
//
|
||||
// // verify the Properties
|
||||
// AssertJUnit.assertNull("The properties are present even after cutting off the record.", elRecord.getProperties().getTitle());
|
||||
//
|
||||
// // delete precondition
|
||||
// deleteRecordCategory(Category1.getId());
|
||||
// deleteRecordCategory(CopyCategoryId);
|
||||
// }
|
||||
// /**
|
||||
// * Test covering RM-3060
|
||||
// * Check the disposition steps for a record can be executed
|
||||
// * When the record is linked to a folder with the same disposition schedule
|
||||
// * */
|
||||
// @Ignore("ACS-5020")
|
||||
//// @Test
|
||||
// @AlfrescoTest (jira = "RM-3060")
|
||||
// public void sameDispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
//
|
||||
// // create a category with retention applied on records level
|
||||
// RecordCategory recordCategory = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
// .createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM3060).build(),
|
||||
// RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
// dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM3060, true);
|
||||
// dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM3060, "week|1", DATE_FILED);
|
||||
// dispositionScheduleService.addTransferAfterEventStep(firstCategoryRM3060, TRANSFER_LOCATION, RMEvents.CASE_CLOSED.getEventName());
|
||||
// dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(firstCategoryRM3060, "week|1", CUT_OFF_DATE);
|
||||
//
|
||||
// // make a copy of the category created
|
||||
// String categorySecondId = copyCategory(getAdminUser(), recordCategory.getId(), secondCategoryRM3060);
|
||||
//
|
||||
// // create a folder on the category firstCategoryRM3060 with a complete electronic record
|
||||
// RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(recordCategory.getId(),firstFolderRM3060);
|
||||
// Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM3060);
|
||||
//
|
||||
// String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(),firstFolderRM3060, electronicRecordRM3060);
|
||||
// String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
//
|
||||
// recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
||||
//
|
||||
// // create a folder on the category secondCategoryRM3060 with a non electronic record
|
||||
// RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(categorySecondId,secondFolderRM3060);
|
||||
// Record secondNonElectronicRecord = createNonElectronicRecord(secondFolderRecordCategoryChild.getId(),nonElectronicRecordRM3060);
|
||||
//
|
||||
// // link the nonElectronicRecordRM3060 to firstFolderRM3060
|
||||
// List<String> recordLists = new ArrayList<>();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
//
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
// secondFolderRM3060, recordLists);
|
||||
// String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), secondFolderRM3060, secondNonElectronicRecord.getName());
|
||||
// String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060);
|
||||
//
|
||||
// // complete records and cut them off
|
||||
// recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), nonElRecordFullName);
|
||||
//
|
||||
// // edit the disposition date
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
//
|
||||
// // cut off the record
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
//
|
||||
// //check the record is cut off
|
||||
// AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
//
|
||||
// // link the electronic record to secondFolderRM3060
|
||||
// recordLists.clear();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
// secondFolderRM3060, recordLists);
|
||||
//
|
||||
// // edit the disposition date and cut off the record
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
//
|
||||
// AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
//
|
||||
// // open the record and complete the disposition schedule event
|
||||
// rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(), elRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
// rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(), nonElRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
//
|
||||
// // transfer the files & complete transfers
|
||||
// HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060));
|
||||
//
|
||||
// String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
//
|
||||
// HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060));
|
||||
//
|
||||
// String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
//
|
||||
// AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully transferred", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
// AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully transferred.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
//
|
||||
// // edit the disposition date for nonElectronicRecordRM3060 & electronicRecordRM3060
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
//
|
||||
// // destroy nonElectronicRecordRM3060 & electronicRecordRM3060 records
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
//
|
||||
// // check the file is not displayed
|
||||
// assertNull("The file " + nonElectronicRecordRM3060 + " has not been successfully destroyed.", secondNonElectronicRecord.getContent());
|
||||
// assertNull("The file " + electronicRecordRM3060 + " has not been successfully destroyed.", firstElectronicRecord.getContent());
|
||||
//
|
||||
// // delete precondition
|
||||
// deleteRecordCategory(recordCategory.getId());
|
||||
// deleteRecordCategory(categorySecondId);
|
||||
// }
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-1622")
|
||||
public void dispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
STEP("Create record category");
|
||||
Category1 = createRootCategory(categoryRM3077);
|
||||
|
||||
//create retention schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
|
||||
//create a copy of the category recordsCategory
|
||||
String CopyCategoryId = copyCategory(getAdminUser(),Category1.getId(), copyCategoryRM3077);
|
||||
|
||||
// create folders in both categories
|
||||
CatFolder = createRecordFolder(Category1.getId(), folderRM3077);
|
||||
CopyCatFolder = createRecordFolder(CopyCategoryId, copyFolderRM3077);
|
||||
|
||||
// create record files
|
||||
String electronicRecord = "RM-2801 electronic record";
|
||||
Record elRecord = createElectronicRecord(CatFolder.getId(), electronicRecord);
|
||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), electronicRecord);
|
||||
|
||||
String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
Record nonElRecord = createNonElectronicRecord(CatFolder.getId(), nonElectronicRecord);
|
||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), nonElectronicRecord);
|
||||
|
||||
// link the records to copy folder, then complete them
|
||||
List<String> recordLists = new ArrayList<>();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + elRecord.getId());
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + nonElRecord.getId());
|
||||
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,copyCategoryRM3077 + "/" +
|
||||
copyFolderRM3077, recordLists);
|
||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), elRecordFullName);
|
||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), nonElRecordFullName);
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),CatFolder.getName());
|
||||
|
||||
// cut off the Folder
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),CatFolder.getName());
|
||||
|
||||
// Verify the Content
|
||||
Node electronicNode = getNode(elRecord.getId());
|
||||
assertTrue("The content of " + electronicRecord + " is available",
|
||||
StringUtils.isEmpty(electronicNode.getNodeContent().getResponse().getBody().asString()));
|
||||
|
||||
// verify the Properties
|
||||
AssertJUnit.assertNull("The properties are present even after cutting off the record.", elRecord.getProperties().getTitle());
|
||||
|
||||
// delete precondition
|
||||
deleteRecordCategory(Category1.getId());
|
||||
deleteRecordCategory(CopyCategoryId);
|
||||
}
|
||||
/**
|
||||
* Test covering RM-3060
|
||||
* Check the disposition steps for a record can be executed
|
||||
* When the record is linked to a folder with the same disposition schedule
|
||||
* */
|
||||
@Test
|
||||
@AlfrescoTest (jira = "RM-3060")
|
||||
public void sameDispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
|
||||
// create a category with retention applied on records level
|
||||
RecordCategory recordCategory = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
.createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM3060).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM3060, true);
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM3060, "week|1", DATE_FILED);
|
||||
dispositionScheduleService.addTransferAfterEventStep(firstCategoryRM3060, TRANSFER_LOCATION, RMEvents.CASE_CLOSED.getEventName());
|
||||
dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(firstCategoryRM3060, "week|1", CUT_OFF_DATE);
|
||||
|
||||
// make a copy of the category created
|
||||
String categorySecondId = copyCategory(getAdminUser(), recordCategory.getId(), secondCategoryRM3060);
|
||||
|
||||
// create a folder on the category firstCategoryRM3060 with a complete electronic record
|
||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(recordCategory.getId(),firstFolderRM3060);
|
||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM3060);
|
||||
|
||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(),firstFolderRM3060, electronicRecordRM3060);
|
||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
|
||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
||||
|
||||
// create a folder on the category secondCategoryRM3060 with a non electronic record
|
||||
RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(categorySecondId,secondFolderRM3060);
|
||||
Record secondNonElectronicRecord = createNonElectronicRecord(secondFolderRecordCategoryChild.getId(),nonElectronicRecordRM3060);
|
||||
|
||||
// link the nonElectronicRecordRM3060 to firstFolderRM3060
|
||||
List<String> recordLists = new ArrayList<>();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
secondFolderRM3060, recordLists);
|
||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), secondFolderRM3060, secondNonElectronicRecord.getName());
|
||||
String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060);
|
||||
|
||||
// complete records and cut them off
|
||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), nonElRecordFullName);
|
||||
|
||||
// edit the disposition date
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
|
||||
// cut off the record
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
|
||||
//check the record is cut off
|
||||
AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
|
||||
// link the electronic record to secondFolderRM3060
|
||||
recordLists.clear();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
secondFolderRM3060, recordLists);
|
||||
|
||||
// edit the disposition date and cut off the record
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
|
||||
AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
|
||||
// open the record and complete the disposition schedule event
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), elRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), nonElRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
|
||||
// transfer the files & complete transfers
|
||||
HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060));
|
||||
|
||||
String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
|
||||
HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060));
|
||||
|
||||
String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
|
||||
AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully transferred", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully transferred.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
|
||||
// edit the disposition date for nonElectronicRecordRM3060 & electronicRecordRM3060
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
|
||||
// destroy nonElectronicRecordRM3060 & electronicRecordRM3060 records
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
|
||||
// check the file is not displayed
|
||||
assertNull("The file " + nonElectronicRecordRM3060 + " has not been successfully destroyed.", secondNonElectronicRecord.getContent());
|
||||
assertNull("The file " + electronicRecordRM3060 + " has not been successfully destroyed.", firstElectronicRecord.getContent());
|
||||
|
||||
// delete precondition
|
||||
deleteRecordCategory(recordCategory.getId());
|
||||
deleteRecordCategory(categorySecondId);
|
||||
}
|
||||
private String copyCategory(UserModel user, String categoryId, String copyName) {
|
||||
RepoTestModel repoTestModel = new RepoTestModel() {};
|
||||
repoTestModel.setNodeRef(categoryId);
|
||||
@@ -374,35 +368,35 @@ public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
||||
|
||||
// create a category with retention applied on records level
|
||||
RecordCategory catsameLevel1 = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
.createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM1622).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
.createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM3060).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
RecordCategory catsameLevel2 = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
.createRootRecordCategory(RecordCategory.builder().name(secondCategoryRM1622).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
.createRootRecordCategory(RecordCategory.builder().name(secondCategoryRM3060).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
|
||||
// create retention schedule applied on records for category 1
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM1622, true);
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM3060, true);
|
||||
|
||||
// with retain immediately after record creation date and cut 1 day after record creation date
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM1622, "day|1", DATE_FILED);
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM3060, "day|1", DATE_FILED);
|
||||
|
||||
|
||||
// create a folder on the category firstCategoryRM1622 with a complete electronic record
|
||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(catsameLevel1.getId(),firstFolderRM1622);
|
||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM1622);
|
||||
// create a folder on the category firstCategoryRM3060 with a complete electronic record
|
||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(catsameLevel1.getId(),firstFolderRM3060);
|
||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM3060);
|
||||
|
||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(),firstFolderRM1622, electronicRecordRM1622);
|
||||
getDataUser().getAdminUser().getPassword(),firstFolderRM3060, electronicRecordRM3060);
|
||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM1622 + "/" + firstFolderRM1622);
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
|
||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
||||
|
||||
// create a folder on the category secondCategoryRM1622 with a non electronic record
|
||||
RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(catsameLevel2.getId(),secondFolderRM1622);
|
||||
// create a folder on the category secondCategoryRM3060 with a non electronic record
|
||||
RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(catsameLevel2.getId(),secondFolderRM3060);
|
||||
String elRecordNameNodeRefs = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM1622 + "/" + firstFolderRM1622);
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
|
||||
|
||||
// link it to the folder in second category through the details page
|
||||
@@ -410,8 +404,8 @@ public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + firstElectronicRecord.getId());
|
||||
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM1622 + "/" +
|
||||
secondFolderRM1622, recordLists);
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
secondFolderRM3060, recordLists);
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
|
@@ -0,0 +1,11 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/rm-automation-community-rest-api.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.logger.com.example=debug
|
@@ -1,20 +0,0 @@
|
||||
###### Root Logger #######
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=target/reports/rm-automation-community-rest-api.log
|
||||
appender.rolling.filePattern=target/reports/rm-automation-community-rest-api.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type=Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Loggers definitions #######
|
||||
logger.com-example.name=com.example
|
||||
logger.com-example.level=debug
|
@@ -1,10 +1,7 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.testng.AlphabeticalPriorityInterceptor" />
|
||||
</listeners>
|
||||
<test name="restapi" preserve-order="false">
|
||||
<test name="restapi">
|
||||
<packages>
|
||||
<package name="org.alfresco.rest.rm.community.*"/>
|
||||
</packages>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.7-A5
|
||||
SOLR6_TAG=2.0.5
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -1,4 +1,3 @@
|
||||
ARG BASE_IMAGE
|
||||
# BUILD STAGE AGS
|
||||
FROM debian:11-slim AS AGSBUILDER
|
||||
|
||||
@@ -13,7 +12,7 @@ RUN unzip -q /build/gs-api-explorer-*.war -d /build/gs-api-explorer && \
|
||||
chmod -R g-w,o= /build
|
||||
|
||||
# ACTUAL IMAGE
|
||||
FROM ${BASE_IMAGE}
|
||||
FROM alfresco/alfresco-community-repo-base:${image.tag}
|
||||
|
||||
# Alfresco user does not have permissions to modify webapps or configuration. Switch to root.
|
||||
# The access will be fixed after all operations are done.
|
||||
|
@@ -116,8 +116,8 @@ rm.patch.v35.holdNewChildAssocPatch.batchSize=1000
|
||||
# Permission mapping
|
||||
# these take a comma separated string of permissions from org.alfresco.service.cmr.security.PermissionService
|
||||
# read maps to ReadRecords and write to FileRecords
|
||||
rm.haspermissionmap.read=Read
|
||||
rm.haspermissionmap.write=WriteProperties,AddChildren,ReadContent
|
||||
rm.haspermissionmap.read=ReadProperties,ReadChildren
|
||||
rm.haspermissionmap.write=WriteProperties,AddChildren
|
||||
|
||||
#
|
||||
# Extended auto-version behaviour. If true and other auto-version properties are satisfied, then
|
||||
|
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# Warnings
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn
|
||||
|
||||
#
|
||||
# Module patches
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
||||
|
||||
#
|
||||
# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be
|
||||
# removed to enhance performance.
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=info
|
||||
|
||||
#
|
||||
# RM permission debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider=debug
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug
|
||||
|
||||
#
|
||||
# RM Audit service debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug
|
||||
|
||||
#
|
||||
# Job debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||
|
||||
#
|
||||
# Script logging level
|
||||
#
|
||||
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=error
|
||||
|
||||
#
|
||||
# Behaviour debug
|
||||
#
|
||||
log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=info
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=info
|
||||
|
||||
#
|
||||
# Patch debug
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
||||
#
|
||||
# RM Audit service debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug
|
||||
|
||||
#
|
||||
# Job debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||
log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl=info
|
@@ -1,50 +0,0 @@
|
||||
# Warnings
|
||||
logger.alfresco-module-org_alfresco_module_rm-caveat.name=org.alfresco.module.org_alfresco_module_rm.caveat
|
||||
logger.alfresco-module-org_alfresco_module_rm-caveat.level=warn
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityPostProcessor.name=org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityPostProcessor.level=warn
|
||||
|
||||
# Module patches
|
||||
logger.alfresco-module-org_alfresco_module_rm-patch.name=org.alfresco.module.org_alfresco_module_rm.patch
|
||||
logger.alfresco-module-org_alfresco_module_rm-patch.level=info
|
||||
|
||||
# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be
|
||||
# removed to enhance performance.
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityInterceptor.name=org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityInterceptor.level=info
|
||||
|
||||
# RM permission debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMEntryVoter.name=org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMEntryVoter.level=debug
|
||||
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMAfterInvocationProvider.name=org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMAfterInvocationProvider.level=debug
|
||||
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-declarative.name=org.alfresco.module.org_alfresco_module_rm.capability.declarative
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-declarative.level=debug
|
||||
|
||||
# RM Audit service debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-audit-RecordsManagementAuditService.name=org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService
|
||||
#logger.alfresco-module-org_alfresco_module_rm-audit-RecordsManagementAuditService.level=debug
|
||||
|
||||
# Job debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-job.name=org.alfresco.module.org_alfresco_module_rm.job
|
||||
#logger.alfresco-module-org_alfresco_module_rm-job.level=debug
|
||||
|
||||
# Script logging level
|
||||
logger.alfresco-repo-jscript-ScriptLogger.name=org.alfresco.repo.jscript.ScriptLogger
|
||||
logger.alfresco-repo-jscript-ScriptLogger.level=error
|
||||
|
||||
# Behaviour debug
|
||||
logger.alfresco-repo-policy-annotation-AnnotatedBehaviourPostProcessor.name=org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor
|
||||
logger.alfresco-repo-policy-annotation-AnnotatedBehaviourPostProcessor.level=info
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-behaviour-BaseBehaviourBean.name=org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean
|
||||
logger.alfresco-module-org_alfresco_module_rm-behaviour-BaseBehaviourBean.level=info
|
||||
|
||||
logger.alfresco-repo-web-scripts-roles-DynamicAuthoritiesGet.name=org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet
|
||||
logger.alfresco-repo-web-scripts-roles-DynamicAuthoritiesGet.level=info
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-query-RecordsManagementQueryDAOImpl.name=org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl
|
||||
logger.alfresco-module-org_alfresco_module_rm-query-RecordsManagementQueryDAOImpl.level=info
|
@@ -8,15 +8,13 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<app.amp.client.war.folder>${project.build.directory}/${project.build.finalName}-war</app.amp.client.war.folder>
|
||||
|
||||
<image.name>alfresco/alfresco-governance-repository-community-base</image.name>
|
||||
<base.image>alfresco/alfresco-community-repo-base</base.image>
|
||||
<scripts.directory>${project.parent.parent.parent.parent.basedir}/scripts</scripts.directory>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -539,43 +537,9 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>build-docker-images</id>
|
||||
<!-- builds "image:latest" locally -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<args>
|
||||
<BASE_IMAGE>${base.image}:${image.tag}</BASE_IMAGE>
|
||||
</args>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>build-multiarch-docker-images</id>
|
||||
<id>build-docker-images</id>
|
||||
<!-- builds "image:latest" locally -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -584,56 +548,20 @@
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
<name>${local.registry}/${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
<builderName>${builder.name}</builderName>
|
||||
</buildx>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
<args>
|
||||
<BASE_IMAGE>${local.registry}/${base.image}:${image.tag}</BASE_IMAGE>
|
||||
</args>
|
||||
</build>
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-push-image</id>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-buildx</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>${scripts.directory}/prepare_buildx.sh</executable>
|
||||
<arguments>
|
||||
<argument>${builder.name}</argument>
|
||||
<argument>${image.registry}</argument>
|
||||
<argument>${image.name}</argument>
|
||||
<argument>${image.tag}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
@@ -650,37 +578,12 @@
|
||||
<images>
|
||||
<image>
|
||||
<!-- Quay image -->
|
||||
<name>${image.registry}/${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
<builderName>${builder.name}</builderName>
|
||||
</buildx>
|
||||
<args>
|
||||
<BASE_IMAGE>${local.registry}/${base.image}:${image.tag}</BASE_IMAGE>
|
||||
</args>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
<registry>${image.registry}</registry>
|
||||
</image>
|
||||
<image>
|
||||
<!-- DockerHub image -->
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
<builderName>${builder.name}</builderName>
|
||||
</buildx>
|
||||
<args>
|
||||
<BASE_IMAGE>${local.registry}/${base.image}:${image.tag}</BASE_IMAGE>
|
||||
</args>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
@@ -695,28 +598,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-buildx</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>${scripts.directory}/prepare_buildx.sh</executable>
|
||||
<arguments>
|
||||
<argument>${builder.name}</argument>
|
||||
<argument>${image.registry}</argument>
|
||||
<argument>${image.name}</argument>
|
||||
<argument>${image.tag}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
@@ -30,10 +30,8 @@ package org.alfresco.module.org_alfresco_module_rm.job;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -49,6 +47,7 @@ import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,6 +64,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
/** batching properties */
|
||||
private int batchSize;
|
||||
public static final int DEFAULT_BATCH_SIZE = 500;
|
||||
private static final String MSG_NODE_FROZEN = "rm.action.node.frozen.error-message";
|
||||
|
||||
/** list of disposition actions to automatically execute */
|
||||
private List<String> dispositionActions;
|
||||
@@ -194,7 +194,6 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
|
||||
boolean hasMore = true;
|
||||
int skipCount = 0;
|
||||
List<NodeRef> resultNodes = new ArrayList<>();
|
||||
|
||||
if (batchSize < 1)
|
||||
{
|
||||
@@ -215,14 +214,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
|
||||
// execute search
|
||||
ResultSet results = searchService.query(params);
|
||||
if(results != null)
|
||||
{
|
||||
// filtering out the hold/freezed cases from the result set
|
||||
resultNodes =
|
||||
results.getNodeRefs().stream().filter(node -> nodeService.getPrimaryParent(node) == null ?
|
||||
!freezeService.isFrozenOrHasFrozenChildren(node) :
|
||||
!freezeService.isFrozenOrHasFrozenChildren(nodeService.getPrimaryParent(node).getParentRef())).collect(Collectors.toList());
|
||||
}
|
||||
List<NodeRef> resultNodes = results.getNodeRefs();
|
||||
hasMore = results.hasMore();
|
||||
skipCount += resultNodes.size(); // increase by page size
|
||||
results.close();
|
||||
@@ -273,6 +265,12 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
}
|
||||
Map<String, Serializable> props = Map.of(PARAM_NO_ERROR_CHECK, false);
|
||||
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(parent.getParentRef()))
|
||||
{
|
||||
log.debug(I18NUtil.getMessage(MSG_NODE_FROZEN, dispAction));
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// execute disposition action
|
||||
|
@@ -4,8 +4,8 @@
|
||||
|
||||
# Version label
|
||||
version.major=7
|
||||
version.minor=4
|
||||
version.revision=0
|
||||
version.minor=3
|
||||
version.revision=1
|
||||
version.label=
|
||||
|
||||
# Edition label
|
||||
|
@@ -170,7 +170,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
executer.executeImpl();
|
||||
|
||||
// then
|
||||
verify(mockedNodeService, times(2)).getPrimaryParent(any(NodeRef.class));
|
||||
|
||||
// ensure the query is executed and closed
|
||||
verifyQueryTimes(2);
|
||||
|
||||
@@ -206,7 +206,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
executer.executeImpl();
|
||||
|
||||
// then
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(any(NodeRef.class));
|
||||
|
||||
// ensure the query is executed and closed
|
||||
verifyQueryTimes(1);
|
||||
|
||||
@@ -262,11 +262,11 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
// ensure each node is process correctly
|
||||
// node1
|
||||
verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
||||
verify(mockedNodeService, times(3)).getPrimaryParent(node1);
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(node1);
|
||||
verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(CUTOFF), anyMap());
|
||||
// node2
|
||||
verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
||||
verify(mockedNodeService, times(3)).getPrimaryParent(node2);
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(node2);
|
||||
verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(RETAIN), anyMap());
|
||||
|
||||
// ensure no more interactions
|
||||
@@ -329,7 +329,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
// call the service
|
||||
executer.executeImpl();
|
||||
|
||||
// check the loop iterated through all the elements
|
||||
// check the loop iterated trough all the elements
|
||||
verify(mockedNodeService).exists(node1);
|
||||
verify(mockedNodeService).exists(node2);
|
||||
verify(mockedNodeService).exists(node3);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -38,7 +38,6 @@ tags:
|
||||
description: Retrieve and manage unfiled records containers
|
||||
- name: unfiled-record-folders
|
||||
description: Retrieve and manage unfiled record folders
|
||||
|
||||
paths:
|
||||
## GS sites
|
||||
'/gs-sites':
|
||||
@@ -2092,7 +2091,6 @@ paths:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
parameters:
|
||||
## File plans
|
||||
filePlanEntryIncludeParam:
|
||||
@@ -3761,4 +3759,4 @@ definitions:
|
||||
- SiteConsumer
|
||||
- SiteCollaborator
|
||||
- SiteContributor
|
||||
- SiteManager
|
||||
- SiteManager
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -15,7 +15,7 @@
|
||||
</modules>
|
||||
|
||||
<!-- When adding a new AMP, create a profile for it here to add the module. The AMPS environment variable may
|
||||
then be used in aliases to optionally build it. The profile will however need to be added to the Github Actions
|
||||
then be used in aliases to optionally build it. The profile will however need to be added to the Travis
|
||||
build scripts. The share-services AMP is build by default as it is very fast. -->
|
||||
<profiles>
|
||||
<profile>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -121,6 +121,12 @@
|
||||
<version>${dependency.webscripts.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
@@ -241,7 +241,7 @@ var Filters =
|
||||
filterData = filterData.slice(0, -1);
|
||||
}
|
||||
filterQuery = this.constructPathQuery(parsedArgs);
|
||||
filterParams.query = filterQuery + " +PATH:\"/cm:categoryRoot/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\"";
|
||||
filterParams.query = filterQuery + " +PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\"";
|
||||
break;
|
||||
|
||||
case "aspect":
|
||||
|
@@ -230,7 +230,7 @@ var Filters =
|
||||
filterData = filterData.slice(0, -1);
|
||||
}
|
||||
filterQuery = this.constructPathQuery(parsedArgs);
|
||||
filterParams.query = filterQuery + " +PATH:\"/cm:categoryRoot/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\"";
|
||||
filterParams.query = filterQuery + " +PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\"";
|
||||
break;
|
||||
|
||||
default: // "path"
|
||||
|
21
core/pom.xml
21
core/pom.xml
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -54,14 +54,9 @@
|
||||
<classifier>asl</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
<artifactId>reload4j</artifactId>
|
||||
<version>1.2.18.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
@@ -118,8 +113,8 @@
|
||||
|
||||
<!-- Test only dependencies, as popped up while running mvn test -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j2-impl</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -137,10 +132,6 @@
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.httpclient;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequestInterceptor;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.HttpClientConnectionManager;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
|
||||
|
||||
public class HttpClient4Factory
|
||||
{
|
||||
protected static final String TLS_PROTOCOL = "TLS";
|
||||
protected static final String HTTPS_PROTOCOL = "https";
|
||||
protected static final String HTTP_TARGET_HOST = "http.target_host";
|
||||
protected static final String TLS_V_1_2 = "TLSv1.2";
|
||||
protected static final String TLS_V_1_3 = "TLSv1.3";
|
||||
|
||||
private static SSLContext createSSLContext(HttpClientConfig config)
|
||||
{
|
||||
KeyManager[] keyManagers = config.getKeyStore().createKeyManagers();
|
||||
TrustManager[] trustManagers = config.getTrustStore().createTrustManagers();
|
||||
|
||||
try
|
||||
{
|
||||
SSLContext sslcontext = SSLContext.getInstance(TLS_PROTOCOL);
|
||||
sslcontext.init(keyManagers, trustManagers, null);
|
||||
return sslcontext;
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to create SSL context", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static CloseableHttpClient createHttpClient(HttpClientConfig config)
|
||||
{
|
||||
return createHttpClient(config, null);
|
||||
}
|
||||
|
||||
public static CloseableHttpClient createHttpClient(HttpClientConfig config, HttpClientConnectionManager connectionManager)
|
||||
{
|
||||
HttpClientBuilder clientBuilder = HttpClients.custom();
|
||||
|
||||
if(config.isMTLSEnabled())
|
||||
{
|
||||
clientBuilder.addInterceptorFirst((HttpRequestInterceptor) (request, context) -> {
|
||||
if (!((HttpHost) context.getAttribute(HTTP_TARGET_HOST)).getSchemeName().equals(HTTPS_PROTOCOL))
|
||||
{
|
||||
String msg = "mTLS is enabled but provided URL does not use a secured protocol";
|
||||
throw new HttpClientException(msg);
|
||||
}
|
||||
});
|
||||
clientBuilder.setSSLSocketFactory(getSslConnectionSocketFactory(config));
|
||||
}
|
||||
|
||||
if (connectionManager != null)
|
||||
{
|
||||
clientBuilder.setConnectionManager(connectionManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Setting a connectionManager overrides these properties
|
||||
clientBuilder.setMaxConnTotal(config.getMaxTotalConnections());
|
||||
clientBuilder.setMaxConnPerRoute(config.getMaxHostConnections());
|
||||
}
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(config.getConnectionTimeout())
|
||||
.setSocketTimeout(config.getSocketTimeout())
|
||||
.setConnectionRequestTimeout(config.getConnectionRequestTimeout())
|
||||
.build();
|
||||
|
||||
clientBuilder.setDefaultRequestConfig(requestConfig);
|
||||
|
||||
clientBuilder.setRetryHandler(new StandardHttpRequestRetryHandler(5, false));
|
||||
|
||||
return clientBuilder.build();
|
||||
}
|
||||
|
||||
private static SSLConnectionSocketFactory getSslConnectionSocketFactory(HttpClientConfig config)
|
||||
{
|
||||
return new SSLConnectionSocketFactory(
|
||||
createSSLContext(config),
|
||||
new String[] { TLS_V_1_2, TLS_V_1_3 },
|
||||
null,
|
||||
config.isHostnameVerificationDisabled() ? new NoopHostnameVerifier() : SSLConnectionSocketFactory.getDefaultHostnameVerifier());
|
||||
}
|
||||
|
||||
public static PoolingHttpClientConnectionManager createPoolingConnectionManager(HttpClientConfig config)
|
||||
{
|
||||
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager;
|
||||
if(config.isMTLSEnabled())
|
||||
{
|
||||
poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("https", getSslConnectionSocketFactory(config))
|
||||
.build());
|
||||
}
|
||||
else
|
||||
{
|
||||
poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.build());
|
||||
}
|
||||
poolingHttpClientConnectionManager.setMaxTotal(config.getMaxTotalConnections());
|
||||
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(config.getMaxHostConnections());
|
||||
|
||||
return poolingHttpClientConnectionManager;
|
||||
}
|
||||
}
|
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.httpclient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.encryption.AlfrescoKeyStore;
|
||||
import org.alfresco.encryption.AlfrescoKeyStoreImpl;
|
||||
import org.alfresco.encryption.KeyResourceLoader;
|
||||
import org.alfresco.encryption.ssl.SSLEncryptionParameters;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class HttpClientConfig
|
||||
{
|
||||
private static final String HTTPCLIENT_CONFIG = "httpclient.config.";
|
||||
|
||||
protected static final Log LOGGER = LogFactory.getLog(HttpClientConfig.class);
|
||||
|
||||
private Properties properties;
|
||||
private String serviceName;
|
||||
|
||||
private SSLEncryptionParameters sslEncryptionParameters;
|
||||
private KeyResourceLoader keyResourceLoader;
|
||||
|
||||
private AlfrescoKeyStore keyStore;
|
||||
private AlfrescoKeyStore trustStore;
|
||||
|
||||
private Map<String, String> config;
|
||||
|
||||
public void setProperties(Properties properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName)
|
||||
{
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public void setSslEncryptionParameters(SSLEncryptionParameters sslEncryptionParameters)
|
||||
{
|
||||
this.sslEncryptionParameters = sslEncryptionParameters;
|
||||
}
|
||||
|
||||
public void setKeyResourceLoader(KeyResourceLoader keyResourceLoader)
|
||||
{
|
||||
this.keyResourceLoader = keyResourceLoader;
|
||||
}
|
||||
|
||||
public AlfrescoKeyStore getKeyStore()
|
||||
{
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
public AlfrescoKeyStore getTrustStore()
|
||||
{
|
||||
return trustStore;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
this.keyStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getKeyStoreParameters(), keyResourceLoader);
|
||||
this.trustStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getTrustStoreParameters(), keyResourceLoader);
|
||||
|
||||
config = retrieveConfig(serviceName);
|
||||
checkUnsupportedProperties(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used for retrieving HttpClient config from Global Properties
|
||||
* @param serviceName name of used service
|
||||
* @return map of properties
|
||||
*/
|
||||
private Map<String, String> retrieveConfig(String serviceName)
|
||||
{
|
||||
return properties.keySet().stream()
|
||||
.filter(key -> key instanceof String)
|
||||
.map(Object::toString)
|
||||
.filter(key -> key.startsWith(HTTPCLIENT_CONFIG + serviceName))
|
||||
.collect(Collectors.toMap(
|
||||
key -> key.replace(HTTPCLIENT_CONFIG + serviceName + ".", ""),
|
||||
key -> properties.getProperty(key, null)));
|
||||
}
|
||||
|
||||
private void checkUnsupportedProperties(Map<String, String> config)
|
||||
{
|
||||
config.keySet().stream()
|
||||
.filter(propertyName -> !HttpClientPropertiesEnum.isPropertyNameSupported(propertyName))
|
||||
.forEach(propertyName -> LOGGER.warn(String.format("For service [%s], an unsupported property [%s] is set", serviceName, propertyName)));
|
||||
}
|
||||
|
||||
private Integer getIntegerProperty(HttpClientPropertiesEnum property)
|
||||
{
|
||||
return Integer.parseInt(extractValueFromConfig(property).orElse("0"));
|
||||
}
|
||||
|
||||
private Boolean getBooleanProperty(HttpClientPropertiesEnum property)
|
||||
{
|
||||
return Boolean.parseBoolean(extractValueFromConfig(property).orElse("false"));
|
||||
}
|
||||
|
||||
private Optional<String> extractValueFromConfig(HttpClientPropertiesEnum property)
|
||||
{
|
||||
Optional<String> optionalProperty = Optional.ofNullable(config.get(property.name));
|
||||
if(property.isRequired && optionalProperty.isEmpty())
|
||||
{
|
||||
String msg = String.format("Required property: '%s' is empty.", property.name);
|
||||
throw new HttpClientException(msg);
|
||||
}
|
||||
return optionalProperty;
|
||||
}
|
||||
|
||||
public Integer getConnectionTimeout()
|
||||
{
|
||||
return getIntegerProperty(HttpClientPropertiesEnum.CONNECTION_REQUEST_TIMEOUT);
|
||||
}
|
||||
|
||||
public Integer getSocketTimeout()
|
||||
{
|
||||
return getIntegerProperty(HttpClientPropertiesEnum.SOCKET_TIMEOUT);
|
||||
}
|
||||
|
||||
public Integer getConnectionRequestTimeout()
|
||||
{
|
||||
return getIntegerProperty(HttpClientPropertiesEnum.CONNECTION_REQUEST_TIMEOUT);
|
||||
}
|
||||
|
||||
public Integer getMaxTotalConnections()
|
||||
{
|
||||
return getIntegerProperty(HttpClientPropertiesEnum.MAX_TOTAL_CONNECTIONS);
|
||||
}
|
||||
|
||||
public Integer getMaxHostConnections()
|
||||
{
|
||||
return getIntegerProperty(HttpClientPropertiesEnum.MAX_HOST_CONNECTIONS);
|
||||
}
|
||||
|
||||
public Boolean isMTLSEnabled()
|
||||
{
|
||||
return getBooleanProperty(HttpClientPropertiesEnum.MTLS_ENABLED);
|
||||
}
|
||||
|
||||
public boolean isHostnameVerificationDisabled()
|
||||
{
|
||||
return getBooleanProperty(HttpClientPropertiesEnum.HOSTNAME_VERIFICATION_DISABLED);
|
||||
}
|
||||
|
||||
private enum HttpClientPropertiesEnum
|
||||
{
|
||||
CONNECTION_TIMEOUT("connectionTimeout", true),
|
||||
SOCKET_TIMEOUT("socketTimeout", true),
|
||||
CONNECTION_REQUEST_TIMEOUT("connectionRequestTimeout", true),
|
||||
MAX_TOTAL_CONNECTIONS("maxTotalConnections", true),
|
||||
MAX_HOST_CONNECTIONS("maxHostConnections", true),
|
||||
HOSTNAME_VERIFICATION_DISABLED("hostnameVerificationDisabled", false),
|
||||
MTLS_ENABLED("mTLSEnabled", true);
|
||||
|
||||
private final String name;
|
||||
private final Boolean isRequired;
|
||||
|
||||
HttpClientPropertiesEnum(String propertyName, Boolean isRequired)
|
||||
{
|
||||
this.name = propertyName;
|
||||
this.isRequired = isRequired;
|
||||
}
|
||||
|
||||
private static final List<String> supportedProperties = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (HttpClientPropertiesEnum property : HttpClientPropertiesEnum.values()) {
|
||||
supportedProperties.add(property.name);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPropertyNameSupported(String propertyName) {
|
||||
return supportedProperties.contains(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.httpclient;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
public class HttpClientException extends AlfrescoRuntimeException
|
||||
{
|
||||
public HttpClientException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
}
|
||||
}
|
@@ -45,13 +45,6 @@ public class ListBackedPagingResults<R> implements PagingResults<R>
|
||||
size = list.size();
|
||||
hasMore = false;
|
||||
}
|
||||
|
||||
public ListBackedPagingResults(List<R> list, boolean hasMore)
|
||||
{
|
||||
this(list);
|
||||
this.hasMore = hasMore;
|
||||
}
|
||||
|
||||
public ListBackedPagingResults(List<R> list, PagingRequest paging)
|
||||
{
|
||||
// Excerpt
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2022 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* A stand in for the org.apache.logging.log4j.ThreadContext class that avoids introducing runtime dependencies against the otherwise
|
||||
* A stand in for the org.apache.log4j.NDC class that avoids introducing runtime dependencies against the otherwise
|
||||
* optional log4j.
|
||||
*
|
||||
* @author dward
|
||||
@@ -32,7 +32,7 @@ public class NDC
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(NDC.class);
|
||||
|
||||
/** Log4J2 delegate for NDC */
|
||||
/** Log4J delegate for NDC */
|
||||
private static NDCDelegate ndcDelegate;
|
||||
|
||||
static
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2022 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -25,19 +25,19 @@
|
||||
package org.alfresco.util.log.log4j;
|
||||
|
||||
import org.alfresco.util.log.NDCDelegate;
|
||||
import org.apache.logging.log4j.ThreadContext;
|
||||
import org.apache.log4j.NDC;
|
||||
|
||||
/**
|
||||
* A stand in for the org.apache.logging.log4j.ThreadContext class that avoids introducing runtime dependencies against the otherwise
|
||||
* A stand in for the org.apache.log4j.NDC class that avoids introducing runtime dependencies against the otherwise
|
||||
* optional log4j.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class Log4JNDC implements NDCDelegate
|
||||
{
|
||||
// Force resolution of the log4j2 ThreadContext class by the classloader (thus forcing an error if unavailable)
|
||||
// Force resolution of the log4j NDC class by the classloader (thus forcing an error if unavailable)
|
||||
@SuppressWarnings("unused")
|
||||
private static final Class<?> NDC_REF = ThreadContext.class;
|
||||
private static final Class<?> NDC_REF = NDC.class;
|
||||
|
||||
/**
|
||||
* Push new diagnostic context information for the current thread.
|
||||
@@ -47,7 +47,7 @@ public class Log4JNDC implements NDCDelegate
|
||||
*/
|
||||
public void push(String message)
|
||||
{
|
||||
ThreadContext.push(message);
|
||||
NDC.push(message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +55,6 @@ public class Log4JNDC implements NDCDelegate
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
ThreadContext.clearAll();
|
||||
NDC.remove();
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -134,7 +134,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<version>6.4.0</version>
|
||||
<version>6.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- the cxf libs were updated, see dependencyManagement section -->
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Data model classes
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||
* 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
|
||||
@@ -51,18 +51,6 @@ public class MLText extends HashMap<Locale, String>
|
||||
{
|
||||
private static final long serialVersionUID = -3696135175650511841L;
|
||||
|
||||
/**
|
||||
* Returns default locale used by the {@link MLText} implementation
|
||||
*
|
||||
* @see I18NUtil#getLocale()
|
||||
*
|
||||
* @return default locale
|
||||
*/
|
||||
public static Locale getDefaultLocale()
|
||||
{
|
||||
return I18NUtil.getLocale();
|
||||
}
|
||||
|
||||
public MLText()
|
||||
{
|
||||
super(3, 0.75F);
|
||||
@@ -73,13 +61,13 @@ public class MLText extends HashMap<Locale, String>
|
||||
*
|
||||
* @param value the value for the current default locale
|
||||
*
|
||||
* @see #getDefaultLocale()
|
||||
* @see I18NUtil#getLocale()
|
||||
* @see #MLText(Locale, String)
|
||||
* @see #getDefaultValue()
|
||||
*/
|
||||
public MLText(String value)
|
||||
{
|
||||
this(getDefaultLocale(), value);
|
||||
this(I18NUtil.getLocale(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +124,7 @@ public class MLText extends HashMap<Locale, String>
|
||||
/**
|
||||
* Retrieves a default value from the set of available locales.<br/>
|
||||
*
|
||||
* @see #getDefaultLocale()
|
||||
* @see I18NUtil#getLocale()
|
||||
* @see #getClosestValue(Locale)
|
||||
*/
|
||||
public String getDefaultValue()
|
||||
@@ -147,7 +135,7 @@ public class MLText extends HashMap<Locale, String>
|
||||
return null;
|
||||
}
|
||||
// There is some hope of getting a match
|
||||
Locale locale = getDefaultLocale();
|
||||
Locale locale = I18NUtil.getLocale();
|
||||
return getClosestValue(locale);
|
||||
}
|
||||
|
||||
@@ -180,7 +168,7 @@ public class MLText extends HashMap<Locale, String>
|
||||
if (match == null)
|
||||
{
|
||||
// No close matches for the locale - go for the default locale
|
||||
locale = getDefaultLocale();
|
||||
locale = I18NUtil.getLocale();
|
||||
match = I18NUtil.getNearestLocale(locale, options);
|
||||
if (match == null)
|
||||
{
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Fetch image based on Tomcat 9.0, Java 17 and Rocky Linux 8
|
||||
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
||||
FROM alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8-202303081618
|
||||
FROM alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8-202209261711
|
||||
|
||||
# Set default docker_context.
|
||||
ARG resource_path=target
|
||||
@@ -42,6 +42,10 @@ RUN sed -i "s/shared.loader=/shared.loader=\${catalina.base}\/shared\/classes/"
|
||||
|
||||
RUN mkdir -p ${TOMCAT_DIR}/amps
|
||||
|
||||
#RUN echo -e '\n\
|
||||
#log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug\n\
|
||||
#' >> ${TOMCAT_DIR}/shared/classes/alfresco/extension/custom-log4j.propertiesRUN mkdir -p ${TOMCAT_DIR}/amps
|
||||
|
||||
# Copy the amps from build context to the appropriate location for your application server
|
||||
COPY ${resource_path}/amps ${TOMCAT_DIR}/amps
|
||||
|
||||
@@ -51,21 +55,20 @@ RUN java -jar ${TOMCAT_DIR}/alfresco-mmt/alfresco-mmt*.jar install \
|
||||
${TOMCAT_DIR}/webapps/alfresco -directory -nobackup
|
||||
|
||||
# Move the log file
|
||||
RUN sed -i -e "s_appender.rolling.fileName\=alfresco.log_appender.rolling.fileName\=${TOMCAT_DIR}/logs\/alfresco.log_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j2.properties && \
|
||||
sed -i -e "s_appender.rolling.filePattern=alfresco.log.%d{yyyy-MM-dd}_appender.rolling.filePattern\=${TOMCAT_DIR}/logs\/alfresco.log.%d{yyyy-MM-dd}_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j2.properties && \
|
||||
RUN sed -i -e "s_log4j.appender.File.File\=alfresco.log_log4j.appender.File.File\=${TOMCAT_DIR}/logs\/alfresco.log_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j.properties && \
|
||||
|
||||
# Add catalina.policy to ROOT.war and alfresco.war
|
||||
# Grant all security permissions to alfresco webapp because of numerous permissions required in order to work properly.
|
||||
# Grant only deployXmlPermission to ROOT webapp.
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/_vti_bin\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" ${TOMCAT_DIR}/conf/catalina.policy
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" ${TOMCAT_DIR}/conf/catalina.policy
|
||||
|
||||
# fontconfig is required by Activiti worflow diagram generator
|
||||
# installing pinned dependencies as well
|
||||
RUN yum install -y fontconfig-2.13.1-4.el8 \
|
||||
dejavu-fonts-common-2.35-7.el8 \
|
||||
fontpackages-filesystem-1.44-22.el8 \
|
||||
freetype-2.9.1-9.el8 \
|
||||
freetype-2.9.1-4.el8_3.1 \
|
||||
libpng-1.6.34-5.el8 \
|
||||
dejavu-sans-fonts-2.35-7.el8 && \
|
||||
yum clean all
|
||||
|
@@ -7,12 +7,11 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<image.name>alfresco/alfresco-community-repo-base</image.name>
|
||||
<scripts.directory>${project.parent.parent.basedir}/scripts</scripts.directory>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -79,6 +78,7 @@
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>copy-amps</id>
|
||||
<phase>process-resources</phase>
|
||||
@@ -157,67 +157,6 @@
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>build-multiarch-docker-images</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
<name>${local.registry}/${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
<builderName>${builder.name}</builderName>
|
||||
</buildx>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-push-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-buildx</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>${scripts.directory}/prepare_buildx.sh</executable>
|
||||
<arguments>
|
||||
<argument>${builder.name}</argument>
|
||||
<argument>${image.registry}</argument>
|
||||
<argument>${image.name}</argument>
|
||||
<argument>${image.tag}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>push-docker-images</id>
|
||||
<!-- publishes "image:latest" on Quay & DockerHub -->
|
||||
@@ -230,29 +169,12 @@
|
||||
<images>
|
||||
<!-- Quay image -->
|
||||
<image>
|
||||
<name>${image.registry}/${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
</buildx>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
<registry>${image.registry}</registry>
|
||||
</image>
|
||||
<!-- DockerHub image -->
|
||||
<image>
|
||||
<name>${image.name}:${image.tag}</name>
|
||||
<build>
|
||||
<buildx>
|
||||
<platforms>
|
||||
<platform>linux/amd64</platform>
|
||||
<platform>linux/arm64</platform>
|
||||
</platforms>
|
||||
</buildx>
|
||||
<contextDir>${project.basedir}</contextDir>
|
||||
</build>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.7-A5
|
||||
SOLR6_TAG=2.0.5
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TAS_DIRECTORY=$1
|
||||
|
||||
cd ${TAS_DIRECTORY}
|
||||
|
||||
cat target/reports/alfresco-tas.log | grep -a "*** STARTING"
|
@@ -1,21 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
export DOCKER_COMPOSE_PATH=$1
|
||||
export DOCKER_COMPOSES=""
|
||||
export CLEAN_UP=""
|
||||
export CLEAN_UP="$2"
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
if [ "$var" == "no-clean-up" ]
|
||||
then
|
||||
export CLEAN_UP="$var"
|
||||
else
|
||||
export DOCKER_COMPOSES+="--file $var "
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$DOCKER_COMPOSES" ]
|
||||
if [ -z "$DOCKER_COMPOSE_PATH" ]
|
||||
then
|
||||
echo "Please provide path to docker-compose.yml: \"${0##*/} /path/to/docker-compose.yml\""
|
||||
exit 1
|
||||
@@ -27,8 +15,8 @@ fi
|
||||
# The second parameter can be used to avoid doing a clean up if we are doing a restart test.
|
||||
if [ "$CLEAN_UP" != "no-clean-up" ]
|
||||
then
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") kill
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") rm -f
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" kill
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" rm -f
|
||||
|
||||
export GENERATED_IMAGES=$(docker images | grep '^environment_' | awk '{ print $3 }')
|
||||
if [ -n "$GENERATED_IMAGES" ]
|
||||
@@ -43,7 +31,7 @@ export TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-tra
|
||||
export TRANSFORM_ROUTER_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-service.version -q -DforceStdout)
|
||||
|
||||
# .env files are picked up from project directory correctly on docker-compose 1.23.0+
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -4,6 +4,8 @@ import org.alfresco.utility.data.AisToken;
|
||||
import org.alfresco.utility.data.auth.DataAIS;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.chemistry.opencmis.commons.SessionParameter;
|
||||
import org.keycloak.authorization.client.util.HttpResponseException;
|
||||
import org.keycloak.representations.AccessTokenResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -84,9 +86,9 @@ public class AuthParameterProviderFactory
|
||||
parameters.put(SessionParameter.OAUTH_REFRESH_TOKEN, aisToken.getRefreshToken());
|
||||
parameters.put(SessionParameter.OAUTH_EXPIRATION_TIMESTAMP, String.valueOf(System.currentTimeMillis()
|
||||
+ (aisToken.getExpiresIn() * 1000))); // getExpiresIn is in seconds
|
||||
parameters.put(SessionParameter.OAUTH_TOKEN_ENDPOINT, cmisProperties.aisProperty().getAuthServerUrl()
|
||||
parameters.put(SessionParameter.OAUTH_TOKEN_ENDPOINT, cmisProperties.aisProperty().getAdapterConfig().getAuthServerUrl()
|
||||
+ "/realms/alfresco/protocol/openid-connect/token");
|
||||
parameters.put(SessionParameter.OAUTH_CLIENT_ID, cmisProperties.aisProperty().getResource());
|
||||
parameters.put(SessionParameter.OAUTH_CLIENT_ID, cmisProperties.aisProperty().getAdapterConfig().getResource());
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@@ -108,10 +110,10 @@ public class AuthParameterProviderFactory
|
||||
// Attempt to get an access token for userModel from AIS
|
||||
aisToken = dataAIS.perform().getAccessToken(userModel);
|
||||
}
|
||||
catch (AssertionError e)
|
||||
catch (HttpResponseException e)
|
||||
{
|
||||
// Trying to authenticate with invalid user credentials so return an invalid access token
|
||||
if (e.getMessage().contains("invalid_grant"))
|
||||
if (e.getStatusCode() == 401)
|
||||
{
|
||||
STEP(String.format("%s Invalid user credentials were provided %s:%s. Using invalid token for reqest.",
|
||||
STEP_PREFIX, userModel.getUsername(), userModel.getPassword()));
|
||||
|
26
packaging/tests/tas-cmis/src/main/resources/log4j.properties
Normal file
26
packaging/tests/tas-cmis/src/main/resources/log4j.properties
Normal file
@@ -0,0 +1,26 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file, stdout
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/alfresco-tas.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# Direct log messages to stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
|
||||
log4j.appender.testrailLog.MaxBackupIndex=10
|
||||
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.category.testrail=INFO, testrailLog
|
||||
log4j.additivity.testrail=false
|
@@ -1,42 +0,0 @@
|
||||
# Root logger option
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=ConsoleAppender
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=./target/reports/alfresco-tas.log
|
||||
appender.rolling.filePattern=./target/reports/alfresco-tas.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type = Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Console appender definition #######
|
||||
appender.console.type=Console
|
||||
appender.console.name=ConsoleAppender
|
||||
appender.console.layout.type=PatternLayout
|
||||
appender.console.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
logger.testrail.name=testrail
|
||||
logger.testrail.level=info
|
||||
logger.testrail.additivity=false
|
||||
logger.testrail.appenderRef.testrail.ref=TestrailAppender
|
||||
|
||||
appender.testrail.name=TestrailAppender
|
||||
appender.testrail.type=RollingFile
|
||||
appender.testrail.fileName=./target/reports/alfresco-testrail.log
|
||||
appender.testrail.filePattern=./target/reports/alfresco-testrail.log.%i
|
||||
appender.testrail.layout.type=PatternLayout
|
||||
appender.testrail.layout.pattern=%d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.testrail.policies.type=Policies
|
||||
appender.testrail.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.testrail.policies.size.size=10MB
|
||||
appender.testrail.strategy.type=DefaultRolloverStrategy
|
||||
appender.testrail.strategy.max=10
|
26
packaging/tests/tas-cmis/src/test/resources/log4j.properties
Normal file
26
packaging/tests/tas-cmis/src/test/resources/log4j.properties
Normal file
@@ -0,0 +1,26 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file, stdout
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/alfresco-tas.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# Direct log messages to stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
|
||||
log4j.appender.testrailLog.MaxBackupIndex=10
|
||||
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.category.testrail=INFO, testrailLog
|
||||
log4j.additivity.testrail=false
|
@@ -1,42 +0,0 @@
|
||||
# Root logger option
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=ConsoleAppender
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=./target/reports/alfresco-tas.log
|
||||
appender.rolling.filePattern=./target/reports/alfresco-tas.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type = Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Console appender definition #######
|
||||
appender.console.type=Console
|
||||
appender.console.name=ConsoleAppender
|
||||
appender.console.layout.type=PatternLayout
|
||||
appender.console.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
logger.testrail.name=testrail
|
||||
logger.testrail.level=info
|
||||
logger.testrail.additivity=false
|
||||
logger.testrail.appenderRef.testrail.ref=TestrailAppender
|
||||
|
||||
appender.testrail.name=TestrailAppender
|
||||
appender.testrail.type=RollingFile
|
||||
appender.testrail.fileName=./target/reports/alfresco-testrail.log
|
||||
appender.testrail.filePattern=./target/reports/alfresco-testrail.log.%i
|
||||
appender.testrail.layout.type=PatternLayout
|
||||
appender.testrail.layout.pattern=%d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.testrail.policies.type=Policies
|
||||
appender.testrail.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.testrail.policies.size.size=10MB
|
||||
appender.testrail.strategy.type=DefaultRolloverStrategy
|
||||
appender.testrail.strategy.max=10
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -0,0 +1,26 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file, stdout
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/alfresco-tas.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# Direct log messages to stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
|
||||
log4j.appender.testrailLog.MaxBackupIndex=10
|
||||
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.category.testrail=INFO, testrailLog
|
||||
log4j.additivity.testrail=false
|
@@ -1,42 +0,0 @@
|
||||
# Root logger option
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=ConsoleAppender
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=./target/reports/alfresco-tas.log
|
||||
appender.rolling.filePattern=./target/reports/alfresco-tas.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type = Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Console appender definition #######
|
||||
appender.console.type=Console
|
||||
appender.console.name=ConsoleAppender
|
||||
appender.console.layout.type=PatternLayout
|
||||
appender.console.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
logger.testrail.name=testrail
|
||||
logger.testrail.level=info
|
||||
logger.testrail.additivity=false
|
||||
logger.testrail.appenderRef.testrail.ref=TestrailAppender
|
||||
|
||||
appender.testrail.name=TestrailAppender
|
||||
appender.testrail.type=RollingFile
|
||||
appender.testrail.fileName=./target/reports/alfresco-testrail.log
|
||||
appender.testrail.filePattern=./target/reports/alfresco-testrail.log.%i
|
||||
appender.testrail.layout.type=PatternLayout
|
||||
appender.testrail.layout.pattern=%d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.testrail.policies.type=Policies
|
||||
appender.testrail.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.testrail.policies.size.size=10MB
|
||||
appender.testrail.strategy.type=DefaultRolloverStrategy
|
||||
appender.testrail.strategy.max=10
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
@@ -66,7 +66,6 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -95,6 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>${dependency.jakarta-json-path.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@@ -0,0 +1,26 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file, stdout
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/alfresco-tas.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# Direct log messages to stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
|
||||
log4j.appender.testrailLog.MaxBackupIndex=10
|
||||
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.category.testrail=INFO, testrailLog
|
||||
log4j.additivity.testrail=false
|
@@ -1,42 +0,0 @@
|
||||
# Root logger option
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=ConsoleAppender
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=./target/reports/alfresco-tas.log
|
||||
appender.rolling.filePattern=./target/reports/alfresco-tas.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type = Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Console appender definition #######
|
||||
appender.console.type=Console
|
||||
appender.console.name=ConsoleAppender
|
||||
appender.console.layout.type=PatternLayout
|
||||
appender.console.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
|
||||
# TestRail particular log file
|
||||
# Direct log messages to a log file
|
||||
logger.testrail.name=testrail
|
||||
logger.testrail.level=info
|
||||
logger.testrail.additivity=false
|
||||
logger.testrail.appenderRef.testrail.ref=TestrailAppender
|
||||
|
||||
appender.testrail.name=TestrailAppender
|
||||
appender.testrail.type=RollingFile
|
||||
appender.testrail.fileName=./target/reports/alfresco-testrail.log
|
||||
appender.testrail.filePattern=./target/reports/alfresco-testrail.log.%i
|
||||
appender.testrail.layout.type=PatternLayout
|
||||
appender.testrail.layout.pattern=%d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.testrail.policies.type=Policies
|
||||
appender.testrail.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.testrail.policies.size.size=10MB
|
||||
appender.testrail.strategy.type=DefaultRolloverStrategy
|
||||
appender.testrail.strategy.max=10
|
@@ -1,564 +0,0 @@
|
||||

|
||||
|
||||
Back to [TAS Master Documentation](https://git.alfresco.com/tas/alfresco-tas-utility/wikis/home)
|
||||
|
||||
---
|
||||
## Table of Contents
|
||||
* [Synopsis](#synopsis)
|
||||
* [Prerequisite](#prerequisite)
|
||||
* [Installation](#installation-if-you-want-to-contribute)
|
||||
* [Package Presentation](#package-presentation)
|
||||
* [Sample Usage](#sample-usage)
|
||||
* [How to write a test](#how-to-write-a-test)
|
||||
* [How to generate models or check coverage](#how-to-generate-models-or-check-coverage)
|
||||
* [How to run tests?](#how-to-run-tests)
|
||||
* [from IDE](#from-ide)
|
||||
* [from command line](#from-command-line)
|
||||
* [Listeners](#listeners)
|
||||
* [Test Results](#test-results)
|
||||
* [Test Rail Integration](#test-rail-integration)
|
||||
* [Configuration](#configuration)
|
||||
* [How to enable Test Rail Integration?](#how-to-enable-test-rail-integration)
|
||||
* [Reference](#reference)
|
||||
* [Change Log](docs/CHANGELOG.md) 🌟
|
||||
* [Contributors](#contributors)
|
||||
* [Releasing](#releasing)
|
||||
* [License](#license)
|
||||
|
||||
## Synopsis
|
||||
|
||||
**TAS**( **T**est **A**utomation **S**ystem)- **RESTAPI** is the project that handles the automated tests related only to [Alfresco REST API](http://docs.alfresco.com/5.1/pra/1/topics/pra-welcome.html).
|
||||
|
||||
It is based on Apache Maven, compatible with major IDEs and is using also Spring capabilities for dependency injection.
|
||||
|
||||
As a high level overview, this project makes use of the following functionality useful in automation testing as:
|
||||
* reading/defining test environment settings (e.g. alfresco server details, authentication, etc.)
|
||||
* managing resource (i.e. creating files and folders)
|
||||
* test data generators (for site, users, content, etc)
|
||||
* helpers (i.e. randomizers, test environment information)
|
||||
* test logging generated on runtime and test reporting capabilities
|
||||
* test management tool integration (at this point we support integration with [Test Rail](https://alfresco.testrail.net) (v5.2.1)
|
||||
* health checks (verify if server is reachable, if server is online)
|
||||
* generic Internal-DSL (Domain Specific Language)
|
||||
|
||||
Using Nexus -Release Repository, everyone will be able to use individual interfaces in their projects by extending the automation core functionalities.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Prerequisite
|
||||
(tested on unix/non-unix destribution)
|
||||
* [Java SE 1.8](http://www.oracle.com/technetwork/java/javase/downloads/index.html).
|
||||
* [Maven 3.3](https://maven.apache.org/download.cgi) installed and configure according to [Windows OS](https://maven.apache.org/guides/getting-started/windows-prerequisites.html) or [Mac OS](https://maven.apache.org/install.html).
|
||||
* Configure Maven to use Alfresco alfresco-internal repository following this [Guide](https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Maven_Setup).
|
||||
* Your favorite IDE as [Eclipse](https://eclipse.org/downloads/) or [InteliJ](https://www.jetbrains.com/idea).
|
||||
* Access to [Nexus](https://nexus.alfresco.com/nexus/) repository.
|
||||
* Access to Gitlab [TAS](https://gitlab.alfresco.com/tas/) repository.
|
||||
* GitLab client for your operating system. (we recommend [SourceTree](https://www.sourcetreeapp.com) - use your google account for initial setup).
|
||||
* Getting familiar with [Basic Git Commands](http://docs.gitlab.com/ee/gitlab-basics/basic-git-commands.html).
|
||||
* Getting familiar with [Maven](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
|
||||
* Getting familiar with [Spring](http://docs.spring.io).
|
||||
* Getting familiar with [TestNG](http://testng.org/doc/index.html)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Installation (if you want to contribute)
|
||||
|
||||
* Open your Gitlab client and clone the repository of this project.
|
||||
* You can do this also from command line (or in your terminal) adding:
|
||||
|
||||
```bash
|
||||
$ git clone https://git.alfresco.com/tas/alfresco-tas-restapi-test.git
|
||||
# this clone will have the latest changes from repository. If you want to checkout a specific version released, take a look at the [Change Log](docs/CHANGELOG.md) page
|
||||
$ cd alfresco-tas-tester
|
||||
# this command will checkout the remove v2.0.0 tagged repository and create locally a new branch v2.0.0
|
||||
$ git checkout tags/v2.0.0 -b v2.0.0
|
||||
|
||||
```
|
||||
|
||||
* Install and check if all dependencies are downloaded
|
||||
|
||||
```bash
|
||||
> cd alfresco-tas-restapi-test
|
||||
> mvn clean install -DskipTests
|
||||
# you should see one [INFO] BUILD SUCCESS message displayed
|
||||
```
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Package Presentation
|
||||
|
||||
The project uses a maven layout [archetype](https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/simple.html):
|
||||
```ruby
|
||||
├── pom.xml
|
||||
├── report.html
|
||||
├── src
|
||||
│ ├── main
|
||||
│ │ └── java
|
||||
│ │ └── org
|
||||
│ │ └── alfresco
|
||||
│ │ └── rest
|
||||
│ │ ├── core
|
||||
│ │ │ ├── assertion
|
||||
│ │ │ │ ├── IModelAssertion.java
|
||||
│ │ │ │ ├── IModelsCollectionAssertion.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── PaginationAssertionVerbs.java
|
||||
│ │ │ ├── swagger
|
||||
│ │ │ │ ├── Generator.java
|
||||
│ │ │ │ ├── RestModelProperty.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── SwaggerYamlParser.java
|
||||
│ │ │ ├── IRestModel.java
|
||||
│ │ │ ├── IRestModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── RestResponse.java
|
||||
│ │ │ └── RestWrapper.java
|
||||
│ │ ├── exception
|
||||
│ │ │ ├── EmptyJsonResponseException.java
|
||||
│ │ │ ├── EmptyRestModelCollectionException.java
|
||||
│ │ │ └── JsonToModelConversionException.java
|
||||
│ │ ├── model
|
||||
│ │ │ ├── builder
|
||||
│ │ │ │ └── NodesBuilder.java
|
||||
│ │ │ ├── RestActivityModel.java
|
||||
│ │ │ ├── RestActivityModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── RestVariableModelsCollection.java
|
||||
│ │ ├── requests
|
||||
│ │ │ ├── authAPI
|
||||
│ │ │ │ └── RestAuthAPI.java
|
||||
│ │ │ ├── coreAPI
|
||||
│ │ │ │ └── RestCoreAPI.java
|
||||
│ │ │ ├── workflowAPI
|
||||
│ │ │ │ └── RestWorkflowAPI.java
|
||||
│ │ │ ├── Deployments.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── Tenant.java
|
||||
│ │
|
||||
│ ├── test
|
||||
│ │ ├── java
|
||||
│ │ │ └── org
|
||||
│ │ │ └── alfresco
|
||||
│ │ │ └── rest
|
||||
│ │ │ ├── auth
|
||||
│ │ │ │ └── AuthTests.java
|
||||
│ │ │ ├── comments
|
||||
│ │ │ │ ├── AddCommentCoreTests.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── workflow
|
||||
│ │ │ │ ├── deployments
|
||||
│ │ │ │ │ ├── DeleteDeploymentCoreFullTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── processDefinitions
|
||||
│ │ │ │ │ ├── GetProcessDefinitionCoreTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── FunctionalCasesTests.java
|
||||
│ │ │ └── RestTest.java
|
||||
│ │ └── resources
|
||||
│ │ ├── alfresco-restapi-context.xml
|
||||
│ │ ├── default.properties
|
||||
│ │ └── log4j.properties
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Sample Usage
|
||||
|
||||
Following the standard layout for Maven projects, the application sources locate in src/main/java and test sources locate in src/test/java.
|
||||
Application sources consist in defining the REST API object that simulates the calls: get, post, put, delete.
|
||||
The tests are based on an abstract object: Rest.java that handles the common behavior: checking the health status of the test server, configuration settings, getting the general properties, etc.
|
||||
|
||||
Please take a look at [RestDemoTests.java](src/test/java/org/alfresco/rest/demo/RestDemoTests.java) class for an example.
|
||||
|
||||
Common configuration settings required for this project are stored in properties file, see [default.properties](src/test/resources/default.properties).
|
||||
Please analyze and update it accordingly with Alfresco test server IP, port, credentials, etc.
|
||||
|
||||
Example:
|
||||
```java
|
||||
# Alfresco HTTP Server Settings
|
||||
alfresco.scheme=http
|
||||
alfresco.server=<add-here-the-ip-of-your-test-server>
|
||||
alfresco.port=<default-port-for-alfresco-not-share>
|
||||
```
|
||||
|
||||
* optional update the logging level in [log4j](src/test/resources/log4j.properties) file (you can increase/decrease the deails of the [logging file](https://logging.apache.org/log4j/1.2/manual.html), setting the ```log4j.rootLogger=DEBUG``` if you want.)
|
||||
* go to [running](#how-to-run-tests) section for more information on how to run this tests.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to write a test
|
||||
|
||||
* Please also take a look at the [Rest-API desing and implementation](https://ts.alfresco.com/share/page/site/eng/document-details?nodeRef=workspace://SpacesStore/9f7823e7-0597-4435-9fd1-6ec8a4791259) guidelines.
|
||||
* Tests are organized in java classes and located on src/test/java as per maven layout.
|
||||
* One test class should contain the tests that cover one functionality as we want to have a clear separation of test scope: tests for sanity/core/full, tests that verify manage of folder/files etc.
|
||||
* These are the conventions that need to follow when you write a test:
|
||||
* The test class has @Test annotation with the group defined: rest-api. You can add more groups like sanity, regression
|
||||
|
||||
```java
|
||||
@Test(groups={ TestGroup.COMMENTS}
|
||||
```
|
||||
|
||||
* The test has @TestRail annotation in order to assure that the details and results will be submitted on TestRail. The fields for TestRail annotation will be explained on next chapter.
|
||||
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets person with Rest API and response is not empty")
|
||||
public void adminShouldRetrievePerson() throws Exception
|
||||
{
|
||||
peopleAPI.getPerson(userModel.getUsername())
|
||||
.assertResponseIsNotEmpty();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
* Use Spring capabilities to initialize the objects(Models, Wrappers) with @Autowired
|
||||
|
||||
* To view a simple class that is using this utility, just browse on [RestDemoTests.java]((src/test/java/org/alfresco/rest/demo/RestDemoTests.java)
|
||||
Notice the class definition and inheritance value:
|
||||
|
||||
```java
|
||||
public class RestDemoTest extends RestTest
|
||||
```
|
||||
|
||||
* as a convention, before running your test, check if the test environment is reachable and your alfresco test server is online.
|
||||
(this will stop the test if the server defined in your property file is not healthy - method available in parent class)
|
||||
|
||||
```java
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupRestTest() throws Exception{
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
```
|
||||
* the test name are self explanatory:
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets sites with Rest API and status code is 200")
|
||||
public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
siteAPI.getSites();
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
```
|
||||
* Asserting on imbricated keys:
|
||||
|
||||
Let's say your response is something like:
|
||||
|
||||
```json
|
||||
{"entry": {
|
||||
"createdAt": "2017-08-01T12:01:24.979+0000",
|
||||
"edited": false,
|
||||
"modifiedBy": {
|
||||
"firstName": "Administrator"
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
if you want to assert that firstName is "Administrator" you can do that using the following DSL:
|
||||
|
||||
```java
|
||||
restClient.onResponse().assertThat().body("entry.modifiedBy.firstName", org.hamcrest.Matchers.is("Administrator"));
|
||||
```
|
||||
|
||||
(notice that i'm using Hamcrest Matcher to finalize this assertion)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to generate models or check coverage
|
||||
|
||||
There are some simple generators that could parse [Swagger YAML](http://docs.alfresco.com/community/concepts/alfresco-sdk-tutorials-using-rest-api-explorer.html) files and provide some usefull information to you like:
|
||||
|
||||
a) Show on screen the actual coverage of TAS vs requests that exists in each YAML file - defined in pom.xml)
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dcoverage
|
||||
```
|
||||
Any missing request are saved under "missing-requests```<yaml-file-name>```.txt" file for further analysis
|
||||
All current implementation are saved under "implemented-requests```<yaml-file-name>```.txt"
|
||||

|
||||
|
||||
b) Generate all missing models
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels
|
||||
```
|
||||
|
||||
This command will read all definitions of models from swagger YAML file predefined in pom.xml file.
|
||||
It will compare with this file pattern: 'Rest```<model-definition-name>```Model.java', file created under ```/src/main/java/org/alfresco/rest/model``` ignoring the ones that are specified in [ignore-models](src/main/java/org/alfresco/rest/model/ignore-models) file.
|
||||
|
||||

|
||||
|
||||
At this time you you will be prompted to select (based on displayed ID) what models you want to generate (separate each one by comma).
|
||||
(you can also skip the generation of models from select yaml file or generate all missing models)
|
||||
|
||||
|
||||
c) Generate specific models
|
||||
Maybe you want to generate/regenerate just one model or multiple ones.
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels=Error,SiteModel
|
||||
```
|
||||
|
||||
This command will parse the Swagger YAML file, and will generate the definition of only those specified models, even if those models exist locally (in this case you will be prompted to override that file or not)
|
||||
|
||||
_NOTE_: there are some fields that are marked as ```required``` in swagger file. We also generate those fields with annotation ```@JsonProperty(required = true)```
|
||||
|
||||
All models are generated based on a [freemarker](http://freemarker.org) template found [here](src/main/resources/rest-model.ftl).
|
||||
|
||||
### How to run tests
|
||||
|
||||
#### from IDE
|
||||
|
||||
* The project can be imported into a development environment tool (Eclipse or IntelliJ). You have the possibility to execute tests or suite of tests using [TestNG plugin](http://testng.org/doc/eclipse.html) previously installed in IDE.
|
||||
|
||||
* In case you are using the default settings that points to localhost (127.0.0.1) and you don't have Alfresco installed on your machine, you will see one exception thrown (as expected):
|
||||
```java
|
||||
org.alfresco.utility.exception.ServerUnreachableException: Server {127.0.0.1} is unreachable.
|
||||
```
|
||||
|
||||
#### from command line
|
||||
|
||||
* In terminal or CMD, navigate (with CD) to root folder of your project (you can use the sample project):
|
||||
|
||||
|
||||
|
||||
The tests can be executed on command line/terminal using Maven command
|
||||
|
||||
```bash
|
||||
mvn test
|
||||
```
|
||||
|
||||
This command with trigger the tests specified in the default testng suite from POM file: <suiteXmlFile>src/main/resources/shared-resources/restapi-acs-community-suite.xml</suiteXmlFile>
|
||||
|
||||
You can use -Dtest parameter to run the test/suites through command line (http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html).
|
||||
|
||||
You can also specify a different suiteXMLFile like:
|
||||
|
||||
```bash
|
||||
mvn test -DsuiteXmlFile=src/resources/your-custom-suite.xml
|
||||
```
|
||||
|
||||
Or even a single test:
|
||||
|
||||
```bash
|
||||
mvn test -Dtest=org.alfresco.rest.RestDemoTest
|
||||
```
|
||||
But pay attention that you will not have enabled all the [listeners](#listeners) in this case (the Reporting listener or TestRail integration one)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Listeners
|
||||
|
||||
With the help of Listeners we can modify the behavior of TestNG framework. There are a lot of testNG listener interfaces that we can override in order to provide new functionalities.
|
||||
The TAS framework provides out of the box a couple of listeners that you could use. These could be enabled and added at the class level or suite level.
|
||||
|
||||
### a) org.alfresco.utility.report.ReportListenerAdapter
|
||||
|
||||
* if added at the class level:
|
||||
|
||||
```java
|
||||
@Listeners(value=ReportListenerAdapter.class)
|
||||
public class MyTestClass extends RestTest
|
||||
{
|
||||
(...)
|
||||
}
|
||||
```
|
||||
|
||||
* or suite xml level
|
||||
|
||||
```java
|
||||
<suite name="Your Suite test" parallel="classes">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
|
||||
</listeners>
|
||||
(...)
|
||||
</suite>
|
||||
```
|
||||
It will automatically generate one html named "report.html" in ./target/report folder.
|
||||
Please also take a look at [Test Results](#test-results) section.
|
||||
|
||||
### b) org.alfresco.utility.testrail.TestRailExecutorListener
|
||||
It will automatically update Test Rail application with the test cases that you've automated.
|
||||
Please take a look at [Test Rail Integration](#test-rail-integration) section for more details.
|
||||
|
||||
### c) org.alfresco.utility.report.log.LogsListener
|
||||
This is a new listener that will generate further details in one XML format of the automated test steps that you will write.
|
||||
|
||||
Example:
|
||||
|
||||
```java
|
||||
public void myDSLMethod1()
|
||||
{
|
||||
STEP("Lorem ipsum dolor sit amet");
|
||||
//code for first step
|
||||
|
||||
STEP("consectetur adipiscing elit");
|
||||
//code for the next description
|
||||
}
|
||||
|
||||
public void myDSLMethod2()
|
||||
{
|
||||
STEP("sed do eiusmod tempor incididunt ut labore");
|
||||
//code for first step
|
||||
|
||||
STEP("et dolore magna aliqua");
|
||||
//code for the next description
|
||||
}
|
||||
```
|
||||
|
||||
If these methods will be executed insite a test method, all those steps will be automatically logged in the XML report generated.
|
||||
Example:
|
||||
|
||||
```java
|
||||
@Test
|
||||
public void adminShouldCreateFileInSite()
|
||||
{
|
||||
myDSLMethod1();
|
||||
myDSLMethod2()
|
||||
}
|
||||
```
|
||||
|
||||
So if "testingSomething" will be executed this is what you will see on the XML file generated. (please take a look at [Test Results](#test-results) section for defining the defaul location)
|
||||
|
||||
Here is one example of XML file generated with these steps:
|
||||
|
||||

|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Results
|
||||
We already executed a couple of tests using command line as indicated above. Sweet! Please take a look at [rest-suites.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) one more time.
|
||||
You will see there that we have one listener added:
|
||||
|
||||
```java
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
```
|
||||
This will tell our framework, after we run all tests, to generate one HTML report file with graphs and metrics.
|
||||
|
||||
Take a look at the target/reports folder (created after running the tests) and open the report.html file.
|
||||
|
||||

|
||||
|
||||
Playing with this report, you will notice that you will be able to:
|
||||
* search tests cases by name
|
||||
* filter test cases by errors, labels, groups, test types, date when it was executed, protocol used, etc.
|
||||
* view overall pass/fail metrics of current test suite, history of tests execution, etc.
|
||||
|
||||
The report path can be configured in default.properties):
|
||||
|
||||
```
|
||||
# The location of the reports path
|
||||
reports.path=your-new-location-of-reports
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Rail Integration
|
||||
|
||||
Alfresco is using now https://alfresco.testrail.net (v5.3.0.3601).
|
||||
|
||||
We aim to accelerate the delivery of automated test by minimizing the interaction with the test management tool - TestRail. In this scope we developed the following capabilities:
|
||||
* creating automatically the manual tests in TestRail
|
||||
* submitting the test results (with stack trace) after each execution into TestRail Test Runs
|
||||
* adding the test steps for each test.
|
||||
|
||||
### Configuration
|
||||
In order to use Test Rail Integration you will need to add a couple of information in [default.properties](src/test/resources/default.properties) file:
|
||||
(the document is pretty self explanatory)
|
||||
|
||||
```java
|
||||
# Example of configuration:
|
||||
# ------------------------------------------------------
|
||||
# testManagement.enabled=<true/false>
|
||||
# testManagement.endPoint=https://alfresco.testrail.com/
|
||||
# testManagement.username=<yourusername-that-you-connect-to-testrail>
|
||||
# testManagement.apiKey=<api-key>
|
||||
# testManagement.project=<id-of-your-project
|
||||
# testManagement.includeOnlyTestCasesExecuted=<true/false>
|
||||
# testManagement.rateLimitInSeconds= 1
|
||||
# testManagement.testRun=<test-run-name>
|
||||
# testManagement.suiteId=<suite-id>
|
||||
```
|
||||
!This settings are already defined in default.properties for you.
|
||||
|
||||
|
||||
For generating a new API Key take a look at the official documentation, TestRail [APIv2](http://docs.gurock.com/testrail-api2)
|
||||
* _testManagement.project= **<id-of-your-project**_ this is the ID of the project where you want to store your test cases.
|
||||
If you want to use [Alfresco ONE](https://alfresco.testrail.net/index.php?/projects/overview/1) project in TestRail, open that project and notice the URL, after "/overview/**1**" link you will see the ID of the project (1 in this case)
|
||||
If you want to use [TAS Project](https://alfresco.testrail.net/index.php?/projects/overview/7) you will notice the ID 7, so _"testManagement.project=7"_
|
||||
* "_testManagement.testRun=<test-run-name>_" this represents the name of the Test Run from your project.
|
||||
* In Test Rail, navigating to Test Runs & Results, create a new Test Run and include all/particular test cases. If this test run name is "Automation", update _testManagement.testRun= **Automation**_.
|
||||
All test results will be updated only on this test run at runtime as each test is executed by TAS framework.
|
||||
|
||||
### How to enable Test Rail Integration?
|
||||
|
||||
We wanted to simplify the Test Rail integration, so we used listeners in order to enable/disable the integration of Test Rail.
|
||||
* first configure your default.properties as indicated above
|
||||
|
||||
* now on your TestNG test, add the @TestRail annotation, so let's say you will have this test:
|
||||
|
||||
```java
|
||||
@Test(groups="sample-tests")
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
add now @TestRail integration with mandatory field ```section```. This means that this tests annotated, will be uploaded in TestRail:
|
||||
|
||||
```java
|
||||
@Test(groups= TestGroup.REST_API, TestGroup.FULL,)
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES })
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
The section field, represents an array of strings, the hierarchy of sections that SHOULD be found on TestRail under the project you've selected in default.properties. Follow the TestRail [user-guide](http://docs.gurock.com/testrail-userguide/start) for more information regarding sections.
|
||||
In our example we created in Test Rail one root section "restAPI" with a child section: "processes" (you can go further and add multiple section as you wish)
|
||||
|
||||
* now, lets add the listener, the TestRailExecutorListener that will handle this TC Management interaction.
|
||||
This listener can be added at the class level or suite level (approach that we embrace)
|
||||
Take a look at [restapi-acs-community-suite.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) for further example.
|
||||
|
||||
```xml
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
(...)
|
||||
</listeners>
|
||||
```
|
||||
|
||||
Right click on sanity-suite.xml file and run it, or just "mvn test" from root if this sample project.
|
||||
After everything passes, go in Test Rail, open your project and navigate to "Test Cases" section. Notice that under restApi/processes section, you will see your test case published.
|
||||
|
||||
If you defined also the "testManagement.testRun" correctly, you will see under Test Runs, the status of this case marked as passed.
|
||||
|
||||
The @TestRail annotation offers also other options like:
|
||||
- "description" this is the description that will be updated in Test Rail for your test case
|
||||
- "testType", the default value is set to Functional test
|
||||
- "executionType", default value is set to ExecutionType.REGRESSION, but you can also use ExecutionType.SMOKE, ExecutionType.SANITY, etc
|
||||
|
||||
Take a look at the demo scenarios in this project for further examples.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Reference
|
||||
|
||||
* For any improvements, bugs, please use Jira - [TAS](https://issues.alfresco.com/jira/browse/TAS) project.
|
||||
* Setup the environment using [docker](https://gitlab.alfresco.com/tas/alfresco-docker-provisioning/blob/master/Readme.md).
|
||||
* [Bamboo Test Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI)
|
||||
|
||||
## Contributors
|
||||
|
||||
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other... [more](CODE_OF_CONDUCT.md)
|
||||
|
||||
## Releasing
|
||||
|
||||
Any commit done on this project should be automatically executed by [TAS Build Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-TAS)
|
||||
If the build passes, then you didn't broke anything.
|
||||
|
||||
If you want to perform a release, open [TAS-RestAPI](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI) Bamboo Build.
|
||||
Run the Default stage and if it passes, then manually perform the Release stage (this will auto-increment the version in pom.xml)
|
Binary file not shown.
Before Width: | Height: | Size: 142 KiB |
Binary file not shown.
Before Width: | Height: | Size: 116 KiB |
Binary file not shown.
Before Width: | Height: | Size: 64 KiB |
@@ -2,26 +2,27 @@
|
||||
<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>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<name>alfresco-tas-restapi</name>
|
||||
<artifactId>alfresco-community-repo-restapi-test</artifactId>
|
||||
<name>restapi test</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.155</version>
|
||||
<version>19.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Paul Brodner</name>
|
||||
<roles>
|
||||
<role>Test Automation Architect</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<suiteXmlFile>${project.basedir}/src/test/resources/restapi-suite.xml</suiteXmlFile>
|
||||
<maven.build.sourceVersion>11</maven.build.sourceVersion>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<rest.api.explorer.branch>master</rest.api.explorer.branch>
|
||||
<httpclient-osgi-version>4.5.6</httpclient-osgi-version>
|
||||
<org.glassfish.version>1.1.4</org.glassfish.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<scribejava-apis.version>8.3.1</scribejava-apis.version>
|
||||
<license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
@@ -46,146 +47,26 @@
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<!-- fix the info log messages related to Could not instantiate TestExecutionListener
|
||||
[org.springframework.test.context.web.ServletTestExecutionListener -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- alfresco tester settings -->
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>restapi</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- REST ASSURED -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient-osgi</artifactId>
|
||||
<version>${httpclient-osgi-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>xml-path</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.scribejava</groupId>
|
||||
<artifactId>scribejava-apis</artifactId>
|
||||
<version>${scribejava-apis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON to Object -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish/javax.json -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>${org.glassfish.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger parser -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--fixing java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap') -->
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
<version>3.0.16</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-json-->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-json</artifactId>
|
||||
<version>3.0.16</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.json</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -215,32 +96,6 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*UnitTest*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-auth.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-core.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-discovery.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-search.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-workflow.yaml</argument>
|
||||
</arguments>
|
||||
<mainClass>org.alfresco.rest.core.swagger.Generator</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@@ -1,70 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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;
|
||||
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
public abstract class NetworkDataPrep extends RestTest
|
||||
{
|
||||
protected static UserModel adminUserModel;
|
||||
protected static UserModel adminTenantUser, secondAdminTenantUser;
|
||||
protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser;
|
||||
protected static UserModel tenantUserWithBad;
|
||||
protected static UserModel userModel;
|
||||
protected static RestNetworkModel restNetworkModel;
|
||||
protected static String tenantDomain;
|
||||
private static boolean isInitialized = false;
|
||||
|
||||
public void init()
|
||||
{
|
||||
if(!isInitialized)
|
||||
{
|
||||
isInitialized = true;
|
||||
initialization();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialization()
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
//create first tenant Admin User.
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant");
|
||||
//create second tenant Admin User.
|
||||
secondAdminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.usingTenant().createTenant(secondAdminTenantUser);
|
||||
|
||||
tenantDomain = tenantUser.getDomain();
|
||||
differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant");
|
||||
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
}
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelAssertion;
|
||||
|
||||
public interface IRestModel<Model> extends IModelAssertion<Model> {
|
||||
Model onModel();
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
|
||||
public interface IRestModelsCollection<Model> {
|
||||
|
||||
public List<Model> getEntries();
|
||||
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException;
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
public RestPaginationModel getPagination();
|
||||
|
||||
}
|
@@ -1,370 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonBuilderFactory;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.Priority;
|
||||
import org.alfresco.rest.model.RestProcessVariableModel;
|
||||
import org.alfresco.rest.model.RestVariableModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* Json builder for small post calls
|
||||
*/
|
||||
public class JsonBodyGenerator
|
||||
{
|
||||
private static JsonBuilderFactory jsonBuilder;
|
||||
|
||||
/**
|
||||
* @return {@link JsonObjectBuilder}
|
||||
*/
|
||||
public static JsonObjectBuilder defineJSON()
|
||||
{
|
||||
return jsonBuilder().createObjectBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link JsonArrayBuilder}
|
||||
*/
|
||||
public static JsonArrayBuilder defineJSONArray()
|
||||
{
|
||||
return jsonBuilder().createArrayBuilder();
|
||||
}
|
||||
/**
|
||||
* {
|
||||
* "tag":"test-tag-1"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(String key, String value)
|
||||
{
|
||||
return defineJSON().add(key, value).build().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "site": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetSiteWithGuid(SiteModel siteModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("site", defineJSON()
|
||||
.add("guid", siteModel.getGuid()))).build();
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "file": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFileWithGuid(FileModel fileModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("file", defineJSON()
|
||||
.add("guid", fileModel.getNodeRef().replace(";1.0", "")))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "folder": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFolderWithGuid(FolderModel folderModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("folder", defineJSON()
|
||||
.add("guid", folderModel.getNodeRef()))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initialized JSON builder
|
||||
*/
|
||||
private static JsonBuilderFactory jsonBuilder()
|
||||
{
|
||||
if (jsonBuilder == null)
|
||||
return Json.createBuilderFactory(null);
|
||||
else
|
||||
{
|
||||
return jsonBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
public static String likeRating(boolean likeOrNot)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "likes")
|
||||
.add("myRating", likeOrNot).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String fiveStarRating(int stars)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "fiveStar")
|
||||
.add("myRating", stars).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String siteMember(UserModel userModel)
|
||||
{
|
||||
Utility.checkObjectIsInitialized(userModel.getUserRole(), "userModel.getUserRole()");
|
||||
JsonObject value = defineJSON()
|
||||
.add("role", userModel.getUserRole().name())
|
||||
.add("id", userModel.getUsername()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String siteGroup(String authorityId, UserRole role)
|
||||
{
|
||||
Utility.checkObjectIsInitialized(authorityId, "authorityId");
|
||||
JsonObject value = defineJSON()
|
||||
.add("role", role.name())
|
||||
.add("id", authorityId).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String siteMemberhipRequest(String message, SiteModel siteModel, String title)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("message", message)
|
||||
.add("id", siteModel.getId())
|
||||
.add("title", title).build();
|
||||
return value.toString();
|
||||
}
|
||||
/**
|
||||
* Method to create a Json object for SiteBody with site title, description, visibility
|
||||
* @param siteModel
|
||||
* @return String
|
||||
*/
|
||||
public static String updateSiteRequest(SiteModel siteModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("title", siteModel.getTitle())
|
||||
.add("description", siteModel.getDescription())
|
||||
.add("visibility", siteModel.getVisibility().toString()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String process(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("processDefinitionKey", processDefinitionKey)
|
||||
.add("variables", jsonBuilder().createObjectBuilder()
|
||||
.add("bpm_assignee", assignee.getUsername())
|
||||
.add("bpm_sendEMailNotifications", sendEmailNotifications)
|
||||
.add("bpm_workflowPriority", priority.getLevel())).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String processVariable(RestProcessVariableModel variableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("name", variableModel.getName())
|
||||
.add("value", variableModel.getValue())
|
||||
.add("type", variableModel.getType()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String taskVariable(RestVariableModel taskVariableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("scope", taskVariableModel.getScope())
|
||||
.add("name", taskVariableModel.getName())
|
||||
.add("type", taskVariableModel.getType())
|
||||
.add("value", taskVariableModel.getValue().toString()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "copy",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* "params": {
|
||||
"destination-folder": "34219f79-66fa-4ebf-b371-118598af898c"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode, Map<String, Serializable> params)
|
||||
{
|
||||
JsonObjectBuilder objectBuilder = jsonBuilder().createObjectBuilder();
|
||||
for(Map.Entry<String, Serializable> param : params.entrySet())
|
||||
{
|
||||
addJsonValue(objectBuilder, param.getKey(), param.getValue());
|
||||
|
||||
}
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.add("params", objectBuilder).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/** Add a value to the JSON object. */
|
||||
private static void addJsonValue(JsonObjectBuilder objectBuilder, String key, Serializable value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
objectBuilder.add(key, JsonObject.NULL);
|
||||
}
|
||||
else if (value instanceof Boolean)
|
||||
{
|
||||
objectBuilder.add(key, (boolean) value);
|
||||
}
|
||||
else if (value instanceof String)
|
||||
{
|
||||
objectBuilder.add(key, (String) value);
|
||||
}
|
||||
else if (value instanceof Integer)
|
||||
{
|
||||
objectBuilder.add(key, (int) value);
|
||||
}
|
||||
else if (value instanceof Long)
|
||||
{
|
||||
objectBuilder.add(key, (long) value);
|
||||
}
|
||||
else if (value instanceof Double)
|
||||
{
|
||||
objectBuilder.add(key, (double) value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Unable to add entry to JsonObject: {" + key + ": " + value + "}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "check-out",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "key1":"key1",
|
||||
* "key2":"key2",
|
||||
* "key3":"key3"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(HashMap<String, String> mapJson)
|
||||
{
|
||||
JsonObjectBuilder builder= defineJSON();
|
||||
|
||||
for (Map.Entry<String, String> entry : mapJson.entrySet())
|
||||
{
|
||||
builder.add(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return builder.build().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a collection of {@link TestModel} objects to JSON for a multi-entity POST request.
|
||||
*
|
||||
* @param models The entities to convert.
|
||||
* @return The JSON string.
|
||||
*/
|
||||
public static String arrayToJson(List<? extends TestModel> models)
|
||||
{
|
||||
// Rather than convert backwards and forwards between Jackson and javax objects then we handle array creation ourselves.
|
||||
StringJoiner stringJoiner = new StringJoiner(",\n");
|
||||
for (TestModel model : models)
|
||||
{
|
||||
stringJoiner.add(model.toJson());
|
||||
}
|
||||
return "[\n" + stringJoiner.toString() + "\n]";
|
||||
}
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.utility.data.AisToken;
|
||||
import org.alfresco.utility.data.auth.DataAIS;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RestAisAuthentication
|
||||
{
|
||||
public static String STEP_PREFIX = "RestAisAuthProvider:";
|
||||
public static String USER_DISABLED_MSG = "Account disabled";
|
||||
|
||||
@Autowired
|
||||
private DataAIS dataAIS;
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the AIS access token for the specified user model.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
public String getAisAuthenticationToken(UserModel userModel)
|
||||
{
|
||||
STEP(String.format("%s Retrieving AIS authentication.", STEP_PREFIX));
|
||||
AisToken aisToken = getAisAccessToken(userModel);
|
||||
|
||||
return aisToken.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Alfresco Identity Service is enabled
|
||||
* @return True if Alfresco Identity Service is enabled (the identity service URL is not null or empty)
|
||||
*/
|
||||
public Boolean isAisAuthenticationEnabled()
|
||||
{
|
||||
return dataAIS.isEnabled() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid access token for valid user credentials in userModel. An
|
||||
* invalid access token is returned for invalid user credentials, which can
|
||||
* be used for tests involving non existing or unauthorized users.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
private AisToken getAisAccessToken(UserModel userModel)
|
||||
{
|
||||
String badToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJUazFPZ2JqVlo1UEw2bmtsNWFvTUlacTZ4cW9PZzc5WGtzdnJTTUcxLUFZIn0.eyJqdGkiOiI3NTVkMGZiOS03NzI5LTQ1NzYtYWM4Ny1hZWZjZWNiZDE0ZGEiLCJleHAiOjE1NTM2MjQ1NDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFsZnJlc2NvIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiNjJlN2U5YzktZmFlNS00N2RhLTk5MDItMTZjYTJhZWUwMWMwIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwOi8vbG9jYWxob3N0KiIsImh0dHBzOi8vbG9jYWxob3N0KiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoidXNlci12eGlrcXd3cG5jYmpzeHgifQ.PeLGCNCzj-P2m0knwUU9Vfx4dzLLQER9IdV7GyLel9LRN-3J9nh7GBDRQsyDJ0pqhObQyMg4V3wSsrsXRQ6gKhmUyDemmD-w1YMC2a2HKX6GlxsTEF_f1K_R15lIQOawNVErlWjZWORJGCvCYZOJ99SOmeOC6PGY79zLL94MMnf6dXcegePPMOKG-59eNjBkOylTipYebvM40nbbKrS5vzNHQlvUh4ALFeBoMSKGnLSjQd06Dj4SWojG0p1BrxurqDjW0zz6pQlEAm4vcWApRZ6qBLZcMH8adYix07zCDb87GOn1pmfEBWpwd3BEgC_LLu06guaCPHC9tpeIaDTHLg";
|
||||
String badRefreshToken = "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJmM2YyMjhjYS1jMzg5LTQ5MGUtOGU1Zi02YWI1MmJhZDVjZGEifQ.eyJqdGkiOiIyNmExZWNhYy00Zjk0LTQwYzctYjJjNS04NTlhZmQ3NjBiYWMiLCJleHAiOjE1NTM2MjYwNDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdC9hdXRoL3JlYWxtcy9hbGZyZXNjbyIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IlJlZnJlc2giLCJhenAiOiJhbGZyZXNjbyIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjYyZTdlOWM5LWZhZTUtNDdkYS05OTAyLTE2Y2EyYWVlMDFjMCIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJwcm9maWxlIGVtYWlsIn0.lRBJQc7tj0rk7JBC0zpM0dDdZgDKjm9wcxP8nzLnXe4";
|
||||
|
||||
AisToken aisToken;
|
||||
try
|
||||
{
|
||||
// Attempt to get an access token for userModel from AIS
|
||||
aisToken = dataAIS.perform().getAccessToken(userModel);
|
||||
}
|
||||
catch (AssertionError e)
|
||||
{
|
||||
// Trying to authenticate with invalid user credentials or disabled
|
||||
// user so return an invalid access token
|
||||
if (e.getMessage().contains("invalid_grant"))
|
||||
{
|
||||
STEP(String.format("%s User disabled or invalid user credentials were provided %s:%s. Using invalid token for request.", STEP_PREFIX,
|
||||
userModel.getUsername(), userModel.getPassword()));
|
||||
aisToken = new AisToken(badToken, badRefreshToken, System.currentTimeMillis(), 300000);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return aisToken;
|
||||
}
|
||||
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelsCollectionAssertion;
|
||||
import org.alfresco.rest.core.assertion.ModelsCollectionAssertion;
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
|
||||
/**
|
||||
* Map multiple entries of JSON response to a class <T>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* "entries": [
|
||||
{
|
||||
"entry": {
|
||||
"visibility": "PUBLIC",
|
||||
"guid": "79e140e1-5039-4efa-acaf-c22b5ba7c947",
|
||||
"description": "Description1470255221170",
|
||||
"id": "0-C2291-1470255221170",
|
||||
"title": "0-C2291-1470255221170"
|
||||
}
|
||||
},
|
||||
*
|
||||
* Having this JSON Entry, we can auto-map this to {@link RestSiteModelsCollection} class having a List of <SiteModel> based on this example
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public abstract class RestModels<Model, ModelCollection> implements IRestModelsCollection<Model>, IModelsCollectionAssertion<ModelCollection>
|
||||
{
|
||||
@JsonProperty(value = "entries")
|
||||
private List<Model> modelEntries;
|
||||
|
||||
private RestPaginationModel pagination;
|
||||
|
||||
@Override
|
||||
public List<Model> getEntries()
|
||||
{
|
||||
return modelEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a random entry from entries list
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@Override
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException
|
||||
{
|
||||
STEP("REST API: Get random one entry from response");
|
||||
Random random = new Random();
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
int index = random.nextInt(models.size());
|
||||
return models.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Example
|
||||
* <code>
|
||||
* siteMembershipRequests.getEntryByIndex(0)
|
||||
.assertThat().field("site.visibility").is(moderatedSite.getVisibility())
|
||||
.assertThat().field("site.description").is(moderatedSite.getDescription())
|
||||
.assertThat().field("site.id").is(moderatedSite.getId())
|
||||
.assertThat().field("site.title").is(moderatedSite.getTitle());
|
||||
* </code>
|
||||
* @param index
|
||||
* @return
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Model getEntryByIndex(int index) throws EmptyRestModelCollectionException{
|
||||
STEP("REST API: Get index entry from response");
|
||||
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
if(models.size() > index){
|
||||
return (Model) ((IRestModel<?>)models.get(index)).onModel();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> assertThat()
|
||||
{
|
||||
return new ModelsCollectionAssertion<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ModelCollection when()
|
||||
{
|
||||
return (ModelCollection)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if (getEntries() != null)
|
||||
return getEntries().isEmpty();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestPaginationModel getPagination()
|
||||
{
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(RestPaginationModel pagination)
|
||||
{
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:default.properties")
|
||||
@PropertySource(value = "classpath:${environment}.properties", ignoreResourceNotFound = true)
|
||||
public class RestProperties
|
||||
{
|
||||
@Autowired
|
||||
private TasProperties properties;
|
||||
|
||||
public TasProperties envProperty()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
@@ -1,216 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.MissingFormatArgumentException;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class RestRequest
|
||||
{
|
||||
private static final String TOKEN_REGEX = "\\{.*?}";
|
||||
private String body;
|
||||
private HttpMethod httpMethod;
|
||||
private String path;
|
||||
private Object[] pathParams;
|
||||
private String contentType = "UTF-8";
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
this(httpMethod, "", path, pathParams);
|
||||
}
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
setHttpMethod(httpMethod);
|
||||
setPath(path);
|
||||
setPathParams(pathParams);
|
||||
setBody(body);
|
||||
// Validate that the supplied path and pathParams are compatible.
|
||||
constructPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when no body is needed
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest simpleRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, path, pathParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when a body has to be provided
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param body
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest requestWithBody(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, body, path, pathParams);
|
||||
}
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body)
|
||||
{
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public HttpMethod getHttpMethod()
|
||||
{
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setHttpMethod(HttpMethod httpMethod)
|
||||
{
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
addQueryParamsIfNeeded();
|
||||
}
|
||||
|
||||
public Object[] getPathParams()
|
||||
{
|
||||
return pathParams;
|
||||
}
|
||||
|
||||
public void setPathParams(Object[] pathParams)
|
||||
{
|
||||
this.pathParams = pathParams;
|
||||
addQueryParamsIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add query parameters to the path if needed.
|
||||
* <p>
|
||||
* e.g. For a path of "api/{fruit}" and params ["apple", "size=10", "colour=red"] then this will
|
||||
* update the path to be "api/{fruit}?{param0}&{param1}" so that the tokens will be populated by
|
||||
* RestAssured to make "api/apple?size=10&colour=red".
|
||||
*/
|
||||
private void addQueryParamsIfNeeded()
|
||||
{
|
||||
// Don't do anything if the path or path params haven't been set yet.
|
||||
if (path == null || path.length() == 0 || pathParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int groupCount = (int) Pattern.compile(TOKEN_REGEX).matcher(path).results().count();
|
||||
if (pathParams.length > groupCount)
|
||||
{
|
||||
// Add the remaining parameters to the URL query.
|
||||
String queryParams = IntStream.range(0, pathParams.length - groupCount)
|
||||
.mapToObj(index -> "{parameter" + index + "}")
|
||||
.collect(Collectors.joining("&"));
|
||||
path += (path.contains("?") ? "&" : "?") + queryParams;
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentType()
|
||||
{
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws MissingFormatArgumentException If there are not enough pathParams for the path.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append("Request: ")
|
||||
.append(getHttpMethod())
|
||||
.append(" ")
|
||||
.append(RestAssured.baseURI)
|
||||
.append(":")
|
||||
.append(RestAssured.port)
|
||||
.append("/")
|
||||
.append(RestAssured.basePath)
|
||||
.append("/");
|
||||
|
||||
sb.append(constructPath());
|
||||
|
||||
if(!getBody().isEmpty())
|
||||
{
|
||||
sb.append("\nbody:")
|
||||
.append(getBody());
|
||||
}
|
||||
sb.append("\n");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the path with the pathParams.
|
||||
*
|
||||
* @return The path with tokens replaced with values.
|
||||
* @throws MissingFormatArgumentException If there are not enough pathParams for the path.
|
||||
*/
|
||||
private String constructPath()
|
||||
{
|
||||
String getPathFormatted = getPath();
|
||||
if(getPath().contains("{"))
|
||||
{
|
||||
getPathFormatted = getPath().replaceAll(TOKEN_REGEX, "%s");
|
||||
getPathFormatted = String.format(getPathFormatted, getPathParams());
|
||||
}
|
||||
return getPathFormatted;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
public interface IModelAssertion<Model>
|
||||
{
|
||||
default ModelAssertion<Model> assertThat()
|
||||
{
|
||||
return new ModelAssertion<>(this);
|
||||
}
|
||||
|
||||
default ModelAssertion<Model> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public interface IModelsCollectionAssertion<ModelCollection> {
|
||||
public ModelsCollectionAssertion and();
|
||||
|
||||
public ModelsCollectionAssertion assertThat();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default ModelCollection when()
|
||||
{
|
||||
return (ModelCollection) this;
|
||||
}
|
||||
}
|
@@ -1,451 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import io.restassured.path.json.JsonPath;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model
|
||||
* Just pass your rest model as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
|
||||
public class ModelAssertion<T>
|
||||
{
|
||||
protected static void checkFieldIsPresent(Object fieldNameToBeRetuned, Object fieldValueToBeRetuned)
|
||||
{
|
||||
if (fieldValueToBeRetuned == null)
|
||||
{
|
||||
Assert.fail(String.format("Field {%s} was not found in returned response.",fieldNameToBeRetuned));
|
||||
}
|
||||
}
|
||||
private final Object model;
|
||||
|
||||
public ModelAssertion(Object model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this DSL for asserting particular fields of your model if your model
|
||||
* is like this (basic POJO)
|
||||
* public class Person extends ModelAssertion<Person>
|
||||
* { private String id = "1234"; }
|
||||
* you can use assert the id of this person as:
|
||||
* Person p = new Person(); p.assertThat().field("id").is("1234")
|
||||
*
|
||||
* @param fieldName
|
||||
* @return
|
||||
* @throws IllegalStateException If the field cannot be converted to JSON.
|
||||
*/
|
||||
public AssertionVerbs field(String fieldName)
|
||||
{
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String jsonInString = null;
|
||||
try
|
||||
{
|
||||
jsonInString = mapper.writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
Object fieldValue = JsonPath.with(jsonInString).get(fieldName);
|
||||
|
||||
return new AssertionVerbs(model, fieldValue, fieldName);
|
||||
}
|
||||
|
||||
public AssertionItemVerbs fieldsCount()
|
||||
{
|
||||
|
||||
int actualSize = 0;
|
||||
List<Field> allFields = getAllDeclaredFields(new LinkedList<Field>(), model.getClass());
|
||||
|
||||
for (Field field : allFields)
|
||||
{
|
||||
|
||||
field.setAccessible(true);
|
||||
Object fieldValue = null;
|
||||
try
|
||||
{
|
||||
fieldValue = field.get(model);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new IllegalStateException("Unable to load model using reflection.", e);
|
||||
}
|
||||
if (fieldValue != null)
|
||||
actualSize++;
|
||||
}
|
||||
return new AssertionItemVerbs(model, actualSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method for asserting whole model with different model object. Method allows to ignore particular fields during the comparison.
|
||||
*
|
||||
* WARNING: For proper work model should implement {@code toString()} and {@code equals()} methods.
|
||||
*
|
||||
* @param expected - expected model.
|
||||
* @param ignoreFields - fields which should be ignored during assertion.
|
||||
* @return model.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T isEqualTo(T expected, String... ignoreFields)
|
||||
{
|
||||
T modelCopy = createCopyIgnoringFields((T) model, ignoreFields);
|
||||
T expectedCopy = createCopyIgnoringFields(expected, ignoreFields);
|
||||
Assert.assertEquals(modelCopy, expectedCopy, String.format("Compared objects of type: %s are not equal!", model.getClass()));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all fields declared from all classes hierarchy
|
||||
*
|
||||
* @param fields
|
||||
* @param classz
|
||||
* @return
|
||||
*/
|
||||
private List<Field> getAllDeclaredFields(List<Field> fields, Class<?> classz)
|
||||
{
|
||||
if (classz.isAssignableFrom(TestModel.class))
|
||||
{
|
||||
return fields;
|
||||
}
|
||||
|
||||
fields.addAll(Arrays.asList(classz.getDeclaredFields()));
|
||||
|
||||
if (classz.getSuperclass() != null)
|
||||
{
|
||||
fields = getAllDeclaredFields(fields, classz.getSuperclass());
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T createCopyIgnoringFields(T model, String... ignoreFields)
|
||||
{
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapterFactory(new SerializableTypeAdapterFactory());
|
||||
Gson gson = gsonBuilder.create();
|
||||
JsonObject jsonObject = gson.fromJson(gson.toJson(model), JsonObject.class);
|
||||
for (String ignoreField : ignoreFields)
|
||||
{
|
||||
jsonObject.remove(ignoreField);
|
||||
}
|
||||
return gson.fromJson(gson.toJson(jsonObject), (Class<? extends T>) model.getClass());
|
||||
}
|
||||
|
||||
/** Workaround from https://github.com/google/gson/issues/544 */
|
||||
private class SerializableTypeAdapterFactory implements TypeAdapterFactory
|
||||
{
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
|
||||
{
|
||||
if (Serializable.class.equals(type.getRawType()))
|
||||
{
|
||||
return (TypeAdapter<T>) gson.getAdapter(Object.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL assertion on Rest Model fields
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionVerbs
|
||||
{
|
||||
private String fieldName;
|
||||
private Object model;
|
||||
private Object fieldValue;
|
||||
|
||||
public AssertionVerbs(Object model, Object fieldValue, String fieldName)
|
||||
{
|
||||
this.model = model;
|
||||
this.fieldValue = fieldValue;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
private String errorMessage(String info)
|
||||
{
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName, model.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public T isNot(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotEquals(fieldValue, expected, errorMessage("is correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
throw new UnsupportedOperationException("You probably want to use is() rather than equals()");
|
||||
}
|
||||
|
||||
public T is(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertEquals(fieldValue.toString(), expected.toString(), errorMessage("is NOT correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is a non-empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isNotEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyList(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyMap(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Integer)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Long)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Boolean)
|
||||
{
|
||||
Assert.assertNotEquals(String.valueOf(fieldValue), "", errorMessage("is empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNotNull()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotNull(fieldValue, errorMessage("is null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNull()
|
||||
{
|
||||
Assert.assertNull(fieldValue, errorMessage("is not null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is an empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is not empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertEquals((Collection<?>) fieldValue, Collections.emptyList(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, "", errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, Collections.emptyMap(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T contains(String value)
|
||||
{
|
||||
if (!fieldValue.toString().contains(value))
|
||||
{
|
||||
Assert.fail(errorMessage("does NOT contain expected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T containsOnce(String value)
|
||||
{
|
||||
final String fieldContent = fieldValue.toString();
|
||||
final int i = fieldContent.indexOf(value);
|
||||
if (i == -1)
|
||||
{
|
||||
Assert.fail(errorMessage("does NOT contain at all the expected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
if (i != fieldContent.lastIndexOf(value))
|
||||
{
|
||||
Assert.fail(errorMessage("contains more than one expected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T notContains(String value)
|
||||
{
|
||||
if (fieldValue.toString().contains(value))
|
||||
{
|
||||
Assert.fail(errorMessage("does contain unexpected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is greater than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isGreaterThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Greater);
|
||||
}
|
||||
|
||||
private T validateSize(Integer value, Operation operation) throws TestConfigurationException
|
||||
{
|
||||
try
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
throw new TestConfigurationException("Input must be valid");
|
||||
}
|
||||
Integer b = Integer.valueOf(fieldValue.toString());
|
||||
switch (operation)
|
||||
{
|
||||
case Greater:
|
||||
if(value > b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not greater than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
case Less:
|
||||
if(value < b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not less than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Assert.fail(errorMessage("No operation type provided"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Assert.fail(errorMessage("The field is not numeric " + fieldValue.toString()));
|
||||
}
|
||||
catch (NullPointerException ne)
|
||||
{
|
||||
Assert.fail(errorMessage("The input value must be numeric " + value));
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is less than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isLessThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Less);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionItemVerbs
|
||||
{
|
||||
private Object model;
|
||||
private Object actual;
|
||||
|
||||
public AssertionItemVerbs(Object model, Object actual)
|
||||
{
|
||||
this.model = model;
|
||||
this.actual = actual;
|
||||
}
|
||||
|
||||
public T is(Object expected) {
|
||||
Assert.assertEquals(actual, expected, String.format("For model [%s], the expected value is not correct ",
|
||||
model.getClass().getSimpleName(), expected.toString(), actual.toString()));
|
||||
return (T) model;
|
||||
}
|
||||
}
|
||||
public static enum Operation
|
||||
{
|
||||
Less,Greater
|
||||
}
|
||||
}
|
@@ -1,329 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.Model;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model Collection
|
||||
* Just pass your rest model collection as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class ModelsCollectionAssertion<C>
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
private IRestModelsCollection modelCollection;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public ModelsCollectionAssertion(IRestModelsCollection modelCollection)
|
||||
{
|
||||
this.modelCollection = modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is not empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsNotEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is not empty");
|
||||
Assert.assertFalse(modelCollection.isEmpty(), "Entries list from response is empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is empty");
|
||||
Assert.assertTrue(modelCollection.isEmpty(), "Entries list from response is not empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListCountIs(int expectedCount)
|
||||
{
|
||||
STEP(String.format("REST API: Assert that entries list count is %d", expectedCount));
|
||||
int actualSize = modelCollection.getEntries().size();
|
||||
Assert.assertEquals(actualSize, expectedCount);
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key, String value)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
String fieldValue = "";
|
||||
for (Model m : modelEntries) {
|
||||
Object model = loadModel(m);
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
key, getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(fieldValue, value, String.format("Entry with key: [%s] with value [%s] not found in list", key, value));
|
||||
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key, String value)
|
||||
{
|
||||
boolean exist = false;
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries) {
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry with key: %s and value %s was found in list", key, value));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
public C entrySetContains(String key, String... expectedValues)
|
||||
{
|
||||
return entrySetContains(key, Arrays.stream(expectedValues).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entrySetContains(String key, Collection<String> expectedValues)
|
||||
{
|
||||
Collection<String> actualValues = ((List<Model>) modelCollection.getEntries()).stream()
|
||||
.map(model -> extractValueAsString(model, key))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Assert.assertTrue(actualValues.containsAll(expectedValues), String.format("Entry with key: \"%s\" is expected to contain values: %s, but actual values are: %s",
|
||||
key, expectedValues, actualValues));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entrySetMatches(String key, Collection<String> expectedValues)
|
||||
{
|
||||
Collection<String> actualValues = ((List<Model>) modelCollection.getEntries()).stream()
|
||||
.map(model -> extractValueAsString(model, key))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Assert.assertEqualsNoOrder(actualValues, expectedValues, String.format("Entry with key: \"%s\" is expected to match values: %s, but actual values are: %s",
|
||||
key, expectedValues, actualValues));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
private String extractValueAsString(Model model, String key)
|
||||
{
|
||||
String fieldValue;
|
||||
Object modelObject = loadModel(model);
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(modelObject);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
key, getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key)
|
||||
{
|
||||
boolean exist = modelInList(key);
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry list contains key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key)
|
||||
{
|
||||
boolean exist = modelInList(key);
|
||||
Assert.assertTrue(exist,
|
||||
String.format("Entry list doesn't contain key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
private boolean modelInList(String key)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString;
|
||||
try
|
||||
{
|
||||
jsonInString = mapper.writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
throw new IllegalStateException("Failed to convert model to string.", e);
|
||||
}
|
||||
Object fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C paginationExist()
|
||||
{
|
||||
STEP("REST API: Assert that response has pagination");
|
||||
Assert.assertNotNull(modelCollection.getPagination(), "Pagination is was not found in the response");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check one field from pagination json body
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public PaginationAssertionVerbs paginationField(String field)
|
||||
{
|
||||
return new PaginationAssertionVerbs<C>(modelCollection, field, modelCollection.getPagination());
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered ASC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedAscBy(String field)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().isOrdered(fieldValues), String.format("Entries are not ordered ASC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered DESC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedDescBy(String field)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().reverse().isOrdered(fieldValues), String.format("Entries are not ordered DESC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
private Object loadModel(Model m)
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
return method.invoke(m, new Object[] {});
|
||||
}
|
||||
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
throw new IllegalStateException("Failed to load model using reflection.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Pagination related assertions
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class PaginationAssertionVerbs<C> {
|
||||
private RestPaginationModel pagination;
|
||||
private C modelCollection;
|
||||
private String fieldName;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public PaginationAssertionVerbs(IRestModelsCollection modelCollection, String fieldName, RestPaginationModel pagination) {
|
||||
this.modelCollection = (C)modelCollection;
|
||||
this.fieldName = fieldName;
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the field
|
||||
*/
|
||||
private String getFieldValue() {
|
||||
String value = "";
|
||||
try {
|
||||
value = BeanUtils.getProperty(pagination, fieldName);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
fieldName, modelCollection.getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private String errorMessage(String info) {
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName,
|
||||
modelCollection.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public C is(String expected) {
|
||||
|
||||
Assert.assertEquals(getFieldValue(), expected, errorMessage("is NOT correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNot(Object expected) {
|
||||
|
||||
Assert.assertNotEquals(getFieldValue(), expected, errorMessage("is correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotEmpty() {
|
||||
Assert.assertNotEquals(getFieldValue(), "", errorMessage("is empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotNull() {
|
||||
Assert.assertNotNull(getFieldValue(), errorMessage("is null,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotPresent() {
|
||||
Assert.assertNull(getFieldValue(), errorMessage("is present,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isEmpty() {
|
||||
Assert.assertEquals(getFieldValue(), "", errorMessage("is NOT empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
/**
|
||||
* Executed via command line/terminal from root of this project
|
||||
* Just execute <code>mvn exec:java</code> passing as arguments:
|
||||
* -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml)
|
||||
* -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.
|
||||
* -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter
|
||||
* -Dhelp => show help
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class Generator
|
||||
{
|
||||
public static String line = "********\n------------------------------------------------------------------------";
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
if (!System.getProperties().containsKey("coverage") && !System.getProperties().containsKey("models") || System.getProperties().containsKey("help") )
|
||||
{
|
||||
System.out.println(line);
|
||||
System.out.println("No parameters provided, please use the following values:\n");
|
||||
System.out.println(
|
||||
"mvn exec:java -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml).");
|
||||
System.out.println("mvn exec:java -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.");
|
||||
System.out.println("mvn exec:java -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter.");
|
||||
System.out.println(line);
|
||||
|
||||
}
|
||||
|
||||
for (String url : args)
|
||||
{
|
||||
if (System.getProperty("coverage") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dcoverage</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).computeCoverage();
|
||||
}
|
||||
else if (System.getProperty("models") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dmodels</code>
|
||||
* <code>mvn exec:java -Dmodels=a,c,e</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).generateMissingModules();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,150 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
|
||||
/**
|
||||
* Model property used by freemarker template in {@link SwaggerModel}
|
||||
*
|
||||
*/
|
||||
public class RestModelProperty
|
||||
{
|
||||
private String name;
|
||||
private String type;
|
||||
private String description;
|
||||
private Boolean isRequired = false;
|
||||
/** If the property is a ref then this is the type referenced. */
|
||||
private String simpleRef;
|
||||
/** If the property is an array then this is the type of the items in it. */
|
||||
private RestModelProperty itemsType;
|
||||
|
||||
public static RestModelProperty build(Entry<String, io.swagger.models.properties.Property> property)
|
||||
{
|
||||
RestModelProperty model = new RestModelProperty();
|
||||
model.setName(property.getKey());
|
||||
model.setType(property.getValue().getType());
|
||||
model.setDescription(property.getValue().getDescription());
|
||||
model.setIsRequired(property.getValue().getRequired());
|
||||
if (property.getValue() instanceof RefProperty)
|
||||
{
|
||||
RefProperty refProperty = (RefProperty) property.getValue();
|
||||
model.setSimpleRef(refProperty.getSimpleRef());
|
||||
}
|
||||
if (property.getValue() instanceof ArrayProperty)
|
||||
{
|
||||
ArrayProperty arrayProperty = (ArrayProperty) property.getValue();
|
||||
Entry<String, io.swagger.models.properties.Property> itemsEntry = new AbstractMap.SimpleEntry<String, io.swagger.models.properties.Property>(
|
||||
arrayProperty.getName(), arrayProperty.getItems());
|
||||
model.setItemsType(RestModelProperty.build(itemsEntry));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNameCapitalized()
|
||||
{
|
||||
return org.apache.commons.lang3.StringUtils.capitalize(name);
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
switch (this.type)
|
||||
{
|
||||
case "string":
|
||||
return "String";
|
||||
case "integer":
|
||||
return "int";
|
||||
case "object":
|
||||
return "Object";
|
||||
case "ref":
|
||||
return "Rest" + getSimpleRef() + "Model";
|
||||
case "array":
|
||||
return "List<" + getItemsType().getType() + ">";
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean isRequired()
|
||||
{
|
||||
return isRequired;
|
||||
}
|
||||
|
||||
public void setIsRequired(Boolean isRequired)
|
||||
{
|
||||
this.isRequired = isRequired;
|
||||
}
|
||||
|
||||
protected void setSimpleRef(String simpleRef)
|
||||
{
|
||||
this.simpleRef = simpleRef;
|
||||
}
|
||||
|
||||
public String getSimpleRef()
|
||||
{
|
||||
return simpleRef;
|
||||
}
|
||||
|
||||
protected void setItemsType(RestModelProperty itemsType)
|
||||
{
|
||||
this.itemsType = itemsType;
|
||||
}
|
||||
|
||||
public RestModelProperty getItemsType()
|
||||
{
|
||||
return itemsType;
|
||||
}
|
||||
}
|
@@ -1,222 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Console;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerDefinitions
|
||||
{
|
||||
private Swagger swagger;
|
||||
List<SwaggerModel> missingSwaggerModels = new ArrayList<SwaggerModel>();
|
||||
Path modelsPath;
|
||||
|
||||
public SwaggerDefinitions(Swagger swagger)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
}
|
||||
|
||||
public void generateMissingDefinitions()
|
||||
{
|
||||
/*
|
||||
* read the content of ignore-moldels file
|
||||
*/
|
||||
List<String> ignoreModel = new ArrayList<String>();
|
||||
try
|
||||
{
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(Paths.get(modelsPath.toFile().getPath(), "ignore-models").toFile())))
|
||||
{
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
if (!line.startsWith("#") && !line.equals(""))
|
||||
ignoreModel.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while generating missing definitions.", e);
|
||||
}
|
||||
|
||||
/*
|
||||
* filter all models, ignoring the ones from ignore-model or the ones that are already created locally
|
||||
*/
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
|
||||
//regexp
|
||||
if(swaggerModel.getName().matches(".*Paging|.*Entry"))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on regular expression: '.*Paging|.*Entry')\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignoreModel.contains(swaggerModel.getName()))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on 'ignore-models' file)\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!swaggerModel.exist())
|
||||
missingSwaggerModels.add(swaggerModel);
|
||||
}
|
||||
|
||||
System.out.println(Generator.line);
|
||||
int count = 0;
|
||||
/*
|
||||
* iterate on all missing models
|
||||
*/
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
if (count == 0) // table heather
|
||||
{
|
||||
System.out.printf("MISSING MODEL ~ THE NEW FILE THAT WILL BE GENERATED\n");
|
||||
System.out.println(" 0 -[Skip all]");
|
||||
}
|
||||
|
||||
count += 1;
|
||||
StringBuilder info = new StringBuilder();
|
||||
info.append(" ")
|
||||
.append(count)
|
||||
.append(" -")
|
||||
.append("[")
|
||||
.append(swaggerModel.getName())
|
||||
.append("] ~ [")
|
||||
.append(swaggerModel.getPath())
|
||||
.append("]");
|
||||
|
||||
System.out.println(info.toString());
|
||||
}
|
||||
System.out.println("ENTER -[All Models]");
|
||||
|
||||
/*
|
||||
* wait for input
|
||||
*/
|
||||
Console c = System.console();
|
||||
if (c != null && missingSwaggerModels.size() > 0)
|
||||
{
|
||||
c.format("%s\n", Generator.line);
|
||||
c.format("\nPlease select what Models you want to generate (ex: 1,3,4) or press <<ENTER>>to generating all missing models:");
|
||||
String prompt = c.readLine();
|
||||
|
||||
if(prompt.equals("0"))
|
||||
return;
|
||||
|
||||
if (prompt.length() == 0)
|
||||
{
|
||||
System.out.println("\nStart generating all models...");
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
generateModel(swaggerModel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prompt.contains(","))
|
||||
{
|
||||
String[] modelsIDToGen = prompt.split(",");
|
||||
for (int i = 0; i < modelsIDToGen.length; i++)
|
||||
{
|
||||
generateSelectedSwaggerModel(modelsIDToGen[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
generateSelectedSwaggerModel(prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the model based on the ID provided
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
private void generateSelectedSwaggerModel(String id)
|
||||
{
|
||||
int choice = Integer.parseInt(id);
|
||||
if ((choice - 1) >= missingSwaggerModels.size())
|
||||
{
|
||||
throw new TestConfigurationException(
|
||||
"You specified a wrong ID: [" + id + "] please select one value from the list displayed above. Run the command again!");
|
||||
}
|
||||
generateModel(missingSwaggerModels.get(choice - 1));
|
||||
}
|
||||
|
||||
public boolean generateDefinition(String modelParamValue)
|
||||
{
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
if (swaggerModel.getName().equals(modelParamValue))
|
||||
{
|
||||
generateModel(swaggerModel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
System.err.println("Model that you provided was NOT found!");
|
||||
System.err.printf("Model [%s] not found in Swagger file: %s\n", modelParamValue, swagger.getBasePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateModel(SwaggerModel swaggerModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
swaggerModel.generate();
|
||||
}
|
||||
catch (IOException | TemplateException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while generating model definition.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,186 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles swagger definitions <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerModel
|
||||
{
|
||||
private Swagger swagger;
|
||||
private Entry<String, Model> model;
|
||||
private Path modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
private List<RestModelProperty> properties = new ArrayList<RestModelProperty>();
|
||||
private Configuration cfg;
|
||||
|
||||
private Configuration getConfig() throws IOException
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerModel(Entry<String, Model> model, Swagger swagger)
|
||||
{
|
||||
this.model = model;
|
||||
this.swagger = swagger;
|
||||
|
||||
|
||||
if(model.getValue().getProperties()!=null)
|
||||
{
|
||||
/*
|
||||
* compute the properties of this model
|
||||
*/
|
||||
for (Entry<String, io.swagger.models.properties.Property> property : model.getValue().getProperties().entrySet())
|
||||
{
|
||||
if (property.getKey().equals("entry"))
|
||||
continue;
|
||||
|
||||
properties.add(RestModelProperty.build(property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if file is already generated in TAS, under 'models' package
|
||||
*/
|
||||
public boolean exist()
|
||||
{
|
||||
return getPath().exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the model in TAS
|
||||
*/
|
||||
public File getPath()
|
||||
{
|
||||
return Paths.get(modelsPath.toFile().getPath(), getNameInTAS() + ".java").toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return original model name as defined in Swagger YAML
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return model.getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name as it will be used in TAS
|
||||
*/
|
||||
public String getNameInTAS()
|
||||
{
|
||||
return String.format("Rest%sModel", getName());
|
||||
}
|
||||
|
||||
public List<RestModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<RestModelProperty> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void generate() throws IOException, TemplateException
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-model.ftl");
|
||||
|
||||
// here we will store all data passed to template
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
|
||||
data.put("author", System.getProperty("user.name"));
|
||||
data.put("yamlTitle", swagger.getInfo().getTitle());
|
||||
data.put("yamlBasePath", swagger.getBasePath());
|
||||
data.put("name", getNameInTAS());
|
||||
|
||||
if (!getProperties().isEmpty())
|
||||
data.put("properties", getProperties());
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
|
||||
System.out.println("----- " + getPath().getName() + " -----\n");
|
||||
System.out.println(Generator.line);
|
||||
System.out.println(append.toString());
|
||||
System.out.printf("\nGenerating Model: %-10s to ->'%-60s'", getName(), getPath());
|
||||
if (exist())
|
||||
{
|
||||
Console c = System.console();
|
||||
if (c != null)
|
||||
{
|
||||
System.out.printf("There is already one model created locally: \n%s\nDo you want to override it ?(ENTER=yes, any other key=no):", getPath());
|
||||
if (c.readLine().length() == 0)
|
||||
{
|
||||
writeContent(append.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeContent(append.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void writeContent(String content) throws IOException
|
||||
{
|
||||
FileWriter fw = new FileWriter(getPath());
|
||||
fw.write(content);
|
||||
fw.close();
|
||||
}
|
||||
}
|
@@ -1,219 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import io.swagger.models.HttpMethod;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerPaths
|
||||
{
|
||||
private Swagger swagger;
|
||||
private BufferedWriter fileWithMissingRequests;
|
||||
private BufferedWriter fileWithImplementedRequests;
|
||||
private String swaggerFilePath;
|
||||
private int implementedRequestCount = 0;
|
||||
private int missingRequestCount = 0;
|
||||
|
||||
public SwaggerPaths(Swagger swagger, String swaggerFilePath)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare requests that exist in swagger yaml file vs request implemented in your code
|
||||
* any findings are saved to a missing-request txt file.
|
||||
*
|
||||
* @throws TestConfigurationException
|
||||
*/
|
||||
public void computeCoverage()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Start computing the coverage of TAS vs Swagger file. Stand by...");
|
||||
File missingReq = new File(String.format("missing-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
missingReq.delete();
|
||||
fileWithMissingRequests = new BufferedWriter(new FileWriter(missingReq));
|
||||
fileWithMissingRequests.write(String.format("BasePath: {%s}", swagger.getBasePath()));
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("These requests generated should be analyzed and modified according to your needs.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("PLEASE UPDATE your 'RestReturnedModel' name with the appropiate returned model by your request.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
File implReq = new File(String.format("implemented-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
implReq.delete();
|
||||
fileWithImplementedRequests = new BufferedWriter(new FileWriter(implReq));
|
||||
|
||||
for (Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet())
|
||||
{
|
||||
for (Map.Entry<HttpMethod, Operation> operation : path.getValue().getOperationMap().entrySet())
|
||||
{
|
||||
searchPattern(path.getKey(), operation);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(toString());
|
||||
|
||||
fileWithImplementedRequests.close();
|
||||
fileWithMissingRequests.close();
|
||||
|
||||
if (missingRequestCount > 0)
|
||||
{
|
||||
System.out.println("[ERROR] PLEASE ANALYSE THE GENERATED <missing-requests> file(s), it seems some request were NOT implemented!");
|
||||
}
|
||||
else
|
||||
missingReq.delete();
|
||||
|
||||
System.out.println("ALSO ANALYZE <implemented-requests.txt> for current implementation, take a look at duplicated requests if any!");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Exception while trying to create coverage report.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use RegExp to check for requests in code, line by line: no further algorithm performance analysis required at this time
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param pathUrl
|
||||
* @param methodName
|
||||
*/
|
||||
private void searchPattern(String pathUrl, Entry<HttpMethod, Operation> operation)
|
||||
{
|
||||
String originalPathUrl = pathUrl;
|
||||
String httpMethod = operation.getKey().name();
|
||||
|
||||
/* update path url, removing first "/" as implemented in TAS requests. */
|
||||
if (pathUrl.startsWith("/"))
|
||||
pathUrl = pathUrl.substring(1, pathUrl.length());
|
||||
|
||||
if (pathUrl.contains("{"))
|
||||
pathUrl = pathUrl.replace("{", "\\{");
|
||||
|
||||
/*
|
||||
* if in code we have something like: <code> "(HttpMethod.GET, "process-definitions?{parameters}" </code>
|
||||
* our regular expression will search for text insider the 'HttpMethod.GET' concatenated with found 'pathUrl" until the optional double brackets
|
||||
* RegExp: .*HttpMethod.%s.*\\\"%s\\\"?.*
|
||||
* Result: .*HttpMethod.GET."process-definition".* - if this line is found we have a match
|
||||
*/
|
||||
String patternRegEx = String.format(".*HttpMethod.%s.*\\\"%s\\\"?.*", httpMethod, pathUrl);
|
||||
|
||||
// all request are saved under this directory, but limited to the rest/request folder
|
||||
File project = Paths.get(".").toAbsolutePath().normalize().toFile();
|
||||
Path requestsPath = Paths.get(project.getPath(), "src/main/java/org/alfresco/rest/requests");
|
||||
|
||||
BufferedReader br;
|
||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(requestsPath))
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
for (Path path : directoryStream)
|
||||
{
|
||||
if (Files.isRegularFile(path) && Files.isReadable(path))
|
||||
{
|
||||
String line;
|
||||
InputStream fis = new FileInputStream(path.toFile());
|
||||
InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
|
||||
if (line.matches(patternRegEx))
|
||||
{
|
||||
// log("OK - Pattern %-60s found in: {%s} file." , originalPathUrl, path.getFileName());
|
||||
fileWithImplementedRequests.write(String.format("%-10s %-60s %s", httpMethod, pathUrl, path.getFileName()));
|
||||
fileWithImplementedRequests.newLine();
|
||||
fileWithImplementedRequests.flush();
|
||||
implementedRequestCount += 1;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
fileWithMissingRequests.write(String.format("%-10s %-60s %s", httpMethod, originalPathUrl, patternRegEx));
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
SwaggerRequest swaggerReqModel = new SwaggerRequest(httpMethod, pathUrl, operation.getValue());
|
||||
fileWithMissingRequests.write(swaggerReqModel.getRequestSample());
|
||||
fileWithMissingRequests.flush();
|
||||
missingRequestCount += 1;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("|\n").append("|------------------------------------------------------------------------\n").append("COVERAGE: ")
|
||||
.append(swaggerFilePath).append("\n");
|
||||
|
||||
int percentage = (implementedRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append("\t\tImplemented:\t").append(String.valueOf(percentage)).append("% [# ").append(implementedRequestCount).append("]\t Missing: ");
|
||||
|
||||
percentage = (missingRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append(String.valueOf(percentage)).append("% [# ").append(missingRequestCount).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Operation;
|
||||
|
||||
public class SwaggerRequest
|
||||
{
|
||||
private Configuration cfg;
|
||||
private Operation swaggerRequest;
|
||||
private String httpMethod;
|
||||
private String pathUrl;
|
||||
|
||||
private Configuration getConfig()
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
try
|
||||
{
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while configuring Freemarker template directory.", e);
|
||||
}
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerRequest(String httpMethod, String pathUrl, Operation swaggerRequest)
|
||||
{
|
||||
this.swaggerRequest = swaggerRequest;
|
||||
this.httpMethod = httpMethod;
|
||||
this.pathUrl = pathUrl;
|
||||
}
|
||||
|
||||
public String getRequestSample()
|
||||
{
|
||||
try
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-request.ftl");
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("operationId", swaggerRequest.getOperationId());
|
||||
data.put("httpMethod", httpMethod);
|
||||
data.put("pathUrl", pathUrl);
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
return append.toString();
|
||||
}
|
||||
catch (IOException | TemplateException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while loading sample request.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
/**
|
||||
* This will handle the Swagger YAML file
|
||||
* It will contain all the models, request or any other properties needed for out generator
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerYamlParser
|
||||
{
|
||||
private Swagger swagger;
|
||||
private String swaggerFilePath;
|
||||
|
||||
public SwaggerYamlParser(String swaggerFilePath) throws TestConfigurationException
|
||||
{
|
||||
if (swaggerFilePath == null)
|
||||
throw new TestConfigurationException("'swaggerFilePath' not defined. Please update your pom.xml file with all '<swagger-file-location.yml>'");
|
||||
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
this.swagger = new SwaggerParser().read(this.swaggerFilePath);
|
||||
|
||||
}
|
||||
|
||||
public void computeCoverage()
|
||||
{
|
||||
new SwaggerPaths(swagger, this.swaggerFilePath).computeCoverage();
|
||||
}
|
||||
|
||||
public void generateMissingModules()
|
||||
{
|
||||
String modelParamValue = System.getProperty("models");
|
||||
|
||||
SwaggerDefinitions swaggerDefinitions = new SwaggerDefinitions(swagger);
|
||||
|
||||
System.out.println(Generator.line);
|
||||
System.out.println("Using SWAGGER FILE: " + this.swaggerFilePath);
|
||||
System.out.println(Generator.line);
|
||||
/*
|
||||
* multiple models, separated by comma: 'mvn exec:java -Dmodels=a,b,d'
|
||||
*/
|
||||
if (modelParamValue.contains(","))
|
||||
{
|
||||
String[] models = {};
|
||||
models = modelParamValue.split(",");
|
||||
|
||||
for (int i = 0; i < models.length; i++)
|
||||
{
|
||||
// generate model
|
||||
swaggerDefinitions.generateDefinition(models[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if no value is added after models "mvn exec:java -Dmodels"
|
||||
* then we assume that we want to generate all models
|
||||
*/
|
||||
if (modelParamValue.equals("true"))
|
||||
{
|
||||
swaggerDefinitions.generateMissingDefinitions();
|
||||
}
|
||||
/*
|
||||
* there is just one model passed as value "mvn exec:java -Dmodels=a"
|
||||
* so only model "a" is generated locally
|
||||
*/
|
||||
else
|
||||
{
|
||||
swaggerDefinitions.generateDefinition(modelParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user