public async Task AccessShare_Creates_UsableSharedAccessForDownload() { string serializedAccess; string bucketname = "accessshare-creates-usablesharedaccessfordownload"; byte[] bytesToUpload = ObjectServiceTest.GetRandomBytes(2048); using (Access scope = new Access(TestConstants.SATELLITE_URL, TestConstants.VALID_API_KEY, TestConstants.ENCRYPTION_SECRET)) { await _bucketService.CreateBucketAsync(bucketname); var bucket = await _bucketService.GetBucketAsync(bucketname); var uploadOperation = await _objectService.UploadObjectAsync(bucket, "test/test-file", new UploadOptions(), bytesToUpload, false); await uploadOperation.StartUploadAsync(); Permission permission = new Permission(); permission.AllowUpload = false; //Should not change anything as we are downloading here permission.AllowDownload = true; List <SharePrefix> sharePrefixes = new List <SharePrefix>(); sharePrefixes.Add(new SharePrefix() { Bucket = bucketname, Prefix = "test/" }); var restricted = scope.Share(permission, sharePrefixes); serializedAccess = restricted.Serialize(); } await Task.Delay(SATELLITE_WAIT_DURATION); //Wait a bit so that some things can happen on the satellite Access restrictedEnv; try { restrictedEnv = new Access(serializedAccess); } catch { Assert.Fail("Failed to create restricted scope from serialized scope"); return; } var restrictedObjectService = new ObjectService(restrictedEnv); var restrictedBucketService = new BucketService(restrictedEnv); var restrictedBucket = await restrictedBucketService.GetBucketAsync(bucketname); var downloadOperation = await restrictedObjectService.DownloadObjectAsync(restrictedBucket, "test/test-file", new DownloadOptions(), false); await downloadOperation.StartDownloadAsync(); Assert.IsTrue(downloadOperation.Completed); Assert.AreEqual(bytesToUpload.Length, downloadOperation.BytesReceived); for (int i = 0; i < bytesToUpload.Length; i++) { Assert.AreEqual(bytesToUpload[i], downloadOperation.DownloadedBytes[i], "DownloadedBytes are not equal at index " + i); } }