Skip to content

Commit

Permalink
added end to end test
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Jul 3, 2023
1 parent 66293e7 commit dabcece
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ services:
- su www-data -c "git clone https://github.com/nextcloud/notifications.git /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 -d test"
- 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<List<OCShare>> 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<DownloadLimitResponse> limitOperation =
new GetShareDownloadLimitOperation(shareToken)
.execute(client);

assertTrue(limitOperation.isSuccess());
assertEquals(downloadLimit, limitOperation.getResultData().getLimit());
assertEquals(0, limitOperation.getResultData().getCount());
}
}

0 comments on commit dabcece

Please sign in to comment.