From 9b66ec5de230bdc7e9ab9413dc286d5412a77232 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 3 Jul 2023 08:53:43 +0200 Subject: [PATCH] added end to end test Signed-off-by: tobiasKaminsky --- .drone.yml | 2 + .../lib/common/operations/CreateShareIT.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/.drone.yml b/.drone.yml index 5c97b452b..67bdf02e5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -99,6 +99,8 @@ services: - su www-data -c "git clone https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" - su www-data -c "cd /var/www/html/apps/photos; composer install" - su www-data -c "php /var/www/html/occ app:enable -f photos" + - su www-data -c "git clone 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" - /usr/local/bin/run.sh trigger: diff --git a/library/src/androidTest/java/com/owncloud/android/lib/common/operations/CreateShareIT.java b/library/src/androidTest/java/com/owncloud/android/lib/common/operations/CreateShareIT.java index 7b4874484..cdf6c428a 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/common/operations/CreateShareIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/common/operations/CreateShareIT.java @@ -28,18 +28,25 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.resources.download_limit.GetShareDownloadLimitOperation; +import com.owncloud.android.lib.resources.download_limit.UpdateShareDownloadLimitRemoteOperation; +import com.owncloud.android.lib.resources.download_limit.model.DownloadLimitResponse; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation; +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.Before; import org.junit.Test; import java.io.File; +import java.util.List; /** * Test create share @@ -246,4 +253,36 @@ public void testCreateFederatedShareWithNonExistingFile() { assertFalse("file doesn't exist", result.isSuccess()); assertEquals("file doesn't exist", ResultCode.FILE_NOT_FOUND, result.getCode()); } + + @Test + public void testCreatePublicShareWithDownloadLimit() { + testOnlyOnServer(NextcloudVersion.nextcloud_25); + + int downloadLimit = 5; + CreateShareRemoteOperation operation = new CreateShareRemoteOperation( + mFullPath2FileToShare, + ShareType.PUBLIC_LINK, + "", + false, + "", + 1); + operation.setGetShareDetails(true); + RemoteOperationResult> result = operation.execute(client); + assertTrue(result.isSuccess()); + String shareToken = result.getResultData().get(0).getToken(); + assertNotNull(shareToken); + + assertTrue(new UpdateShareDownloadLimitRemoteOperation(shareToken, downloadLimit) + .execute(client) + .isSuccess() + ); + + RemoteOperationResult limitOperation = + new GetShareDownloadLimitOperation(shareToken) + .execute(client); + + assertTrue(limitOperation.isSuccess()); + assertEquals(downloadLimit, limitOperation.getResultData().getLimit()); + assertEquals(0, limitOperation.getResultData().getCount()); + } }