|
28 | 28 |
|
29 | 29 | import static org.junit.Assert.assertEquals;
|
30 | 30 | import static org.junit.Assert.assertFalse;
|
| 31 | +import static org.junit.Assert.assertNotNull; |
31 | 32 | import static org.junit.Assert.assertTrue;
|
32 | 33 |
|
33 | 34 | import com.owncloud.android.AbstractIT;
|
34 | 35 | import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
| 36 | +import com.owncloud.android.lib.resources.download_limit.GetShareDownloadLimitOperation; |
| 37 | +import com.owncloud.android.lib.resources.download_limit.UpdateShareDownloadLimitRemoteOperation; |
| 38 | +import com.owncloud.android.lib.resources.download_limit.model.DownloadLimitResponse; |
35 | 39 | import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
|
36 | 40 | import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
|
| 41 | +import com.owncloud.android.lib.resources.shares.OCShare; |
37 | 42 | import com.owncloud.android.lib.resources.shares.ShareType;
|
| 43 | +import com.owncloud.android.lib.resources.status.NextcloudVersion; |
38 | 44 |
|
39 | 45 | import org.junit.Before;
|
40 | 46 | import org.junit.Test;
|
41 | 47 |
|
42 | 48 | import java.io.File;
|
| 49 | +import java.util.List; |
43 | 50 |
|
44 | 51 | /**
|
45 | 52 | * Test create share
|
@@ -246,4 +253,36 @@ public void testCreateFederatedShareWithNonExistingFile() {
|
246 | 253 | assertFalse("file doesn't exist", result.isSuccess());
|
247 | 254 | assertEquals("file doesn't exist", ResultCode.FILE_NOT_FOUND, result.getCode());
|
248 | 255 | }
|
| 256 | + |
| 257 | + @Test |
| 258 | + public void testCreatePublicShareWithDownloadLimit() { |
| 259 | + testOnlyOnServer(NextcloudVersion.nextcloud_25); |
| 260 | + |
| 261 | + int downloadLimit = 5; |
| 262 | + CreateShareRemoteOperation operation = new CreateShareRemoteOperation( |
| 263 | + mFullPath2FileToShare, |
| 264 | + ShareType.PUBLIC_LINK, |
| 265 | + "", |
| 266 | + false, |
| 267 | + "", |
| 268 | + 1); |
| 269 | + operation.setGetShareDetails(true); |
| 270 | + RemoteOperationResult<List<OCShare>> result = operation.execute(client); |
| 271 | + assertTrue(result.isSuccess()); |
| 272 | + String shareToken = result.getResultData().get(0).getToken(); |
| 273 | + assertNotNull(shareToken); |
| 274 | + |
| 275 | + assertTrue(new UpdateShareDownloadLimitRemoteOperation(shareToken, downloadLimit) |
| 276 | + .execute(client) |
| 277 | + .isSuccess() |
| 278 | + ); |
| 279 | + |
| 280 | + RemoteOperationResult<DownloadLimitResponse> limitOperation = |
| 281 | + new GetShareDownloadLimitOperation(shareToken) |
| 282 | + .execute(client); |
| 283 | + |
| 284 | + assertTrue(limitOperation.isSuccess()); |
| 285 | + assertEquals(downloadLimit, limitOperation.getResultData().getLimit()); |
| 286 | + assertEquals(0, limitOperation.getResultData().getCount()); |
| 287 | + } |
249 | 288 | }
|
0 commit comments