Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public async Task TestCommandUploadBucket()
        {
            var bucket = Builder <FakeBucket> .CreateNew().Build();

            CancellationToken ct = default(CancellationToken);
            var command          = new UploadBucketCommand();
            var config           = new BucketConfiguration()
            {
                LocalPathFiles     = new List <string>(),
                LocalPathFolders   = 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");
        }
Exemplo n.º 3
0
        public void TestCommandUploadBucketWithInvalidRemotePathIsBlockedBySanitization()
        {
            var bucket = Builder <FakeBucket> .CreateNew().Build();

            CancellationToken ct = default(CancellationToken);
            var command          = new UploadBucketCommand();
            var config           = new BucketConfiguration()
            {
                LocalPathFiles     = new List <string>(),
                LocalPathFolders   = new List <string>(),
                LocalPathGet       = "a",
                RemoteRelativePath = "/invalid//Path",
                DeleteFiles        = true,
            };
            var ret = Assert.ThrowsAsync <Exception>(
                async() => await command.ExecuteAsync(bucket, config, ct),
                "Invalid path should throw an error");

            var expectedErrorMessage = "Upload failed. Invalid remote path";

            Assert.AreEqual(expectedErrorMessage, ret.Message);
        }