From e372414880e34d817d38c984c178402e23a73863 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 4 Apr 2024 07:19:07 +0200 Subject: [PATCH] Garm Signed-off-by: tobiasKaminsky --- .drone.yml | 369 ------------------ .github/workflows/configNC.sh | 91 +++++ .github/workflows/configServer.sh | 20 + .github/workflows/garm.yml | 115 ++++++ ...ashboardGetWidgetItemsRemoteOperationIT.kt | 8 +- .../files/ReadFileRemoteOperationIT.kt | 2 +- .../files/SearchRemoteOperationIT.java | 2 +- .../android/lib/resources/users/StatusIT.kt | 2 +- .../oldTests/DownloadFileTest.java | 116 ------ .../androidTest/oldTests/GetShareesTest.java | 175 --------- .../androidTest/oldTests/MoveFileTest.java | 354 ----------------- .../oldTests/OwnCloudClientTest.java | 297 -------------- .../androidTest/oldTests/ReadFileTest.java | 64 --- .../androidTest/oldTests/ReadFolderTest.java | 78 ---- .../androidTest/oldTests/RenameFileTest.java | 245 ------------ .../oldTests/SimpleFactoryManagerTest.java | 82 ---- .../oldTests/SingleSessionManagerTest.java | 80 ---- .../oldTests/UpdatePrivateShareTest.java | 153 -------- .../oldTests/UpdatePublicShareTest.java | 185 --------- .../androidTest/oldTests/UploadFileTest.java | 89 ----- scripts/createDockerTestContainer.sh | 34 ++ scripts/runTests.sh | 19 + scripts/uploadReport.sh | 8 +- 23 files changed, 292 insertions(+), 2296 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/configNC.sh create mode 100644 .github/workflows/configServer.sh create mode 100644 .github/workflows/garm.yml delete mode 100644 library/src/androidTest/oldTests/DownloadFileTest.java delete mode 100644 library/src/androidTest/oldTests/GetShareesTest.java delete mode 100644 library/src/androidTest/oldTests/MoveFileTest.java delete mode 100644 library/src/androidTest/oldTests/OwnCloudClientTest.java delete mode 100644 library/src/androidTest/oldTests/ReadFileTest.java delete mode 100644 library/src/androidTest/oldTests/ReadFolderTest.java delete mode 100644 library/src/androidTest/oldTests/RenameFileTest.java delete mode 100644 library/src/androidTest/oldTests/SimpleFactoryManagerTest.java delete mode 100644 library/src/androidTest/oldTests/SingleSessionManagerTest.java delete mode 100644 library/src/androidTest/oldTests/UpdatePrivateShareTest.java delete mode 100644 library/src/androidTest/oldTests/UpdatePublicShareTest.java delete mode 100644 library/src/androidTest/oldTests/UploadFileTest.java create mode 100755 scripts/createDockerTestContainer.sh create mode 100755 scripts/runTests.sh diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index d3b94ec1c0..0000000000 --- a/.drone.yml +++ /dev/null @@ -1,369 +0,0 @@ ---- -kind: pipeline -type: docker -name: test-master - -# SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-License-Identifier: MIT - -steps: -- name: test - image: ghcr.io/nextcloud/continuous-integration-android8:4 - privileged: true - environment: - LOG_USERNAME: - from_secret: LOG_USERNAME - LOG_PASSWORD: - from_secret: LOG_PASSWORD - GIT_USERNAME: - from_secret: GIT_USERNAME - GIT_TOKEN: - from_secret: GIT_TOKEN - commands: - - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 & - - sed -i s"#server#server-master#" gradle.properties - - sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt - - ./gradlew assembleDebug - - ./scripts/wait_for_emulator.sh - - ./scripts/wait_for_server.sh server-master - - scripts/deleteOutdatedComments.sh "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - scripts/deleteOutdatedComments.sh "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - adb logcat -c - - adb logcat > logcat.txt & - - ./gradlew jacocoTestDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew installDebugAndroidTest - - ./gradlew createDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew combinedTestReport - - curl -Os https://uploader.codecov.io/latest/linux/codecov - - chmod +x codecov - - ./codecov -t 2eec98c3-ff20-4cad-9e08-463471a33431 - -- name: notify - image: drillster/drone-email - settings: - port: 587 - from: nextcloud-drone@kaminsky.me - recipients_only: true - username: - from_secret: EMAIL_USERNAME - password: - from_secret: EMAIL_PASSWORD - recipients: - from_secret: EMAIL_RECIPIENTS - host: - from_secret: EMAIL_HOST - when: - event: - - push - status: - - failure - branch: - - master - - stable-* - -services: - - name: server-master - image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest - commands: - - rm /etc/apt/sources.list.d/php.list - - 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 - - su www-data -c "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash" - - su www-data -c "source ~/.bashrc; nvm install node" - - /usr/local/bin/initnc.sh - - su www-data -c "php /var/www/html/occ log:manage --level warning" - - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1" - - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2" - - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test'" - - su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G" - - su www-data -c "php /var/www/html/occ group:add users" - - su www-data -c "php /var/www/html/occ group:adduser users user1" - - su www-data -c "php /var/www/html/occ group:adduser users user2" - - su www-data -c "php /var/www/html/occ group:adduser users test" - - su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" - - su www-data -c "php /var/www/html/occ app:enable activity" - - su www-data -c "git clone --depth 1 -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/" - - su www-data -c "php /var/www/html/occ app:enable text" - - su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/" - - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption" - - su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/" - - su www-data -c "php /var/www/html/occ app:enable password_policy" - - su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/external/ /var/www/html/apps/external/" - - su www-data -c "cd /var/www/html/apps/external; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable external" - - su www-data -c '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}}"' - - su www-data -c "git clone --depth 1 -b main https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/" - - su www-data -c "php /var/www/html/occ app:enable -f files_lock" - - su www-data -c "git clone --depth 1 https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/" - - su www-data -c "php /var/www/html/occ app:enable -f groupfolders" - - su www-data -c "php /var/www/html/occ groupfolders:create groupfolder" - - su www-data -c "php /var/www/html/occ groupfolders:group 1 users" - - su www-data -c "git clone --depth 1 https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/" - - su www-data -c "cd /var/www/html/apps/notifications; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable -f notifications" - - su www-data -c "php /var/www/html/occ notification:generate test -d test" - - su www-data -c "git clone --depth 1 https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" - - su www-data -c "cd /var/www/html/apps/photos; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable -f photos" - - su www-data -c "git clone --depth 1 -b main https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/" - - su www-data -c "cd /var/www/html/apps/assistant; source ~/.bashrc; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable -f assistant" - - su www-data -c "php /var/www/html/occ app:enable -f testing" - - su www-data -c "git clone --depth 1 https://github.com/nextcloud/files_downloadlimit.git /var/www/html/apps/files_downloadlimit/" - - su www-data -c "php /var/www/html/occ app:enable -f files_downloadlimit" - - su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/" - - su www-data -c "php /var/www/html/occ app:enable -f recommendations" - - su www-data -c "php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool" - - /usr/local/bin/run.sh - -trigger: - branch: - - master - - stable-* - event: - - push - - pull_request ---- -kind: pipeline -type: docker -name: test-stable-latest - -steps: - - name: test - image: ghcr.io/nextcloud/continuous-integration-android8:4 - privileged: true - environment: - LOG_USERNAME: - from_secret: LOG_USERNAME - LOG_PASSWORD: - from_secret: LOG_PASSWORD - GIT_USERNAME: - from_secret: GIT_USERNAME - GIT_TOKEN: - from_secret: GIT_TOKEN - commands: - - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 & - - sed -i s"#server#server-stable-latest#" gradle.properties - - sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt - - ./gradlew assembleDebug - - ./scripts/wait_for_emulator.sh - - ./scripts/wait_for_server.sh server-stable-latest - - scripts/deleteOutdatedComments.sh "stable-latest" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - scripts/deleteOutdatedComments.sh "stable-latest" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew jacocoTestDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable-latest" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew installDebugAndroidTest - - ./gradlew createDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable-latest" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew combinedTestReport - - curl -Os https://uploader.codecov.io/latest/linux/codecov - - chmod +x codecov - - ./codecov -t 2eec98c3-ff20-4cad-9e08-463471a33431 - - - name: notify - image: drillster/drone-email - settings: - port: 587 - from: nextcloud-drone@kaminsky.me - recipients_only: true - username: - from_secret: EMAIL_USERNAME - password: - from_secret: EMAIL_PASSWORD - recipients: - from_secret: EMAIL_RECIPIENTS - host: - from_secret: EMAIL_HOST - when: - event: - - push - status: - - failure - branch: - - master - - stable-* - -services: - - name: server-stable-latest - image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest - environment: - SERVER_VERSION: stable33 - commands: - - rm /etc/apt/sources.list.d/php.list - - 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 - - su www-data -c "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash" - - su www-data -c "source ~/.bashrc; nvm install node" - - BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh - - su www-data -c "php /var/www/html/occ log:manage --level warning" - - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1" - - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2" - - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test'" - - su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G" - - su www-data -c "php /var/www/html/occ group:add users" - - su www-data -c "php /var/www/html/occ group:adduser users user1" - - su www-data -c "php /var/www/html/occ group:adduser users user2" - - su www-data -c "php /var/www/html/occ group:adduser users test" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" - - su www-data -c "php /var/www/html/occ app:enable activity" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" - - su www-data -c "php /var/www/html/occ app:enable text" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" - - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/password_policy.git /var/www/html/apps/password_policy/" - - su www-data -c "php /var/www/html/occ app:enable password_policy" - - su www-data -c "php /var/www/html/occ app:enable external" - - su www-data -c '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}}"' - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/" - - su www-data -c "php /var/www/html/occ app:enable files_lock" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/" - - su www-data -c "php /var/www/html/occ app:enable -f groupfolders" - - su www-data -c "php /var/www/html/occ groupfolders:create groupfolder" - - su www-data -c "php /var/www/html/occ groupfolders:group 1 users" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/" - - su www-data -c "cd /var/www/html/apps/notifications; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable -f notifications" - - su www-data -c "php /var/www/html/occ notification:generate test test" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" - - su www-data -c "cd /var/www/html/apps/photos; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable -f photos" - - su www-data -c "git clone --depth 1 -b main https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/" - - su www-data -c "cd /var/www/html/apps/assistant; source ~/.bashrc; composer install --no-dev" - - su www-data -c "php /var/www/html/occ app:enable assistant" - - su www-data -c "php /var/www/html/occ app:enable -f testing" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/files_downloadlimit.git /var/www/html/apps/files_downloadlimit/" - - su www-data -c "php /var/www/html/occ app:enable -f files_downloadlimit" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/" - - su www-data -c "php /var/www/html/occ app:enable recommendations" - - su www-data -c "php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool" - - /usr/local/bin/run.sh - -trigger: - branch: - - master - - stable-* - event: - - push - - pull_request ---- -kind: pipeline -type: docker -name: test-stable-oldest - -steps: - - name: test - image: ghcr.io/nextcloud/continuous-integration-android8:4 - privileged: true - environment: - LOG_USERNAME: - from_secret: LOG_USERNAME - LOG_PASSWORD: - from_secret: LOG_PASSWORD - GIT_USERNAME: - from_secret: GIT_USERNAME - GIT_TOKEN: - from_secret: GIT_TOKEN - commands: - - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 & - - sed -i s"#server#server-stable-oldest#" gradle.properties - - sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt - - ./gradlew assembleDebug - - ./scripts/wait_for_emulator.sh - - ./scripts/wait_for_server.sh server-stable-oldest - - scripts/deleteOutdatedComments.sh "stable-oldest" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - scripts/deleteOutdatedComments.sh "stable-oldest" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew jacocoTestDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable-oldest" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew installDebugAndroidTest - - ./gradlew createDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable-oldest" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN - - ./gradlew combinedTestReport - - curl -Os https://uploader.codecov.io/latest/linux/codecov - - chmod +x codecov - - ./codecov -t 2eec98c3-ff20-4cad-9e08-463471a33431 - - - name: notify - image: drillster/drone-email - settings: - port: 587 - from: nextcloud-drone@kaminsky.me - recipients_only: true - username: - from_secret: EMAIL_USERNAME - password: - from_secret: EMAIL_PASSWORD - recipients: - from_secret: EMAIL_RECIPIENTS - host: - from_secret: EMAIL_HOST - when: - event: - - push - status: - - failure - branch: - - master - - stable-* - -services: - - name: server-stable-oldest - image: ghcr.io/nextcloud/continuous-integration-shallow-server-php7.4:1 - environment: - SERVER_VERSION: stable20 - commands: - - rm /etc/apt/sources.list.d/php.list - - 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 - - su www-data -c "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash" - - su www-data -c "source ~/.bashrc; nvm install node" - - BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh - - su www-data -c "php /var/www/html/occ log:manage --level warning" - - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1" - - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2" - - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test" - - su www-data -c "OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test'" - - su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G" - - su www-data -c "php /var/www/html/occ group:add users" - - su www-data -c "php /var/www/html/occ group:adduser users user1" - - su www-data -c "php /var/www/html/occ group:adduser users user2" - - su www-data -c "php /var/www/html/occ group:adduser users test" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" - - su www-data -c "php /var/www/html/occ app:enable activity" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" - - su www-data -c "php /var/www/html/occ app:enable text" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" - - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/password_policy.git /var/www/html/apps/password_policy/" - - su www-data -c "php /var/www/html/occ app:enable password_policy" - - su www-data -c "php /var/www/html/occ app:enable external" - - su www-data -c '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}}"' - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/" - - su www-data -c "php /var/www/html/occ app:enable -f groupfolders" - - su www-data -c "php /var/www/html/occ groupfolders:create groupfolder" - - su www-data -c "php /var/www/html/occ groupfolders:group 1 users" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/" - - su www-data -c "cd /var/www/html/apps/notifications" - - su www-data -c "php /var/www/html/occ app:enable -f notifications" - - su www-data -c "php /var/www/html/occ notification:generate test test" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" - - su www-data -c "cd /var/www/html/apps/photos" - - su www-data -c "php /var/www/html/occ app:enable -f photos" - - su www-data -c "php /var/www/html/occ app:enable -f testing" - - su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/" - - su www-data -c "php /var/www/html/occ app:enable recommendations" - - su www-data -c "php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool" - - /usr/local/bin/run.sh - -trigger: - branch: - - master - - stable-* - event: - - push - - pull_request ---- -kind: signature -hmac: b26e47fc03b18d8521973aa42f47b82f98b0c61c1836a99e454e9792dbee02ae - -... diff --git a/.github/workflows/configNC.sh b/.github/workflows/configNC.sh new file mode 100644 index 0000000000..8446e69faa --- /dev/null +++ b/.github/workflows/configNC.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT +# + +if [ $1 = "master" ]; then + SERVER_VERSION_MAIN="main" + SERVER_VERSION_MASTER="master" +else + SERVER_VERSION_MAIN=$1 + SERVER_VERSION_MASTER=$1 +fi + +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" + +. ~/.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 $SERVER_VERSION_MASTER https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable -f activity + +git clone --depth=1 -b $SERVER_VERSION_MAIN https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable -f text + +git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/ +php /var/www/html/occ app:enable -f end_to_end_encryption + +git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/password_policy.git /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable -f password_policy + +git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/external.git /var/www/html/apps/external/ +cd /var/www/html/apps/external; composer install --no-dev +php /var/www/html/occ app:enable -f 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 $SERVER_VERSION_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 -b $SERVER_VERSION_MASTER 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 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +cd /var/www/html/apps/notifications; composer install --no-dev +php /var/www/html/occ app:enable -f notifications + +if [ $1 = 'stable22' ]; then + php /var/www/html/occ notification:generate test test +else + php /var/www/html/occ notification:generate test -d test +fi + +git clone --depth=1 -b $SERVER_VERSION_MASTER 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 -b $SERVER_VERSION_MAIN https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/ +cd /var/www/html/apps/assistant; . ~/.bashrc; make +php /var/www/html/occ app:enable -f assistant + +php /var/www/html/occ app:enable -f testing + +git clone --depth 1 -b $SERVER_VERSION_MASTER 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 $SERVER_VERSION_MASTER https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/ +cd /var/www/html/apps/recommendations; composer install --no-dev +php /var/www/html/occ app:enable -f recommendations + +git clone --depth 1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/viewer.git /var/www/html/apps/viewer/ +php /var/www/html/occ app:enable -f viewer + +php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool diff --git a/.github/workflows/configServer.sh b/.github/workflows/configServer.sh new file mode 100644 index 0000000000..e87cbbf0f3 --- /dev/null +++ b/.github/workflows/configServer.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +# 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 +mkdir /var/www/.cache/ +touch /var/www/.bashrc +chown -R 33:33 /var/www/.nvm /var/www/.npm /var/www/.bashrc /var/www/.cache + +cd /var/www/html/ +rm data -rf +rm config/config.php +su www-data -c "git reset --hard" +BRANCH="$1" /usr/local/bin/initnc.sh diff --git a/.github/workflows/garm.yml b/.github/workflows/garm.yml new file mode 100644 index 0000000000..b0d2adb01a --- /dev/null +++ b/.github/workflows/garm.yml @@ -0,0 +1,115 @@ +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +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-24.04 + services: + server: + image: ${{ matrix.server == 'stable22' && 'ghcr.io/nextcloud/continuous-integration-shallow-server-php8.0:1' || 'ghcr.io/nextcloud/continuous-integration-shallow-server-php8.2:1' }} + options: --name server + ports: + - 80:80 + strategy: + fail-fast: false + matrix: + server: [ stable22, stable33, master ] + api-level: [ 29 ] # [ 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.sh server:/tmp/ + docker exec server chmod +x /tmp/configNC.sh + docker exec --user www-data server /tmp/configNC.sh ${{ matrix.server }} + 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: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + + - 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 + 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: 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}} ${{ matrix.server }} "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/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 680c5ef522..1d5d5682bb 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/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt index 1b7c5c5a84..891c9da292 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt @@ -114,7 +114,7 @@ class ReadFileRemoteOperationIT : AbstractIT() { val remoteFile = result.data[0] as RemoteFile @Suppress("Detekt.MagicNumber") - if (isServerAtLeast(NextcloudVersion.nextcloud_21)) { + if (isServerAtLeast(NextcloudVersion.nextcloud_23)) { assertEquals(ImageDimension(451f, 529f), remoteFile.imageDimension) } 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 75829c8835..dda961ed40 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 @@ -203,7 +203,7 @@ public void favoriteFiles() throws IOException { assertEquals(remotePath, result.getResultData().get(0).getRemotePath()); String expectedSharedRemotePath; - if (isServerAtLeast(NextcloudVersion.nextcloud_21)) { + if (isServerAtLeast(NextcloudVersion.nextcloud_23)) { expectedSharedRemotePath = sharedRemotePath; } else { // Bug: shared search ends with "/" even for files diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/StatusIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/StatusIT.kt index f3194214b4..fd61cfc12c 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/StatusIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/StatusIT.kt @@ -43,7 +43,7 @@ class StatusIT : AbstractIT() { val status = StatusType.entries.toMutableList() - if (!isServerAtLeast(NextcloudVersion.nextcloud_21)) { + if (!isServerAtLeast(NextcloudVersion.nextcloud_23)) { status.remove(StatusType.BUSY) } 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..28c9c3c55f --- /dev/null +++ b/scripts/createDockerTestContainer.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2026 Tobias Kaminsky +# SPDX-License-Identifier: MIT +# + +if [[ $# -ne 1 ]]; then + echo "please specify as first parameter: stable22, stable33, master" + exit +fi + +docker stop testNC +docker rm testNC + +if [ $1 = 'stable22' ]; then + docker run --name=testNC ghcr.io/nextcloud/continuous-integration-shallow-server-php8.0:1 & +else + docker run --name=testNC ghcr.io/nextcloud/continuous-integration-shallow-server-php8.2:1 & +fi + +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.sh testNC:/tmp/ +docker exec testNC chmod +x /tmp/configNC.sh +docker exec --user www-data testNC /tmp/configNC.sh $1 +docker exec testNC -dt /usr/local/bin/run.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..c91e931923 --- /dev/null +++ b/scripts/runTests.sh @@ -0,0 +1,19 @@ +# +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2026 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..5f8eabe544 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/ \" }" +curl --header "Authorization: token $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