public void TestCommandDownloadBucketWithInvalidRemotePathIsBlockedBySanitizationAndThrowError(string invalidPath, string pathType = null) { var bucket = Builder <FakeBucket> .CreateNew().Build(); CancellationToken ct = default(CancellationToken); var command = new DownloadBucketCommand(); var config = new BucketConfiguration() { RemoteRelativePathFiles = new List <string>(), RemoteRelativePathFolders = new List <string>(), LocalPathGet = "a", RemoteRelativePath = "b", DeleteFiles = true, }; switch (pathType) { case "folder": config.RemoteRelativePathFolders.Add(invalidPath); break; case "file": default: config.RemoteRelativePathFiles.Add(invalidPath); break; } var ret = Assert.ThrowsAsync <Exception>( async() => await command.ExecuteAsync(bucket, config, ct), "Invalid path should throw an error"); var expectedErrorMessage = "Download failed. Invalid remote path(s)"; Assert.AreEqual(expectedErrorMessage, ret.Message); }
public async Task TestCommandDownloadBucketWithinvalidRemotePathIsBlockedBySanitization(string invalidPath, string pathType = null) { var bucket = Builder <FakeBucket> .CreateNew().Build(); CancellationToken ct = default(CancellationToken); var command = new DownloadBucketCommand(); var config = new BucketConfiguration() { RemoteRelativePathFiles = new List <string>(), RemoteRelativePathFolders = new List <string>(), LocalPathGet = "a", RemoteRelativePath = "b", DeleteFiles = true, }; switch (pathType) { case "folder": config.RemoteRelativePathFolders.Add(invalidPath); break; case "file": default: config.RemoteRelativePathFiles.Add(invalidPath); break; } CommandValues.GenericInfoCommandValue ret = await command.ExecuteAsync(bucket, config, ct); Assert.IsTrue(ret is CommandValues.GenericInfoCommandValue); Assert.AreEqual(ret.Uuid, "Shortname1"); Assert.AreEqual("Download failed. Invalid remote path(s)", (ret as CommandValues.GenericInfoCommandValue).Message); }
public void TestBasicCommandOnBucketNotFoundReturnTheNotFoundErrorMessage(CommandApi commandType) { QBucket bucket = null; // symbolize the null return from sdk retrieve bucket method if the bucket doses not exist ICommand <QBucket, CommandValues.GenericInfoCommandValue> command; Task commandAsync = null; CancellationToken ct = default(CancellationToken); var config = new BucketConfiguration() { Name = "NonExistingBucket", LocalPathGet = "a", RemoteRelativePaths = new List <string> { "b" }, }; switch (commandType) { case CommandApi.Delete: command = new DeleteBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; case CommandApi.SyncFrom: command = new SynchronizeLocalFolderFromBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; case CommandApi.SyncTo: command = new SynchronizeLocalFolderToBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; case CommandApi.Upload: command = new UploadBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; case CommandApi.Download: command = new DownloadBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; case CommandApi.Remove: command = new RemoveEntityBucketCommand(); commandAsync = command.ExecuteAsync(bucket, config, ct); break; } var cliException = Assert.ThrowsAsync <Exception>(async() => await commandAsync, "Bucket not found should throw an error"); string expected1 = "Bucket not found"; StringAssert.Contains(expected1, cliException.Message); }
public async Task TestCommandDownloadBucket() { var bucket = Builder <FakeBucket> .CreateNew().Build(); CancellationToken ct = default(CancellationToken); var command = new DownloadBucketCommand(); var config = new BucketConfiguration() { RemoteRelativePathFiles = new List <string>(), RemoteRelativePathFolders = new List <string>(), LocalPathGet = "a", RemoteRelativePath = "b", DeleteFiles = true, }; CommandValues.GenericInfoCommandValue ret = await command.ExecuteAsync(bucket, config, ct); Assert.IsTrue(ret is CommandValues.GenericInfoCommandValue); Assert.AreEqual(ret.Uuid, "Shortname1"); }