diff --git a/.drone.yml b/.drone_old.yml similarity index 100% rename from .drone.yml rename to .drone_old.yml diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml deleted file mode 100644 index 6c82b63769..0000000000 --- a/.github/workflows/analysis.yml +++ /dev/null @@ -1,77 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2025 Alper Ozturk -# SPDX-FileCopyrightText: 2023 Tobias Kaminsky -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2023 Josh Richards -# SPDX-FileCopyrightText: 2025 Marcel Hibbe -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "Analysis" - -on: - pull_request: - branches: [ "master", "main", "stable-*" ] - push: - branches: [ "master", "main", "stable-*" ] - -permissions: - pull-requests: write - contents: write - -concurrency: - group: analysis-wrapper-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - analysis: - runs-on: ubuntu-latest - steps: - - name: Disabled on forks - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} - run: | - echo 'Can not analyze PRs from forks' - exit 1 - - name: Setup variables # zizmor: ignore[template-injection] - id: get-vars - run: | - if [ -z "$GITHUB_HEAD_REF" ]; then - # push - { - echo "branch=$GITHUB_REF_NAME" - echo "pr=$GITHUB_RUN_ID" - echo "repo=${{ github.repository }}" - } >> "$GITHUB_OUTPUT" - else - # pull request - { - echo "branch=$GITHUB_HEAD_REF" - echo "pr=${{ github.event.pull_request.number }}" - echo "repo=${{ github.event.pull_request.head.repo.full_name }}" - } >> "$GITHUB_OUTPUT" - fi - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - repository: ${{ steps.get-vars.outputs.repo }} - ref: ${{ steps.get-vars.outputs.branch }} - - name: Set up JDK 21 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - distribution: "temurin" - java-version: 21 - - name: Install dependencies - run: | - sudo apt install python3-defusedxml - - name: Run analysis wrapper - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - mkdir -p "$HOME/.gradle" - { - echo "org.gradle.jvmargs=-Xmx1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" - echo "org.gradle.configureondemand=true" - echo "kapt.incremental.apt=true" - } > "$HOME/.gradle/gradle.properties" - scripts/analysis/analysis-wrapper.sh "${{ steps.get-vars.outputs.branch }}" "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" "$GITHUB_RUN_NUMBER" "${{ steps.get-vars.outputs.pr }}" diff --git a/.github/workflows/assemble.yml b/.github/workflows/assemble.yml deleted file mode 100644 index c3e569b3ee..0000000000 --- a/.github/workflows/assemble.yml +++ /dev/null @@ -1,36 +0,0 @@ -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: MIT - -name: Assemble - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -permissions: - contents: read - -jobs: - assemble: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Set up JDK 17 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - distribution: "temurin" - java-version: 17 - - uses: gradle/actions/wrapper-validation@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1 - - name: Setup JVM options - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - - name: Setup Gradle - uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1 - - name: Assemble - run: ./gradlew assemble diff --git a/.github/workflows/autoApproveSync.yml b/.github/workflows/autoApproveSync.yml deleted file mode 100644 index c215be0b3e..0000000000 --- a/.github/workflows/autoApproveSync.yml +++ /dev/null @@ -1,40 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: Auto approve sync -on: - pull_request_target: # zizmor: ignore[dangerous-triggers] - branches: - - master - - main - types: - - opened - - reopened - - synchronize - - labeled - -concurrency: - group: sync-approve-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - pull-requests: write - -jobs: - auto-approve: - name: Auto approve sync - runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }} - steps: - - name: Disabled on forks - if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} - run: | - echo 'Can not approve PRs from forks' - exit 1 - - - uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 3ba50dd6dc..0000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2017 Tobias Kaminsky -# SPDX-License-Identifier: GPL-3.0-or-later -name: Check - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -permissions: - contents: read - -jobs: - check: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - task: [ detekt, spotlessKotlinCheck, lint ] - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Set up JDK 17 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - distribution: "temurin" - java-version: 17 - - name: Setup JVM options - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - - name: Check ${{ matrix.task }} - uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 - with: - arguments: ${{ matrix.task }} - - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - if: ${{ always() }} - with: - name: ${{ matrix.task }}-report - path: library/build/reports diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 02030913bc..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,60 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-FileCopyrightText: 2025 Marcel Hibbe -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "CodeQL" - -on: - push: - branches: [ "master", "main", "stable-*" ] - pull_request: - branches: [ "master", "main" ] - schedule: - - cron: '24 18 * * 3' - -permissions: - contents: read - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - steps: - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - name: Set Swap Space - if: runner.environment == 'github-hosted' - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0 - with: - swap-size-gb: 10 - - name: Initialize CodeQL - uses: github/codeql-action/init@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1 - with: - languages: ${{ matrix.language }} - - name: Set up JDK 21 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - distribution: "temurin" - java-version: 21 - - name: Assemble - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - ./gradlew --no-daemon assembleDebug - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1 diff --git a/.github/workflows/configNC_master.sh b/.github/workflows/configNC_master.sh new file mode 100644 index 0000000000..e49050de29 --- /dev/null +++ b/.github/workflows/configNC_master.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + + + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +source ~/.bashrc; nvm install node + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone --depth=1 -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone --depth=1 -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +git clone --depth=1 -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/ +php /var/www/html/occ app:enable end_to_end_encryption + +git clone --depth=1 -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +git clone --depth=1 -b master https://github.com/nextcloud/external/ /var/www/html/apps/external/ +cd /var/www/html/apps/external; composer install --no-dev +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +git clone --depth=1 -b main https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/ +php /var/www/html/occ app:enable -f files_lock + +git clone --depth=1 https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/ +php /var/www/html/occ app:enable -f groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone --depth=1 https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable -f notifications +php /var/www/html/occ notification:generate test -d test + +git clone --depth=1 https://github.com/nextcloud/photos.git /var/www/html/apps/photos/ +cd /var/www/html/apps/photos; composer install --no-dev +php /var/www/html/occ app:enable -f photos + +git clone --depth=1 https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/ +cd /var/www/html/apps/assistant; source ~/.bashrc; make +php /var/www/html/occ app:enable -f assistant + +php /var/www/html/occ app:enable -f testing + +git clone --depth 1 https://github.com/nextcloud/files_downloadlimit.git /var/www/html/apps/files_downloadlimit/ +php /var/www/html/occ app:enable -f files_downloadlimit + +git clone --depth 1 -b master https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/ +php /var/www/html/occ app:enable -f recommendations + +php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool diff --git a/.github/workflows/configNC_stable16.sh b/.github/workflows/configNC_stable16.sh new file mode 100644 index 0000000000..ea8e53aa55 --- /dev/null +++ b/.github/workflows/configNC_stable16.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +SERVER_VERSION="stable16" + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +php /var/www/html/occ app:enable end_to_end_encryption + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +php /var/www/html/occ app:enable groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable notifications + +php /var/www/html/occ app:enable testing diff --git a/.github/workflows/configNC_stable30.sh b/.github/workflows/configNC_stable30.sh new file mode 100644 index 0000000000..786768e9ec --- /dev/null +++ b/.github/workflows/configNC_stable30.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +SERVER_VERSION="stable30" + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash +source ~/.bashrc; nvm install node + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/ +php /var/www/html/occ app:enable end_to_end_encryption + +git clone -b $SERVER_VERSION https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +git clone -b $SERVER_VERSION https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/ +php /var/www/html/occ app:enable -f files_lock + +git clone -b $SERVER_VERSION https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/ +php /var/www/html/occ app:enable -f groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable -f notifications +php /var/www/html/occ notification:generate test -d test + +git clone -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/ +cd /var/www/html/apps/photos; composer install --no-dev +php /var/www/html/occ app:enable -f photos + +git clone https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/ +cd /var/www/html/apps/assistant; git checkout tags/v1.0.8; source ~/.bashrc; npm run build; composer install --no-dev +php /var/www/html/occ app:enable -f assistant + +php /var/www/html/occ app:enable -f testing diff --git a/.github/workflows/configServer.sh b/.github/workflows/configServer.sh new file mode 100644 index 0000000000..a444314131 --- /dev/null +++ b/.github/workflows/configServer.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +apt-get update && apt-get install -y composer +mkdir /var/www/.nvm /var/www/.npm +touch /var/www/.bashrc +chown -R 33:33 /var/www/.nvm /var/www/.npm /var/www/.bashrc + +rm data -rf +rm config/config.php +BRANCH="$1" /usr/local/bin/initnc.sh diff --git a/.github/workflows/configServer16.sh b/.github/workflows/configServer16.sh new file mode 100644 index 0000000000..cb603e595e --- /dev/null +++ b/.github/workflows/configServer16.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +rm data -rf +rm config/config.php +BRANCH="stable16" /initnc.sh diff --git a/.github/workflows/detectNewJavaFiles.yml b/.github/workflows/detectNewJavaFiles.yml deleted file mode 100644 index 908e3fd288..0000000000 --- a/.github/workflows/detectNewJavaFiles.yml +++ /dev/null @@ -1,43 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "Detect new java files" - -on: - pull_request: - branches: [ master, main, stable-* ] - -permissions: read-all - -concurrency: - group: detect-new-java-files-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - detectNewJavaFiles: - runs-on: ubuntu-latest - steps: - - id: file_changes - uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4 - with: - output: ',' - - name: Detect new java files - run: | - if [ -z '${{ steps.file_changes.outputs.files_added }}' ]; then - echo "No new files added" - exit 0 - fi - new_java=$(echo '${{ steps.file_changes.outputs.files_added }}' | tr ',' '\n' | grep '\.java$' | cat) - if [ -n "$new_java" ]; then - # shellcheck disable=SC2016 - printf 'New java files detected:\n```\n%s\n```\n' "$new_java" | tee "$GITHUB_STEP_SUMMARY" - exit 1 - else - echo "No new java files detected" - exit 0 - fi diff --git a/.github/workflows/detectSnaphost.yml b/.github/workflows/detectSnaphost.yml deleted file mode 100644 index 646c25bf17..0000000000 --- a/.github/workflows/detectSnaphost.yml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2017 Tobias Kaminsky -# SPDX-License-Identifier: GPL-3.0-or-later -name: "Detect snapshot" - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -# Declare default permissions as read only. -permissions: read-all - -jobs: - detekt: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Detect SNAPSHOT - run: scripts/analysis/detectSNAPSHOT.sh diff --git a/.github/workflows/garm.yml b/.github/workflows/garm.yml new file mode 100644 index 0000000000..6bd673b1ab --- /dev/null +++ b/.github/workflows/garm.yml @@ -0,0 +1,196 @@ +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later + +name: "Garm" + +on: + pull_request: + branches: [ master, stable-* ] + +permissions: + contents: read + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest-kvm + services: + server: + image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest + options: --name server + ports: + - 80:80 + strategy: + fail-fast: false + matrix: + server: [ master ] # [ stable20, stable32, master ] + api-level: [ 30 ] # [ 21, 36 ] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: configure server + run: | + sudo apt-get update && sudo apt-get install unzip cpu-checker qemu-kvm --yes + sudo chmod 666 /dev/kvm + docker cp .github/workflows/configServer.sh server:/tmp/ + docker exec server chmod +x /tmp/configServer.sh + docker exec server /tmp/configServer.sh ${{ matrix.server }} + docker cp .github/workflows/configNC_${{ matrix.server }}.sh server:/tmp/ + docker exec server chmod +x /tmp/configNC_${{ matrix.server }}.sh + docker exec --user www-data server /tmp/configNC_${{ matrix.server }}.sh + docker exec server /usr/local/bin/run.sh + + - name: set up JDK 17 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 + with: + distribution: "temurin" + java-version: 17 + + - name: create AVD and generate snapshot for caching + uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0 + with: + api-level: ${{ matrix.api-level }} + force-avd-creation: false + arch: x86 + sdcard-path-or-size: 100M + target: google_apis + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 + script: echo "Generated AVD snapshot for caching." + + - name: Configure gradle daemon + run: | + mkdir -p $HOME/.gradle + echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties + echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties + + - name: Build gplay # TODO build only once! + run: | + sed -i s#https://server#http://10.0.2.2# gradle.properties + sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt + ./gradlew assembleDebug --info + + - name: wait and ping server + run: | + while ! curl http://localhost/status.php 2>&1 | grep installed; do + echo "wait…" + sleep 5 + done + + - name: gplay + uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0 + with: + api-level: ${{ matrix.api-level }} + force-avd-creation: false + arch: x86 + sdcard-path-or-size: 100M + target: google_apis + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 + script: scripts/runTests.sh + + - name: upload failing results + if: ${{ failure() }} + env: + LOG_USERNAME: ${{ secrets.LOG_USERNAME }} + LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }} + GIT_USERNAME: ${{ secrets.GIT_USERNAME }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "master" "IT" ${{github.event.number}} "${{ secrets.GIT_USERNAME }}" "${{ secrets.GIT_TOKEN }}" + - name: Archive Espresso results + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: ${{ always() }} + with: + name: Report-${{ matrix.server }}-${{ matrix.api-level }} + path: app/build/reports + retention-days: 4 + +# stable16: +# runs-on: ubuntu-latest-kvm +# services: +# server: +# image: nextcloudci/server:server-13 +# options: --name server +# ports: +# - 80:80 +# strategy: +# fail-fast: false +# matrix: +# api-level: [ 27 ] +# steps: +# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 +# +# - name: wait and ping server +# run: | +# while ! curl http://localhost/status.php 2>&1 | grep installed; do +# echo "wait…" +# sleep 5 +# done +# +# - name: configure server +# run: | +# docker cp .github/workflows/configServer16.sh server:/tmp/ +# docker exec server chmod +x /tmp/configServer16.sh +# docker exec server /tmp/configServer16.sh +# docker cp .github/workflows/configNC_stable16.sh server:/tmp/ +# docker exec server chmod +x /tmp/configNC_stable16.sh +# docker exec --user www-data server /tmp/configNC_stable16.sh +# +# - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 +# with: +# distribution: "temurin" +# java-version: 17 +# +# - name: create AVD and generate snapshot for caching +# uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 +# with: +# api-level: ${{ matrix.api-level }} +# force-avd-creation: false +# arch: x86 +# sdcard-path-or-size: 100M +# target: google_apis +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 +# script: echo "Generated AVD snapshot for caching." +# +# - name: Configure gradle daemon +# run: | +# mkdir -p $HOME/.gradle +# echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties +# echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties +# +# - name: Build gplay # TODO build only once! +# run: | +# sed -i s#https://server#http://10.0.2.2# gradle.properties +# sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt +# ./gradlew assembleDebug +# +# - name: gplay +# env: +# SHOT_TEST: "true" +# uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 +# with: +# api-level: ${{ matrix.api-level }} +# force-avd-creation: false +# arch: x86 +# sdcard-path-or-size: 100M +# target: google_apis +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 +# script: scripts/runTests.sh +# +# - name: upload failing results +# if: ${{ failure() }} +# env: +# LOG_USERNAME: ${{ secrets.LOG_USERNAME }} +# LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }} +# GIT_USERNAME: ${{ secrets.GIT_USERNAME }} +# GIT_TOKEN: ${{ secrets.GIT_TOKEN }} +# run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "master" "IT" ${{github.event.number}} "${{ secrets.GIT_USERNAME }}" "${{ secrets.GIT_TOKEN }}" +# - name: Archive Espresso results +# uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 +# if: ${{ always() }} +# with: +# name: Report-${{ matrix.server }}-${{ matrix.api-level }} +# path: app/build/reports +# retention-days: 4 diff --git a/.github/workflows/pr-feedback.yml b/.github/workflows/pr-feedback.yml deleted file mode 100644 index a3a2d1296c..0000000000 --- a/.github/workflows/pr-feedback.yml +++ /dev/null @@ -1,55 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Marcel Klehr -# SPDX-FileCopyrightText: 2023 Joas Schilling <213943+nickvergessen@users.noreply.github.com> -# SPDX-FileCopyrightText: 2023 Daniel Kesselberg -# SPDX-FileCopyrightText: 2023 Florian Steffens -# SPDX-License-Identifier: MIT - -name: 'Ask for feedback on PRs' -on: - schedule: - - cron: '30 1 * * *' - -permissions: - contents: read - pull-requests: write - -jobs: - pr-feedback: - if: ${{ github.repository_owner == 'nextcloud' }} - runs-on: ubuntu-latest - steps: - - name: The get-github-handles-from-website action - uses: marcelklehr/get-github-handles-from-website-action@06b2239db0a48fe1484ba0bfd966a3ab81a08308 # v1.0.1 - id: scrape - with: - website: 'https://nextcloud.com/team/' - - - name: Get blocklist - id: blocklist - run: | - blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -) - echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT" - - - uses: nextcloud/pr-feedback-action@5227c55be184087d0aef6338bee210d8620b6297 # main - with: - feedback-message: | - Hello there, - Thank you so much for taking the time and effort to create a pull request to our Nextcloud project. - - We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. - - Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 - - Thank you for contributing to Nextcloud and we hope to hear from you soon! - - (If you believe you should not receive this message, you can add yourself to the [blocklist](https://github.com/nextcloud/.github/blob/master/non-community-usernames.txt).) - days-before-feedback: 14 - start-date: '2024-04-30' - exempt-authors: '${{ steps.blocklist.outputs.blocklist }},${{ steps.scrape.outputs.users }}' - exempt-bots: true diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml deleted file mode 100644 index 3f485f875f..0000000000 --- a/.github/workflows/reuse.yml +++ /dev/null @@ -1,27 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization - -# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. -# -# SPDX-License-Identifier: CC0-1.0 - -name: REUSE Compliance Check - -on: [pull_request] - -permissions: - contents: read - -jobs: - reuse-compliance-check: - runs-on: ubuntu-latest-low - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: REUSE Compliance Check - uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml deleted file mode 100644 index 19c608fe1a..0000000000 --- a/.github/workflows/scorecard.yml +++ /dev/null @@ -1,47 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-License-Identifier: GPL-3.0-or-later - -name: Scorecard supply-chain security -on: - branch_protection_rule: - schedule: - - cron: '32 23 * * 4' - push: - branches: [ "main", "master" ] - -# Declare default permissions as read only. -permissions: read-all - -concurrency: - group: scorecard-supply-chain-security-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - analysis: - name: Scorecard analysis - runs-on: ubuntu-latest - permissions: - # Needed to upload the results to code-scanning dashboard. - security-events: write - - steps: - - name: "Checkout code" - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: "Run analysis" - uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 - with: - results_file: results.sarif - results_format: sarif - publish_results: false - - # Upload the results to GitHub's code scanning dashboard. - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1 - with: - sarif_file: results.sarif diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index fe125a9a62..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,35 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: 'Close stale issues' -on: - schedule: - - cron: '0 0 * * *' - -# Declare default permissions as read only. -permissions: read-all - -jobs: - stale: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1 - with: - days-before-stale: 28 - days-before-close: 14 - days-before-pr-close: -1 - only-labels: 'bug,needs info' - exempt-issue-labels: 'no-stale' - stale-issue-message: >- - This bug report did not receive an update in the last 4 weeks. - Please take a look again and update the issue with new details, - otherwise the issue will be automatically closed in 2 weeks. Thank you! - exempt-all-pr-milestones: true - labels-to-remove-when-unstale: 'needs info' diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt index a2e9aed385..b10e8ee8fb 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt @@ -14,14 +14,18 @@ import com.owncloud.android.lib.resources.shares.OCShare import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.status.NextcloudVersion import org.junit.Assert.assertTrue +import org.junit.Before import org.junit.Test class DashboardGetWidgetItemsRemoteOperationIT : AbstractIT() { - @Test - fun getItems() { + @Before + fun before() { // only on NC25+ testOnlyOnServer(NextcloudVersion.nextcloud_25) + } + @Test + fun getItems() { // create folder to have some content assertTrue(CreateFolderRemoteOperation("/testFolder", false).execute(client2).isSuccess) assertTrue( diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java index b8b88a081b..24eb575eff 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java @@ -9,7 +9,9 @@ import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.operations.RemoteOperationResult; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertFalse; diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java index 83540cdbeb..7b5cba922d 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java @@ -10,7 +10,9 @@ import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.TemplateList; import com.owncloud.android.lib.common.operations.RemoteOperationResult; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import java.util.Objects; diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java index 9f23bf3a74..d98f9d04ed 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java @@ -11,9 +11,11 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import junit.framework.TestCase; +import org.junit.BeforeClass; import org.junit.Test; import java.io.IOException; diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java index 8d4d2f8c37..dd513dc939 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java @@ -16,7 +16,9 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import java.io.File; diff --git a/library/src/androidTest/java/com/owncloud/android/FileIT.java b/library/src/androidTest/java/com/owncloud/android/FileIT.java index a3e87e1962..93f50e2706 100644 --- a/library/src/androidTest/java/com/owncloud/android/FileIT.java +++ b/library/src/androidTest/java/com/owncloud/android/FileIT.java @@ -25,6 +25,7 @@ import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import org.junit.Test; diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java index c30d7c13ec..9e63e83743 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java @@ -25,7 +25,7 @@ public class UpdateMetadataRemoteOperationIT extends AbstractIT { //@Test public void uploadAndModifyV1() { - // tests only for NC19+ + // tests only for NC20+ testOnlyOnServer(OwnCloudVersion.nextcloud_20); // E2E server app checks for official NC client with >=3.13.0, diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java index 7ff006ffd4..37f0e841f3 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java @@ -24,6 +24,7 @@ import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; +import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; import org.junit.BeforeClass; @@ -92,6 +93,12 @@ public void testFileSearchEmpty() throws IOException { @Test public void testFileSearchEverything() throws IOException { + // on newer server we have Talk folder + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) { + offset = 1; + } + for (int i = 0; i < 10; i++) { String filePath = createFile("image" + i); String remotePath = "/image" + i + ".jpg"; @@ -106,7 +113,7 @@ public void testFileSearchEverything() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(11, result.getResultData().size()); + assertEquals(offset + 10, result.getResultData().size()); } @Test @@ -208,6 +215,12 @@ public void favoriteFiles() throws IOException { */ @Test public void testRecentlyModifiedSearch() throws IOException { + // on newer server we have Talk folder + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) { + offset = 1; + } + long now = System.currentTimeMillis() / MILLI_TO_SECOND; String filePath = createFile("image"); assertTrue(new UploadFileRemoteOperation(filePath, "/image.jpg", "image/jpg", now - 50) @@ -232,7 +245,7 @@ public void testRecentlyModifiedSearch() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(4, result.getResultData().size()); + assertEquals(offset + 3, result.getResultData().size()); assertEquals("/video.mp4", result.getResultData().get(0).getRemotePath()); assertEquals("/pdf.pdf", result.getResultData().get(1).getRemotePath()); @@ -423,6 +436,13 @@ public void testGallerySearch() throws IOException { @Test public void showOnlyFolders() throws IOException { + // on newer server we have Talk folder + // on NC16 groupfolder is also returned + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20)) { + offset = 1; + } + for (int i = 0; i < 10; i++) { String filePath = createFile("image" + i); String remotePath = "/image" + i + ".jpg"; @@ -436,13 +456,13 @@ public void showOnlyFolders() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(1, result.getResultData().size()); + assertEquals(0 + offset, result.getResultData().size()); assertTrue(new CreateFolderRemoteOperation("/folder/", false).execute(client).isSuccess()); result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(2, result.getResultData().size()); + assertEquals(1 + offset, result.getResultData().size()); assertEquals("/folder/", result.getResultData().get(0).getRemotePath()); } diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt index 56e9196928..5b9ca6d454 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt @@ -11,6 +11,8 @@ import android.os.Build import com.owncloud.android.AbstractIT import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.files.model.RemoteFile +import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation +import com.owncloud.android.lib.resources.status.OCCapability import junit.framework.TestCase.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue @@ -32,6 +34,11 @@ class UploadFileRemoteOperationIT : AbstractIT() { @Test fun upload() { + val ocCapability = + GetCapabilitiesRemoteOperation() + .execute(nextcloudClient) + .singleData as OCCapability + // create file val filePath = createFile("text") val remotePath = "/test.md" diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt index ba34b46fba..4075dd61db 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt @@ -8,6 +8,7 @@ package com.owncloud.android.lib.resources.notifications import com.owncloud.android.AbstractIT +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertTrue import org.junit.Test diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java index 4a7fc05c87..511faf1a31 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java @@ -27,6 +27,7 @@ import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import junit.framework.TestCase; diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt index 53802ec18e..852ed94b66 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt @@ -9,6 +9,7 @@ package com.owncloud.android.lib.resources.users import androidx.test.platform.app.InstrumentationRegistry import com.owncloud.android.AbstractIT +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.Assert.assertFalse import junit.framework.Assert.assertTrue import okhttp3.Credentials.basic diff --git a/library/src/androidTest/oldTests/DownloadFileTest.java b/library/src/androidTest/oldTests/DownloadFileTest.java deleted file mode 100644 index 21d1618a4c..0000000000 --- a/library/src/androidTest/oldTests/DownloadFileTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android.lib.common.operations; - -import com.owncloud.android.AbstractIT; -import com.owncloud.android.lib.resources.files.RemoteFile; - -import org.apache.commons.io.FileUtils; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; - -/** - * Class to test Download File Operation - * - * @author masensio - * @author David A. Velasco - */ - -public class DownloadFileTest extends AbstractIT { - private static final String LOG_TAG = DownloadFileTest.class.getCanonicalName(); - - /* Files to download. These files must exist on the account */ -// private static final String IMAGE_PATH = "/fileToDownload.png"; -// private static final String IMAGE_PATH_WITH_SPECIAL_CHARS = "/@file@download.png"; - // private static final String IMAGE_NOT_FOUND = "/fileNotFound.png"; - - private String mFullPath2Image; - private String mFullPath2ImageWitSpecialChars; - private String mFullPath2ImageNotFound; - private String mDownloadedFilePath; - -// @Override -// protected void setUp() throws Exception { -// super.setUp(); -// setActivityInitialTouchMode(false); -// mDownloadedFilePath = null; -// mFullPath2Image = mBaseFolderPath + IMAGE_PATH; -// mFullPath2ImageWitSpecialChars = mBaseFolderPath + IMAGE_PATH_WITH_SPECIAL_CHARS; -// mFullPath2ImageNotFound = mBaseFolderPath + IMAGE_NOT_FOUND; -// -// File imageFile = getFile(TestActivity.ASSETS__IMAGE_FILE_NAME); -// -// RemoteOperationResult result = mActivity.uploadFile(imageFile.getAbsolutePath(), mFullPath2Image, -// "image/png", null); -// -// if (!result.isSuccess()) { -// Utils.logAndThrow(LOG_TAG, result); -// } -// -// result = mActivity.uploadFile(imageFile.getAbsolutePath(), mFullPath2ImageWitSpecialChars, "image/png", null); -// if (!result.isSuccess()) { -// Utils.logAndThrow(LOG_TAG, result); -// } -// -// result = mActivity.removeFile(mFullPath2ImageNotFound); -// if (!result.isSuccess() && result.getCode() != ResultCode.FILE_NOT_FOUND) { -// Utils.logAndThrow(LOG_TAG, result); -// } -// } - - /** - * Test Download a File - */ - @Test - public void testDownloadFile() throws FileNotFoundException { - RemoteOperationResult result = mActivity.downloadFile(new RemoteFile(mFullPath2Image), ""); - mDownloadedFilePath = mFullPath2Image; - assertTrue(result.isSuccess()); - // TODO some checks involving the local file - } - - /** - * Test Download a File with special chars - */ - public void testDownloadFileSpecialChars() throws FileNotFoundException { - RemoteOperationResult result = mActivity.downloadFile(new RemoteFile(mFullPath2ImageWitSpecialChars), ""); - mDownloadedFilePath = mFullPath2ImageWitSpecialChars; - assertTrue(result.isSuccess()); - // TODO some checks involving the local file - } - - /** - * Test Download a Not Found File - */ - public void testDownloadFileNotFound() throws FileNotFoundException { - RemoteOperationResult result = mActivity.downloadFile(new RemoteFile(mFullPath2ImageNotFound), ""); - assertFalse(result.isSuccess()); - } - - @Override - protected void tearDown() throws Exception { - if (mDownloadedFilePath != null) { - RemoteOperationResult removeResult = mActivity.removeFile(mDownloadedFilePath); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - File[] files = mActivity.getFilesDir().listFiles(); - for (File file : files) { - if (file.isDirectory()) { - FileUtils.deleteDirectory(file); - } else if (!file.delete()) { - throw new FileNotFoundException(file.getAbsolutePath()); - } - } - super.tearDown(); - } -} diff --git a/library/src/androidTest/oldTests/GetShareesTest.java b/library/src/androidTest/oldTests/GetShareesTest.java deleted file mode 100644 index 6cabbc1fd0..0000000000 --- a/library/src/androidTest/oldTests/GetShareesTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.util.Log; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.resources.shares.GetRemoteShareesOperation; -import com.owncloud.android.lib.resources.shares.ShareType; -import com.owncloud.android.lib.testclient.R; - -import junit.framework.AssertionFailedError; - -import org.apache.commons.httpclient.HttpStatus; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Class to test GetRemoteShareesOperation - *

- * With this TestCase we are experimenting a bit to improve the test suite design, in two aspects: - *

- * - Reduce the dependency from the set of test cases on the "test project" needed to - * have an instrumented APK to install in the device, as required by the testing framework - * provided by Android. To get there, this class avoids calling TestActivity methods in the test - * method. - *

- * - Reduce the impact of creating a remote fixture over the Internet, while the structure of the - * TestCase is kept easy to maintain. To get this, all the tests are done in a single test method, - * granting this way that setUp and tearDown are run only once. - */ - -public class GetShareesTest extends RemoteTest { - - private static final String LOG_TAG = GetShareesTest.class.getCanonicalName(); - - /** - * Test get sharees - *

- * Requires OC server 8.2 or later - */ - public void testGetRemoteShareesOperation() { - Log.v(LOG_TAG, "testGetRemoteSharees in"); - - /// successful cases - - // search for sharees including "a" - RemoteOperationResult result = new GetRemoteShareesOperation("a", 1, 50).execute(mClient); - JSONObject resultItem; - JSONObject value; - int type; - int userCount = 0; - int groupCount = 0; - assertTrue(result.isSuccess() && result.getData().size() > 0); - try { - for (int i = 0; i < result.getData().size(); i++) { - resultItem = (JSONObject) result.getData().get(i); - value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); - type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); - if (type == ShareType.GROUP.getValue()) { - groupCount++; - } else { - userCount++; - } - } - assertTrue(userCount > 0); - assertTrue(groupCount > 0); - } catch (JSONException e) { - AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); - afe.setStackTrace(e.getStackTrace()); - throw afe; - } - - // search for sharees including "ad" - expecting user "admin" & group "admin" - result = new GetRemoteShareesOperation("ad", 1, 50).execute(mClient); - assertTrue(result.isSuccess() && result.getData().size() == 2); - userCount = 0; - groupCount = 0; - try { - for (int i = 0; i < 2; i++) { - resultItem = (JSONObject) result.getData().get(i); - value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); - type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); - if (type == ShareType.GROUP.getValue()) { - groupCount++; - } else { - userCount++; - } - } - assertEquals(userCount, 1); - assertEquals(groupCount, 1); - } catch (JSONException e) { - AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); - afe.setStackTrace(e.getStackTrace()); - throw afe; - } - - - // search for sharees including "bd" - expecting 0 results - result = new GetRemoteShareesOperation("bd", 1, 50).execute(mClient); - assertTrue(result.isSuccess() && result.getData().size() == 0); - - - /// failed cases - - // search for sharees including wrong page values - result = new GetRemoteShareesOperation("a", 0, 50).execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); - - result = new GetRemoteShareesOperation("a", 1, 0).execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); - } - - /** - * Test get federated sharees - *

- * Requires OC server 8.2 or later - */ - public void testGetFederatedShareesOperation() { - Log.v(LOG_TAG, "testGetFederatedSharees in"); - - /// successful cases - - // search for sharees including "@" - RemoteOperationResult result = new GetRemoteShareesOperation("@", 1, 50).execute(mClient); - JSONObject resultItem; - JSONObject value; - int type; - int fedCount = 0; - assertTrue(result.isSuccess() && result.getData().size() > 0); - try { - for (int i = 0; i < result.getData().size(); i++) { - resultItem = (JSONObject) result.getData().get(i); - value = resultItem.getJSONObject(GetRemoteShareesOperation.NODE_VALUE); - type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE); - if (type == ShareType.FEDERATED.getValue()) { - fedCount++; - } - } - assertTrue(fedCount > 0); - } catch (JSONException e) { - AssertionFailedError afe = new AssertionFailedError(e.getLocalizedMessage()); - afe.setStackTrace(e.getStackTrace()); - throw afe; - } - - // search for 'admin' sharee from external server - expecting at least 1 result - mServerUri2 = getActivity().getString(R.string.server_base_url_2); - String remoteSharee = "admin@" + mServerUri2.split("//")[1]; - result = new GetRemoteShareesOperation(remoteSharee, 1, 50).execute(mClient); - assertTrue(result.isSuccess() && result.getData().size() > 0); - - - /// failed cases - - // search for sharees including wrong page values - result = new GetRemoteShareesOperation("@", 0, 50).execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); - - result = new GetRemoteShareesOperation("@", 1, 0).execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); - } - - @Override - protected void tearDown() throws Exception { - Log.v(LOG_TAG, "Deleting remote fixture..."); - super.tearDown(); - Log.v(LOG_TAG, "Remote fixture delete."); - } -} diff --git a/library/src/androidTest/oldTests/MoveFileTest.java b/library/src/androidTest/oldTests/MoveFileTest.java deleted file mode 100644 index 50d4922520..0000000000 --- a/library/src/androidTest/oldTests/MoveFileTest.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.util.Log; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.files.MoveRemoteFileOperation; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; -import com.owncloud.android.lib.testclient.TestActivity; - -import org.apache.commons.httpclient.HttpStatus; - -import java.io.File; - -/** - * Class to test MoveRemoteFileOperation - *

- * With this TestCase we are experimenting a bit to improve the test suite design, in two aspects: - *

- * - Reduce the dependency from the set of test cases on the "test project" needed to - * have an instrumented APK to install in the device, as required by the testing framework - * provided by Android. To get there, this class avoids calling TestActivity methods in the test - * method. - *

- * - Reduce the impact of creating a remote fixture over the Internet, while the structure of the - * TestCase is kept easy to maintain. To get this, all the tests are done in a single test method, - * granting this way that setUp and tearDown are run only once. - * - * @author David A. Velasco - */ - -//public class MoveFileTest extends AndroidTestCase { -public class MoveFileTest extends RemoteTest { - - private static final String LOG_TAG = MoveFileTest.class.getCanonicalName(); - - /// Paths to files and folders in fixture - - private static final String SRC_BASE_FOLDER = "/src/"; - private static final String TARGET_BASE_FOLDER = "/target/"; - private static final String NO_FILE = "nofile.txt"; - private static final String FILE1 = "file1.txt"; - private static final String FILE2 = "file2.txt"; - private static final String FILE3 = "file3.txt"; - private static final String FILE4 = "file4.txt"; - private static final String FILE5 = "file5.txt"; - private static final String FILE6 = "file6.txt"; - private static final String FILE7 = "file7.txt"; - private static final String EMPTY = "empty/"; - private static final String NO_FOLDER = "nofolder/"; - private static final String FOLDER1 = "folder1/"; - private static final String FOLDER2 = "folder2/"; - private static final String FOLDER3 = "folder3/"; - private static final String FOLDER4 = "folder4/"; - - private static final String SRC_PATH_TO_FILE_1 = SRC_BASE_FOLDER + FILE1; - private static final String TARGET_PATH_TO_FILE_1 = TARGET_BASE_FOLDER + FILE1; - - private static final String SRC_PATH_TO_FILE_2 = SRC_BASE_FOLDER + FILE2; - private static final String TARGET_PATH_TO_FILE_2_RENAMED = TARGET_BASE_FOLDER + "renamed_" + FILE2; - - private static final String SRC_PATH_TO_FILE_3 = SRC_BASE_FOLDER + FILE3; - private static final String SRC_PATH_TO_FILE_3_RENAMED = SRC_BASE_FOLDER + "renamed_" + FILE3; - - private static final String SRC_PATH_TO_FILE_4 = SRC_BASE_FOLDER + FILE4; - - private static final String SRC_PATH_TO_FILE_5 = SRC_BASE_FOLDER + FILE5; - - private static final String SRC_PATH_TO_FILE_6 = SRC_BASE_FOLDER + FILE6; - - private static final String SRC_PATH_TO_FILE_7 = SRC_BASE_FOLDER + FILE7; - - private static final String SRC_PATH_TO_NON_EXISTENT_FILE = SRC_BASE_FOLDER + NO_FILE; - - private static final String SRC_PATH_TO_EMPTY_FOLDER = SRC_BASE_FOLDER + EMPTY; - private static final String TARGET_PATH_TO_EMPTY_FOLDER = TARGET_BASE_FOLDER + EMPTY; - - private static final String SRC_PATH_TO_FULL_FOLDER_1 = SRC_BASE_FOLDER + FOLDER1; - private static final String TARGET_PATH_TO_FULL_FOLDER_1 = TARGET_BASE_FOLDER + FOLDER1; - - private static final String SRC_PATH_TO_FULL_FOLDER_2 = SRC_BASE_FOLDER + FOLDER2; - - private static final String TARGET_PATH_TO_FULL_FOLDER_2_RENAMED = TARGET_BASE_FOLDER + "renamed_" + FOLDER2; - - private static final String SRC_PATH_TO_FULL_FOLDER_3 = SRC_BASE_FOLDER + FOLDER3; - private static final String SRC_PATH_TO_FULL_FOLDER_4 = SRC_BASE_FOLDER + FOLDER4; - - private static final String SRC_PATH_TO_FULL_FOLDER_3_RENAMED = SRC_BASE_FOLDER + "renamed_" + FOLDER3; - - private static final String TARGET_PATH_RENAMED_WITH_INVALID_CHARS = SRC_BASE_FOLDER + "renamed:??_" + FILE6; - - private static final String TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4 = TARGET_BASE_FOLDER + FOLDER4; - - private static final String TARGET_PATH_TO_NON_EXISTENT_FILE = TARGET_BASE_FOLDER + NO_FILE; - - private static final String TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER = TARGET_BASE_FOLDER + NO_FOLDER + FILE5; - - private static final String TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7 = TARGET_BASE_FOLDER + FILE7; - - private static final String[] FOLDERS_IN_FIXTURE = { - SRC_PATH_TO_EMPTY_FOLDER, - - SRC_PATH_TO_FULL_FOLDER_1, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2 + FOLDER2, - - SRC_PATH_TO_FULL_FOLDER_2, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2 + FOLDER2, - - SRC_PATH_TO_FULL_FOLDER_3, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER2, - - SRC_PATH_TO_FULL_FOLDER_4, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2 + FOLDER1, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2 + FOLDER2, - - TARGET_BASE_FOLDER, - TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4 - }; - - private static final String[] FILES_IN_FIXTURE = { - SRC_PATH_TO_FILE_1, - SRC_PATH_TO_FILE_2, - SRC_PATH_TO_FILE_3, - SRC_PATH_TO_FILE_4, - SRC_PATH_TO_FILE_5, - - SRC_PATH_TO_FULL_FOLDER_1 + FILE1, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2 + FILE1, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2 + FILE2, - SRC_PATH_TO_FULL_FOLDER_1 + FOLDER2 + FOLDER2 + FILE2, - - SRC_PATH_TO_FULL_FOLDER_2 + FILE1, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2 + FILE1, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2 + FILE2, - SRC_PATH_TO_FULL_FOLDER_2 + FOLDER2 + FOLDER2 + FILE2, - - SRC_PATH_TO_FULL_FOLDER_3 + FILE1, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FILE1, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FILE2, - SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER2 + FILE2, - - SRC_PATH_TO_FULL_FOLDER_4 + FILE1, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2 + FILE1, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2 + FILE2, - SRC_PATH_TO_FULL_FOLDER_4 + FOLDER2 + FOLDER2 + FILE2, - - TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7 - }; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - Log.v(LOG_TAG, "Setting up the remote fixture..."); - - RemoteOperationResult result; - for (String folderPath : FOLDERS_IN_FIXTURE) { - result = mActivity.createFolder(mBaseFolderPath + folderPath, true); - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - } - - File txtFile = getFile(TestActivity.ASSETS__TEXT_FILE_NAME); - for (String filePath : FILES_IN_FIXTURE) { - result = mActivity.uploadFile(txtFile.getAbsolutePath(), mBaseFolderPath + filePath, "txt/plain", null); - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - } - - Log.v(LOG_TAG, "Remote fixture created."); - } - - - /** - * Test move folder - */ - public void testMoveRemoteFileOperation() { - Log.v(LOG_TAG, "testMoveFolder in"); - - /// successful cases - - // move file - MoveRemoteFileOperation moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_1, - mBaseFolderPath + TARGET_PATH_TO_FILE_1, - false - ); - RemoteOperationResult result = moveOperation.execute(mClient); - assertTrue("move file", result.isSuccess()); - - // move & rename file, different location - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_2, - mBaseFolderPath + TARGET_PATH_TO_FILE_2_RENAMED, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move & rename file, different location", result.isSuccess()); - - // move & rename file, same location (rename file) - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_3, - mBaseFolderPath + SRC_PATH_TO_FILE_3_RENAMED, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move & rename file, same location (rename file)", result.isSuccess()); - - // move empty folder - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER, - mBaseFolderPath + TARGET_PATH_TO_EMPTY_FOLDER, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move empty folder", result.isSuccess()); - - // move non-empty folder - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_1, - mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_1, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move non-empty folder", result.isSuccess()); - - // move & rename folder, different location - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_2, - mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move & rename folder, different location", result.isSuccess()); - - // move & rename folder, same location (rename folder) - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3, - mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3_RENAMED, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move & rename folder, same location (rename folder)", result.isSuccess()); - - // move for nothing (success, but no interaction with network) - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_4, - mBaseFolderPath + SRC_PATH_TO_FILE_4, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move for nothing (success, but no interaction with network)", result.isSuccess()); - - // move overwriting - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_4, - mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, - true - ); - result = moveOperation.execute(mClient); - assertTrue("move overwriting", result.isSuccess()); - - - /// Failed cases - - // file to move does not exist - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_NON_EXISTENT_FILE, - mBaseFolderPath + TARGET_PATH_TO_NON_EXISTENT_FILE, - false - ); - result = moveOperation.execute(mClient); - assertTrue("file to move does not exist", result.getCode() == ResultCode.FILE_NOT_FOUND); - - // folder to move into does no exist - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_5, - mBaseFolderPath + TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, - false - ); - result = moveOperation.execute(mClient); - assertTrue("folder to move into does no exist", result.getHttpCode() == HttpStatus.SC_CONFLICT); - - // target location (renaming) has invalid characters - mActivity.getClient().setOwnCloudVersion(null); - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_6, - mBaseFolderPath + TARGET_PATH_RENAMED_WITH_INVALID_CHARS, - false - ); - result = moveOperation.execute(mClient); - assertTrue("target location (renaming) has invalid characters", result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - mActivity.getClient().setOwnCloudVersion(OwnCloudVersion.nextcloud_10); - - // name collision - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_PATH_TO_FILE_7, - mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, - false - ); - result = moveOperation.execute(mClient); - assertTrue("name collision", result.getCode() == ResultCode.INVALID_OVERWRITE); - - // move a folder into a descendant - moveOperation = new MoveRemoteFileOperation( - mBaseFolderPath + SRC_BASE_FOLDER, - mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER, - false - ); - result = moveOperation.execute(mClient); - assertTrue("move a folder into a descendant", result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT); - } - - @Override - protected void tearDown() throws Exception { - Log.v(LOG_TAG, "Deleting remote fixture..."); - - String[] mPathsToCleanUp = { - mBaseFolderPath + SRC_BASE_FOLDER, - mBaseFolderPath + TARGET_BASE_FOLDER - }; - - for (String path : mPathsToCleanUp) { - RemoteOperationResult removeResult = mActivity.removeFile(path); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - super.tearDown(); - - Log.v(LOG_TAG, "Remote fixture delete."); - } -} diff --git a/library/src/androidTest/oldTests/OwnCloudClientTest.java b/library/src/androidTest/oldTests/OwnCloudClientTest.java deleted file mode 100644 index c6435ad9af..0000000000 --- a/library/src/androidTest/oldTests/OwnCloudClientTest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.net.Uri; -import android.test.AndroidTestCase; -import android.util.Log; - -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.OwnCloudCredentials; -import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.accounts.AccountUtils; -import com.owncloud.android.lib.common.network.NetworkUtils; -import com.owncloud.android.lib.testclient.R; - -import junit.framework.AssertionFailedError; - -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.methods.HeadMethod; -import org.apache.jackrabbit.webdav.DavConstants; -import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; - -import java.io.IOException; -import java.io.InputStream; -import java.net.SocketTimeoutException; - - -/** - * Unit test for OwnCloudClient - * - * @author David A. Velasco - */ -public class OwnCloudClientTest extends AndroidTestCase { - - private static final String TAG = OwnCloudClientTest.class.getSimpleName(); - - private Uri mServerUri; - private String mUsername; - private String mPassword; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mServerUri = Uri.parse(getContext().getString(R.string.server_base_url)); - mUsername = getContext().getString(R.string.username); - mPassword = getContext().getString(R.string.password); - } - - - public void testConstructor() { - try { - new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager(), false); - throw new AssertionFailedError("Accepted NULL parameter"); - } catch (IllegalArgumentException e) { - assertTrue("Expected exception passing NULL baseUri", true); - } catch (Exception e) { - assertTrue("Unexpected exception", false); - } - - try { - new OwnCloudClient(mServerUri, null, false); - throw new AssertionFailedError("Accepted NULL parameter"); - - } catch (IllegalArgumentException e) { - assertTrue("Expected exception passing NULL connectionMgr", true); - } catch (Exception e) { - assertTrue("Unexpected exception passing NULL connectionMgr", false); - } - - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - assertNotNull("OwnCloudClient instance not built", client); - } - - - public void testGetSetCredentials() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - - assertNotNull("Returned NULL credentials", client.getCredentials()); - assertEquals("Not instanced without credentials", client.getCredentials(), - OwnCloudCredentialsFactory.getAnonymousCredentials()); - - OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials("user", "pass"); - client.setCredentials(credentials); - assertEquals("Basic credentials not set", credentials, client.getCredentials()); - - credentials = OwnCloudCredentialsFactory.newBearerCredentials("bearerToken"); - client.setCredentials(credentials); - assertEquals("Bearer credentials not set", credentials, client.getCredentials()); - - credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("user", "samlSessionCookie=124"); - client.setCredentials(credentials); - assertEquals("SAML2 session credentials not set", credentials, client.getCredentials()); - } - - public void testExecuteMethodWithTimeouts() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - int connectionTimeout = client.getConnectionTimeout(); - int readTimeout = client.getDataTimeout(); - - HeadMethod head = new HeadMethod(client.getWebdavUri() + "/"); - try { - client.executeMethod(head, 1, 1000); - throw new AssertionFailedError("Completed HEAD with impossible read timeout"); - } catch (ConnectTimeoutException | SocketTimeoutException e) { - Log.e("OwnCloudClientTest", "EXCEPTION", e); - assertTrue("Expected exception " + e.getLocalizedMessage(), true); - - } catch (IOException e) { - assertFalse("Unexpected exception", false); - } finally { - head.releaseConnection(); - } - - assertEquals("Connection timeout was changed for future requests", connectionTimeout, - client.getConnectionTimeout()); - assertEquals("Read timeout was changed for future requests", readTimeout, client.getDataTimeout()); - - try { - client.executeMethod(head, 1000, 1); - throw new AssertionFailedError("Completed HEAD with impossible connection timeout"); - - } catch (ConnectTimeoutException | SocketTimeoutException e) { - Log.e("OwnCloudClientTest", "EXCEPTION", e); - assertTrue("Expected exception " + e.getLocalizedMessage(), true); - } catch (Exception e) { - Log.e("OwnCloudClientTest", "EXCEPTION", e); - assertTrue("Unexpected exception " + e.getLocalizedMessage(), false); - } finally { - head.releaseConnection(); - } - - assertEquals("Connection timeout was changed for future requests", connectionTimeout, - client.getConnectionTimeout()); - assertEquals("Read timeout was changed for future requests", readTimeout, client.getDataTimeout()); - } - - - public void testExecuteMethod() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - HeadMethod head = new HeadMethod(client.getWebdavUri() + "/"); - int status; - try { - status = client.executeMethod(head); - assertTrue("Wrong status code returned: " + status, status > 99 && status < 600); - - } catch (IOException e) { - Log.e(TAG, "Exception in HEAD method execution", e); - // TODO - make it fail? ; try several times, and make it fail if none - // is right? - - } finally { - head.releaseConnection(); - } - } - - public void testExhaustResponse() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - - PropFindMethod propfind = null; - try { - propfind = new PropFindMethod(client.getWebdavUri() + "/", DavConstants.PROPFIND_ALL_PROP, - DavConstants.DEPTH_0); - client.executeMethod(propfind); - InputStream responseBody = propfind.getResponseBodyAsStream(); - if (responseBody != null) { - client.exhaustResponse(responseBody); - - try { - int character = responseBody.read(); - assertEquals("Response body was not fully exhausted", character, -1); // -1 is acceptable - } catch (IOException e) { - // this is the preferred result - } - } else { - Log.e(TAG, "Could not test exhaustResponse due to wrong response"); - // TODO - make it fail? ; try several times, and make it fail if none - // is right? - } - } catch (IOException e) { - Log.e(TAG, "Exception in PROPFIND method execution", e); - // TODO - make it fail? ; try several times, and make it fail if none - // is right? - } finally { - if (propfind != null) { - propfind.releaseConnection(); - } - } - - client.exhaustResponse(null); // must run with no exception - } - - public void testGetSetDefaultTimeouts() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - - int oldDataTimeout = client.getDataTimeout(); - int oldConnectionTimeout = client.getConnectionTimeout(); - - client.setDefaultTimeouts(oldDataTimeout + 1000, oldConnectionTimeout + 1000); - assertEquals("Data timeout not set", oldDataTimeout + 1000, client.getDataTimeout()); - assertEquals("Connection timeout not set", oldConnectionTimeout + 1000, client.getConnectionTimeout()); - - client.setDefaultTimeouts(0, 0); - assertEquals("Zero data timeout not set", 0, client.getDataTimeout()); - assertEquals("Zero connection timeout not set", 0, client.getConnectionTimeout()); - - client.setDefaultTimeouts(-1, -1); - assertEquals("Negative data timeout not ignored", 0, client.getDataTimeout()); - assertEquals("Negative connection timeout not ignored", 0, client.getConnectionTimeout()); - - client.setDefaultTimeouts(-1, 1000); - assertEquals("Negative data timeout not ignored", 0, client.getDataTimeout()); - assertEquals("Connection timeout not set", 1000, client.getConnectionTimeout()); - - client.setDefaultTimeouts(1000, -1); - assertEquals("Data timeout not set", 1000, client.getDataTimeout()); - assertEquals("Negative connection timeout not ignored", 1000, client.getConnectionTimeout()); - } - - public void testGetWebdavUri() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - client.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials("fakeToken")); - Uri webdavUri = client.getWebdavUri(); - assertTrue("WebDAV URI does not point to the right entry point for OAuth2 authenticated servers", - webdavUri.getPath().endsWith(AccountUtils.ODAV_PATH)); - assertTrue("WebDAV URI is not a sub path of base URI", webdavUri.getAuthority().equals(mServerUri.getAuthority()) - && webdavUri.getPath().startsWith(mServerUri.getPath())); - - client.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(mUsername, mPassword)); - webdavUri = client.getWebdavUri(); - assertTrue("WebDAV URI does not point to the right entry point", - webdavUri.getPath().endsWith(AccountUtils.WEBDAV_PATH_4_0)); - PropFindMethod propfind = null; - - try { - propfind = new PropFindMethod(webdavUri + "/", DavConstants.PROPFIND_ALL_PROP, DavConstants.DEPTH_0); - int status = client.executeMethod(propfind); - assertEquals("WebDAV request did not work on WebDAV URI", HttpStatus.SC_MULTI_STATUS, status); - - } catch (IOException e) { - Log.e(TAG, "Exception in PROPFIND method execution", e); - // TODO - make it fail? ; try several times, and make it fail if none - // is right? - - } finally { - if (propfind != null) { - propfind.releaseConnection(); - } - } - } - - public void testGetSetBaseUri() { - OwnCloudClient client = new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(), false); - assertEquals("Returned base URI different that URI passed to constructor", mServerUri, client.getBaseUri()); - - Uri otherUri = Uri.parse("https://whatever.com/basePath/here"); - client.setBaseUri(otherUri); - assertEquals("Returned base URI different that URI passed to constructor", otherUri, client.getBaseUri()); - - try { - client.setBaseUri(null); - throw new AssertionFailedError("Accepted NULL parameter"); - } catch (IllegalArgumentException e) { - assertTrue("Unexpected exception passing NULL base URI", true); - } catch (Exception e) { - assertTrue("Unexpected exception passing NULL base URI", false); - } - } - -// public void testGetCookiesString() { - // TODO implement test body - /*public String getCookiesString(){ - Cookie[] cookies = getState().getCookies(); - String cookiesString =""; - for (Cookie cookie: cookies) { - cookiesString = cookiesString + cookie.toString() + ";"; - - logCookie(cookie); - } - - return cookiesString; - - } - */ -// } - - -// public void testSetFollowRedirects() { -// // TODO - to implement this test we need a redirected server -// } - -} diff --git a/library/src/androidTest/oldTests/ReadFileTest.java b/library/src/androidTest/oldTests/ReadFileTest.java deleted file mode 100644 index e370117e48..0000000000 --- a/library/src/androidTest/oldTests/ReadFileTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; - -/** - * Class to test Read File Operation - * - * @author masensio - * @author David A. Velasco - */ - -public class ReadFileTest extends RemoteTest { - - private static final String LOG_TAG = ReadFileTest.class.getCanonicalName(); - - private String FILE_PATH = "/fileToRead.txt"; - private String mFullPath2File; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - setActivityInitialTouchMode(false); - mFullPath2File = mBaseFolderPath + FILE_PATH; - - File textFile = getFile(TestActivity.ASSETS__TEXT_FILE_NAME); - RemoteOperationResult uploadResult = mActivity.uploadFile(textFile.getAbsolutePath(), mFullPath2File, - "txt/plain", null); - - if (!uploadResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, uploadResult); - } - } - - /** - * Test Read File - */ - public void testReadFile() { - RemoteOperationResult result = mActivity.readFile(mFullPath2File); - assertTrue(result.getData() != null && result.getData().size() == 1); - assertTrue(result.isSuccess()); - // TODO check more properties of the result - } - - @Override - protected void tearDown() throws Exception { - RemoteOperationResult removeResult = mActivity.removeFile(mFullPath2File); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - - super.tearDown(); - } -} diff --git a/library/src/androidTest/oldTests/ReadFolderTest.java b/library/src/androidTest/oldTests/ReadFolderTest.java deleted file mode 100644 index f49096c30d..0000000000 --- a/library/src/androidTest/oldTests/ReadFolderTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; - -/** - * Class to test Read Folder Operation - * - * @author masensio - * @author David A. Velasco - */ - -public class ReadFolderTest extends RemoteTest { - - private static final String LOG_TAG = ReadFolderTest.class.getCanonicalName(); - - private static final String FOLDER_PATH = "/folderToRead"; - private static final String[] FILE_PATHS = { - FOLDER_PATH + "/file1.txt", - FOLDER_PATH + "/file2.txt", - FOLDER_PATH + "/file3.txt", - }; - - - private String mFullPathToFolder; - - @Override - protected void setUp() throws Exception { - super.setUp(); - setActivityInitialTouchMode(false); - mFullPathToFolder = mBaseFolderPath + FOLDER_PATH; - - File textFile = getFile(TestActivity.ASSETS__TEXT_FILE_NAME); - RemoteOperationResult result = mActivity.createFolder(mFullPathToFolder, true); - if (result.isSuccess()) { - for (int i = 0; i < FILE_PATHS.length && result.isSuccess(); i++) { - result = mActivity.uploadFile(textFile.getAbsolutePath(), mBaseFolderPath + FILE_PATHS[i], "txt/plain", - null); - } - } - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - } - - /** - * Test Read Folder - */ - public void testReadFolder() { - RemoteOperationResult result = mActivity.readFile(mFullPathToFolder); - assertTrue(result.isSuccess()); - assertTrue(result.getData() != null && result.getData().size() > 1); - assertTrue(result.getData().size() == 4); - // TODO assert more properties about the result - } - - - @Override - protected void tearDown() throws Exception { - RemoteOperationResult removeResult = mActivity.removeFile(mFullPathToFolder); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - - super.tearDown(); - } - -} diff --git a/library/src/androidTest/oldTests/RenameFileTest.java b/library/src/androidTest/oldTests/RenameFileTest.java deleted file mode 100644 index 41d37e864e..0000000000 --- a/library/src/androidTest/oldTests/RenameFileTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.files.FileUtils; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; - -/** - * Class to test Rename File Operation - * - * @author masensio - */ - -public class RenameFileTest extends RemoteTest { - - private static final String LOG_TAG = RenameFileTest.class.getCanonicalName(); - - /* Folder data to rename. This folder must exist on the account */ - private static final String OLD_FOLDER_NAME = "folderToRename"; - private static final String OLD_FOLDER_PATH = FileUtils.PATH_SEPARATOR + OLD_FOLDER_NAME; - private static final String NEW_FOLDER_NAME = "renamedFolder"; - private static final String NEW_FOLDER_PATH = FileUtils.PATH_SEPARATOR + NEW_FOLDER_NAME; - - /* File data to rename. This file must exist on the account */ - private static final String OLD_FILE_NAME = "fileToRename.png"; - private static final String OLD_FILE_PATH = FileUtils.PATH_SEPARATOR + OLD_FILE_NAME; - private static final String NEW_FILE_NAME = "renamedFile.png"; - private static final String NEW_FILE_PATH = FileUtils.PATH_SEPARATOR + NEW_FILE_NAME; - - - private String mToCleanUpInServer; - private String mFullPath2OldFolder; - private String mFullPath2NewFolder; - private String mFullPath2OldFile; - private String mFullPath2NewFile; - - @Override - protected void setUp() throws Exception { - super.setUp(); - setActivityInitialTouchMode(false); - mFullPath2OldFolder = mBaseFolderPath + OLD_FOLDER_PATH; - mFullPath2NewFolder = mBaseFolderPath + NEW_FOLDER_PATH; - mFullPath2OldFile = mBaseFolderPath + OLD_FILE_PATH; - mFullPath2NewFile = mBaseFolderPath + NEW_FILE_PATH; - - createTestFolder(); - uploadTestFile(); - - mToCleanUpInServer = null; - } - - /** - * Test Rename Folder - */ - public void testRenameFolder() { - - mToCleanUpInServer = mFullPath2OldFolder; - RemoteOperationResult result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME, true); - assertTrue(result.isSuccess()); - mToCleanUpInServer = mFullPath2NewFolder; - } - - /** - * Test Rename Folder with forbidden characters : \ < > : " | ? * - */ - public void testRenameFolderForbiddenCharsOnNewServer() throws Exception { - RemoteOperationResult result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, - NEW_FOLDER_NAME + "\\", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "<", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + ">", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + ":", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "\"", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "|", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "?", true); - assertTrue(result.isSuccess()); - - createTestFolder(); - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "*", true); - assertTrue(result.isSuccess()); - } - - /** - * Test Rename Folder with forbidden characters : \ < > : " | ? * - */ - public void testRenameFolderForbiddenCharsOnOlderServer() { - mActivity.getClient().setOwnCloudVersion(null); - - RemoteOperationResult result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, - NEW_FOLDER_NAME + "\\", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "<", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + ">", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + ":", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "\"", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "|", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "?", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FOLDER_NAME, mFullPath2OldFolder, NEW_FOLDER_NAME + "*", true); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - } - - /** - * Test Rename File - */ - public void testRenameFile() { - mToCleanUpInServer = mFullPath2OldFile; - RemoteOperationResult result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - mToCleanUpInServer = mFullPath2NewFile; - } - - - /** - * Test Rename Folder with forbidden characters: \ < > : " | ? * - */ - public void testRenameFileForbiddenCharsOnOlderServer() { - mActivity.getClient().setOwnCloudVersion(null); - RemoteOperationResult result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "\\" + NEW_FILE_NAME, - false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "<" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, ">" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, ":" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "\"" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "|" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "?" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "*" + NEW_FILE_NAME, false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - } - - /** - * Test Rename Folder with forbidden characters: \ < > : " | ? * - */ - public void testRenameFileForbiddenCharsOnNewServer() throws Exception { - RemoteOperationResult result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "\\" + NEW_FILE_NAME, - false); - assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); - - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "<" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, ">" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, ":" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "\"" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "|" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "?" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - - uploadTestFile(); - result = mActivity.renameFile(OLD_FILE_NAME, mFullPath2OldFile, "*" + NEW_FILE_NAME, false); - assertTrue(result.isSuccess()); - } - - @Override - protected void tearDown() throws Exception { - if (mToCleanUpInServer != null) { - RemoteOperationResult removeResult = mActivity.removeFile(mToCleanUpInServer); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - super.tearDown(); - } - - private void uploadTestFile() throws Exception { - File imageFile = getFile(TestActivity.ASSETS__IMAGE_FILE_NAME); - RemoteOperationResult result = mActivity.uploadFile(imageFile.getAbsolutePath(), mFullPath2OldFile, - "image/png", null); - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - } - - private void createTestFolder() throws Exception { - RemoteOperationResult result = mActivity.createFolder(mFullPath2OldFolder, true); - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - } -} diff --git a/library/src/androidTest/oldTests/SimpleFactoryManagerTest.java b/library/src/androidTest/oldTests/SimpleFactoryManagerTest.java deleted file mode 100644 index d93f640c50..0000000000 --- a/library/src/androidTest/oldTests/SimpleFactoryManagerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.net.Uri; -import android.test.AndroidTestCase; - -import com.owncloud.android.lib.common.OwnCloudAccount; -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.SimpleFactoryManager; -import com.owncloud.android.lib.testclient.R; - -import junit.framework.AssertionFailedError; - -/** - * Unit test for SimpleFactoryManager - * - * @author David A. Velasco - */ - -public class SimpleFactoryManagerTest extends AndroidTestCase { - - private SimpleFactoryManager mSFMgr; - - private OwnCloudAccount mValidAccount; - private OwnCloudAccount mAnonymousAccount; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mSFMgr = new SimpleFactoryManager(); - Uri serverUri = Uri.parse(getContext().getString(R.string.server_base_url)); - String username = getContext().getString(R.string.username); - - mValidAccount = new OwnCloudAccount(serverUri, OwnCloudCredentialsFactory.newBasicCredentials( - username, getContext().getString(R.string.password))); - - mAnonymousAccount = new OwnCloudAccount(serverUri, OwnCloudCredentialsFactory.getAnonymousCredentials()); - } - - public void testGetClientFor() { - try { - OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext()); - - assertNotSame("Got same client instances for same account", client, mSFMgr.getClientFor(mValidAccount, - getContext())); - - assertNotSame("Got same client instances for different accounts", client, - mSFMgr.getClientFor(mAnonymousAccount, getContext())); - - } catch (Exception e) { - throw new AssertionFailedError("Exception getting client for account: " + e.getMessage()); - } - // TODO harder tests - } - - public void testRemoveClientFor() { - try { - OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext()); - mSFMgr.removeClientFor(mValidAccount); - assertNotSame("Got same client instance after removing it from manager", - client, mSFMgr.getClientFor(mValidAccount, getContext())); - } catch (Exception e) { - throw new AssertionFailedError("Exception getting client for account: " + e.getMessage()); - } - // TODO harder tests - } - - -// public void testSaveAllClients() { - // TODO implement test; - // or refactor saveAllClients() method out of OwnCloudClientManager to make - // it independent of AccountManager -// } - -} diff --git a/library/src/androidTest/oldTests/SingleSessionManagerTest.java b/library/src/androidTest/oldTests/SingleSessionManagerTest.java deleted file mode 100644 index 6452ef73da..0000000000 --- a/library/src/androidTest/oldTests/SingleSessionManagerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.net.Uri; -import android.test.AndroidTestCase; - -import com.owncloud.android.lib.common.OwnCloudAccount; -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.SingleSessionManager; -import com.owncloud.android.lib.testclient.R; - -import junit.framework.AssertionFailedError; - -/** - * Unit test for SingleSessionManager - * - * @author David A. Velasco - */ -public class SingleSessionManagerTest extends AndroidTestCase { - - private SingleSessionManager mSSMgr; - - private OwnCloudAccount mValidAccount; - private OwnCloudAccount mAnonymousAccount; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mSSMgr = new SingleSessionManager(); - Uri serverUri = Uri.parse(getContext().getString(R.string.server_base_url)); - String username = getContext().getString(R.string.username); - - mValidAccount = new OwnCloudAccount(serverUri, OwnCloudCredentialsFactory.newBasicCredentials(username, - getContext().getString(R.string.password))); - - mAnonymousAccount = new OwnCloudAccount(serverUri, OwnCloudCredentialsFactory.getAnonymousCredentials()); - } - - public void testGetClientFor() { - try { - OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext()); - OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext()); - - assertNotSame("Got same client instances for different accounts", client1, client2); - assertSame("Got different client instances for same account", - client1, mSSMgr.getClientFor(mValidAccount, getContext())); - } catch (Exception e) { - throw new AssertionFailedError("Exception getting client for account: " + e.getMessage()); - } - - // TODO harder tests - } - - public void testRemoveClientFor() { - try { - OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext()); - mSSMgr.removeClientFor(mValidAccount); - assertNotSame("Got same client instance after removing it from manager", - client1, mSSMgr.getClientFor(mValidAccount, getContext())); - } catch (Exception e) { - throw new AssertionFailedError("Exception getting client for account: " + e.getMessage()); - } - - // TODO harder tests - } - - -// public void testSaveAllClients() { - // TODO implement test; - // or refactor saveAllClients() method out of OwnCloudClientManager to make - // it independent of AccountManager -// } -} diff --git a/library/src/androidTest/oldTests/UpdatePrivateShareTest.java b/library/src/androidTest/oldTests/UpdatePrivateShareTest.java deleted file mode 100644 index 9a480ff75a..0000000000 --- a/library/src/androidTest/oldTests/UpdatePrivateShareTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.util.Log; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.resources.shares.OCShare; -import com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation; -import com.owncloud.android.lib.resources.shares.ShareType; -import com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; - -/** - * Class to test UpdateRemoteShareOperation - * with private shares - */ -public class UpdatePrivateShareTest extends RemoteTest { - private static final String LOG_TAG = UpdatePrivateShareTest.class.getCanonicalName(); - - /* File to share and update */ - private static final String FILE_TO_SHARE = "/fileToShare.txt"; - - /* Folder to share and update */ - private static final String FOLDER_TO_SHARE = "/folderToShare"; - - /* Sharees */ - private static final String USER_SHAREE = "admin"; - private static final String GROUP_SHAREE = "admin"; - - private String mFullPath2FileToShare; - private String mFullPath2FolderToShare; - - private OCShare mFileShare; - private OCShare mFolderShare; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - Log.v(LOG_TAG, "Setting up the remote fixture..."); - - // Upload the file - mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; - - File textFile = getFile(TestActivity.ASSETS__TEXT_FILE_NAME); - RemoteOperationResult result = getActivity().uploadFile(textFile.getAbsolutePath(), mFullPath2FileToShare, - "txt/plain", null); - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - - // Share the file privately with other user - result = getActivity().createShare(mFullPath2FileToShare, ShareType.USER, USER_SHAREE, false, "", - OCShare.MAXIMUM_PERMISSIONS_FOR_FILE); - - if (result.isSuccess()) { - mFileShare = (OCShare) result.getData().get(0); - } else { - mFileShare = null; - } - - // Create the folder - mFullPath2FolderToShare = mBaseFolderPath + FOLDER_TO_SHARE; - result = getActivity().createFolder(mFullPath2FolderToShare, true); - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - - // Share the folder privately with a group - result = getActivity().createShare(mFullPath2FolderToShare, ShareType.GROUP, GROUP_SHAREE, false, "", - OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER); - - if (result.isSuccess()) { - mFolderShare = (OCShare) result.getData().get(0); - } else { - mFolderShare = null; - } - - Log.v(LOG_TAG, "Remote fixture created."); - } - - public void testUpdateSharePermissions() { - Log.v(LOG_TAG, "testUpdateSharePermissions in"); - - if (mFileShare != null) { - /// successful tests - // Update Share permissions on a shared file - UpdateRemoteShareOperation updateShare = new UpdateRemoteShareOperation(mFileShare.getRemoteId()); - updateShare.setPermissions(OCShare.READ_PERMISSION_FLAG); // minimum permissions - RemoteOperationResult result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - // Update Share permissions on a shared folder - updateShare = new UpdateRemoteShareOperation(mFolderShare.getRemoteId()); - updateShare.setPermissions(OCShare.READ_PERMISSION_FLAG + OCShare.DELETE_PERMISSION_FLAG); - result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - - /// unsuccessful tests - // Update Share with invalid permissions - updateShare = new UpdateRemoteShareOperation(mFileShare.getRemoteId()); - // greater than maximum value - updateShare.setPermissions(OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER + 1); - result = updateShare.execute(mClient); - assertFalse(result.isSuccess()); - - // Unshare the file before next unsuccessful tests - RemoveRemoteShareOperation unshare = new RemoveRemoteShareOperation((int) mFileShare.getRemoteId()); - result = unshare.execute(mClient); - - if (result.isSuccess()) { - // Update Share permissions on unknown share - UpdateRemoteShareOperation updateNoShare = new UpdateRemoteShareOperation(mFileShare.getRemoteId()); - updateNoShare.setPermissions(OCShare.READ_PERMISSION_FLAG); // minimum permissions - result = updateNoShare.execute(mClient); - assertFalse(result.isSuccess()); - } - } - } - - @Override - protected void tearDown() throws Exception { - Log.v(LOG_TAG, "Deleting remote fixture..."); - - if (mFullPath2FileToShare != null) { - RemoteOperationResult removeResult = getActivity().removeFile(mFullPath2FileToShare); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - if (mFullPath2FolderToShare != null) { - RemoteOperationResult removeResult = getActivity().removeFile(mFullPath2FolderToShare); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - super.tearDown(); - Log.v(LOG_TAG, "Remote fixture delete."); - } -} diff --git a/library/src/androidTest/oldTests/UpdatePublicShareTest.java b/library/src/androidTest/oldTests/UpdatePublicShareTest.java deleted file mode 100644 index 7e6d7a6bc9..0000000000 --- a/library/src/androidTest/oldTests/UpdatePublicShareTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import android.util.Log; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.resources.shares.OCShare; -import com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation; -import com.owncloud.android.lib.resources.shares.ShareType; -import com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; -import java.util.Calendar; - -/** - * Class to test UpdateRemoteShareOperation - * with public shares - */ -public class UpdatePublicShareTest extends RemoteTest { - private static final String LOG_TAG = UpdatePublicShareTest.class.getCanonicalName(); - - /* File to share and update.*/ - private static final String FILE_TO_SHARE = "/fileToShare.txt"; - - /* Folder to share and update */ - private static final String FOLDER_TO_SHARE = "/folderToShare"; - - // Data for tests - private static final String PASSWORD = "password"; - private static final String PASS_SPECIAL_CHARS = "p@ssw�rd"; - - private String mFullPath2FileToShare; - private String mFullPath2FolderToShare; - - private OCShare mShare; - private OCShare mFolderShare; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - Log.v(LOG_TAG, "Setting up the remote fixture..."); - - // Upload the file - mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; - - File textFile = getFile(TestActivity.ASSETS__TEXT_FILE_NAME); - RemoteOperationResult result = getActivity().uploadFile(textFile.getAbsolutePath(), mFullPath2FileToShare, - "txt/plain", null); - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - - // Share the file with a public link - result = getActivity().createShare(mFullPath2FileToShare, ShareType.PUBLIC_LINK, "", false, "", - OCShare.READ_PERMISSION_FLAG); - - if (result.isSuccess()) { - mShare = (OCShare) result.getData().get(0); - } else { - Utils.logAndThrow(LOG_TAG, result); - } - - // Create the folder - mFullPath2FolderToShare = mBaseFolderPath + FOLDER_TO_SHARE; - result = getActivity().createFolder(mFullPath2FolderToShare, true); - - if (!result.isSuccess()) { - Utils.logAndThrow(LOG_TAG, result); - } - - // Share the folder publicly via link - result = getActivity().createShare(mFullPath2FolderToShare, ShareType.PUBLIC_LINK, "", false, "", - OCShare.READ_PERMISSION_FLAG); - - if (result.isSuccess()) { - mFolderShare = (OCShare) result.getData().get(0); - } else { - Utils.logAndThrow(LOG_TAG, result); - } - - Log.v(LOG_TAG, "Remote fixtures created."); - } - - public void testUpdatePublicShare() { - Log.v(LOG_TAG, "testUpdatePublicShare in"); - - if (mShare != null) { - // successful tests - // Update Share with password - UpdateRemoteShareOperation updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - updateShare.setPassword(PASSWORD); - RemoteOperationResult result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - // Update Share with password with special characters - updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - updateShare.setPassword(PASS_SPECIAL_CHARS); - result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - // Update Share with expiration date - updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DAY_OF_MONTH, 7); - long expirationDateInMillis = calendar.getTimeInMillis(); - updateShare.setExpirationDate(expirationDateInMillis); - result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - // Update the Folder Share with edit permission - updateShare = new UpdateRemoteShareOperation(mFolderShare.getRemoteId()); - updateShare.setPublicUpload(true); - result = updateShare.execute(mClient); - assertTrue(result.isSuccess()); - - // unsuccessful test - // Update Share with expiration date in the past - updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - calendar.set(Calendar.YEAR, 2014); - expirationDateInMillis = calendar.getTimeInMillis(); - updateShare.setExpirationDate(expirationDateInMillis); - result = updateShare.execute(mClient); - assertFalse(result.isSuccess()); - - // Try to update the file Share with edit permission - updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - updateShare.setPublicUpload(true); - result = updateShare.execute(mClient); - assertFalse(result.isSuccess()); - - // Unshare the file before the unsuccessful tests - result = new RemoveRemoteShareOperation((int) mShare.getRemoteId()).execute(mClient); - - if (result.isSuccess()) { - // Update Share with password on unknown share - UpdateRemoteShareOperation updateNoShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - updateNoShare.setPassword(PASSWORD); - result = updateNoShare.execute(mClient); - assertFalse(result.isSuccess()); - - // Update Share with expiration date on unknown share - updateNoShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DAY_OF_MONTH, 7); - expirationDateInMillis = cal.getTimeInMillis(); - updateNoShare.setExpirationDate(expirationDateInMillis); - result = updateNoShare.execute(mClient); - assertFalse(result.isSuccess()); - } - } - } - - @Override - protected void tearDown() throws Exception { - Log.v(LOG_TAG, "Deleting remote fixture..."); - - if (mFullPath2FileToShare != null) { - RemoteOperationResult removeResult = getActivity().removeFile(mFullPath2FileToShare); - - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - if (mFullPath2FolderToShare != null) { - RemoteOperationResult removeResult = getActivity().removeFile(mFullPath2FolderToShare); - - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - - super.tearDown(); - Log.v(LOG_TAG, "Remote fixture delete."); - } -} diff --git a/library/src/androidTest/oldTests/UploadFileTest.java b/library/src/androidTest/oldTests/UploadFileTest.java deleted file mode 100644 index c59005ff7a..0000000000 --- a/library/src/androidTest/oldTests/UploadFileTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2019 Tobias Kaminsky - * SPDX-License-Identifier: MIT - */ -package com.owncloud.android; - -import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.testclient.TestActivity; - -import java.io.File; - -/** - * Class to test Update File Operation - * - * @author masensio - * @author David A. Velasco - */ - -public class UploadFileTest extends RemoteTest { - - private static final String LOG_TAG = UploadFileTest.class.getCanonicalName(); - - private static final String UPLOAD_PATH = "/uploadedImage.png"; - - private static final String CHUNKED_UPLOAD_PATH = "/uploadedVideo.MP4"; - - private static final String FILE_NOT_FOUND_PATH = "/notFoundShouldNotBeHere.png"; - - private File mFileToUpload, mFileToUploadWithChunks; - private String mUploadedFilePath; - - @Override - protected void setUp() throws Exception { - super.setUp(); - setActivityInitialTouchMode(false); - mUploadedFilePath = null; - - mFileToUpload = getFile(TestActivity.ASSETS__IMAGE_FILE_NAME); - mFileToUploadWithChunks = getFile(TestActivity.ASSETS__VIDEO_FILE_NAME); - } - - /** - * Test Upload File without chunks - */ - public void testUploadFile() { - - String fullPath2Upload = mBaseFolderPath + UPLOAD_PATH; - RemoteOperationResult result = mActivity.uploadFile(mFileToUpload.getAbsolutePath(), fullPath2Upload, - "image/png", null); - mUploadedFilePath = fullPath2Upload; - assertTrue(result.isSuccess()); - } - - /** - * Test Upload File with chunks - */ - public void testUploadFileWithChunks() { - - String fullPath2Upload = mBaseFolderPath + CHUNKED_UPLOAD_PATH; - RemoteOperationResult result = mActivity.uploadFile(mFileToUploadWithChunks.getAbsolutePath(), fullPath2Upload, - "video/mp4", null); - mUploadedFilePath = fullPath2Upload; - assertTrue(result.isSuccess()); - } - - /** - * Test Upload Not Found File - */ - public void testUploadFileNotFound() { - String fullPath2Upload = mBaseFolderPath + FILE_NOT_FOUND_PATH; - RemoteOperationResult result = mActivity.uploadFile(FILE_NOT_FOUND_PATH, fullPath2Upload, "image/png", null); - mUploadedFilePath = fullPath2Upload; - assertFalse(result.isSuccess()); - } - - @Override - protected void tearDown() throws Exception { - if (mUploadedFilePath != null) { - RemoteOperationResult removeResult = mActivity.removeFile(mUploadedFilePath); - if (!removeResult.isSuccess()) { - Utils.logAndThrow(LOG_TAG, removeResult); - } - } - super.tearDown(); - } -} diff --git a/scripts/createDockerTestContainer.sh b/scripts/createDockerTestContainer.sh new file mode 100755 index 0000000000..6ad2af78a2 --- /dev/null +++ b/scripts/createDockerTestContainer.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Tobias Kaminsky +# SPDX-License-Identifier: MIT +# + +if [[ $# -ne 1 ]]; then + echo "please specify stable29 or master as first parameter" + exit +fi + +docker stop testNC +docker rm testNC +docker run --name=testNC ghcr.io/nextcloud/continuous-integration-shallow-server:latest & +sleep 60 + +docker cp ../.github/workflows/configServer.sh testNC:/tmp/ +docker exec testNC chmod +x /tmp/configServer.sh +docker exec testNC /tmp/configServer.sh $1 +docker cp ../.github/workflows/configNC_$1.sh testNC:/tmp/ +docker exec testNC chmod +x /tmp/configNC_$1.sh +docker exec --user www-data testNC /tmp/configNC_$1.sh + +echo "Docker IP Address is:" +docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' testNC diff --git a/scripts/runTests.sh b/scripts/runTests.sh new file mode 100755 index 0000000000..d2465b2d1d --- /dev/null +++ b/scripts/runTests.sh @@ -0,0 +1,19 @@ +# +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Tobias Kaminsky +# SPDX-License-Identifier: MIT +# + +scripts/wait_for_emulator.sh +adb logcat -c +adb logcat > logcat.txt & +./gradlew assembleDebug +./gradlew jacocoTestDebugUnitTestReport +./gradlew installDebugAndroidTest +./gradlew createDebugCoverageReport +stat=$? + +./gradlew combinedTestReport + +exit $stat diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh index c9b4a0534c..868b8aa459 100755 --- a/scripts/uploadReport.sh +++ b/scripts/uploadReport.sh @@ -19,11 +19,11 @@ URL=https://nextcloud.kaminsky.me/remote.php/dav/files/$USER/android-library-int # upload logcat log_filename=$ID"_logcat.txt.xz" log_file="${log_filename}" -upload_path="https://nextcloud.kaminsky.me/remote.php/webdav/library-logcat/$log_filename" +upload_path="https://nextcloud.kaminsky.me/remote.php/webdav/android-library-logcat/$log_filename" xz logcat.txt mv logcat.txt.xz "$log_file" curl -u "$USER:$PASS" -X PUT "$upload_path" --upload-file "$log_file" -echo >&2 "Uploaded logcat to https://www.kaminsky.me/nc-dev/library-logcat/$log_filename" +echo >&2 "Uploaded logcat to https://www.kaminsky.me/nc-dev/android-library-logcat/$log_filename" if [ $TYPE = "IT" ]; then cd library/build/reports/androidTests/connected @@ -39,7 +39,7 @@ fi find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \; find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \; -echo "Uploaded failing library tests to https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER" +echo "Uploaded failing library tests to https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER/debug/" curl -u $GIT_USERNAME:$GIT_TOKEN -X POST https://api.github.com/repos/nextcloud/android-library/issues/$PR_ID/comments -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER/debug/ \" }" exit 1