示例#1
0
        public async Task Error_IfCredentialsAreInvalidAndThrowExceptionOnErrorResponseIsFalse()
        {
            var input = new UploadInput
            {
                FileMask    = "TestFile1.csv",
                FilePath    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../TestData/"),
                S3Directory = @"\"
            };

            var options = new UploadOptions
            {
                ReturnListOfObjectKeys = true,
                ThrowErrorIfNoMatch    = true
            };

            var param = new Parameters
            {
                // Invalid AwsAccesKeyId.
                AwsAccessKeyId = "fnvfdvfkdjvn",

                // Invalid AwsSecretAccessKey.
                AwsSecretAccessKey            = "bvfjhbvdjhvbjdhf",
                BucketName                    = Environment.GetEnvironmentVariable("HiQ_AWSS3Test_BucketName"),
                Region                        = (Regions)int.Parse(Environment.GetEnvironmentVariable("HiQ_AWSS3Test_Region")),
                ThrowExceptionOnErrorResponse = false
            };

            async Task <List <string> > UploadThatThrows()
            {
                var response = await UploadTask.UploadFiles(input, param, options, new CancellationToken());

                return(response);
            }

            try
            {
                await UploadThatThrows();
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but got: " + ex.Message);
            }
        }
示例#2
0
        public void Error_IfSourcePathIsInvalid()
        {
            var input = new UploadInput
            {
                FileMask = @"*.test",
                FilePath = @"c:\there_is_no_folder_like_this\"
            };
            var options = new UploadOptions
            {
                ReturnListOfObjectKeys = true,
                ThrowErrorIfNoMatch    = true
            };

            void UploadThatThrows()
            {
                UploadTask.UploadFiles(input, _param, options, new CancellationToken());
            }

            Assert.That(UploadThatThrows,
                        Throws.TypeOf <ArgumentException>()
                        .With.Message.StartsWith("Source path not found."));
        }
示例#3
0
        public void Error_IfCredentialsAreInvalidAndThrowExceptionOnErrorResponseIsTrue()
        {
            var input = new UploadInput
            {
                FileMask    = "TestFile1.csv",
                FilePath    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../TestData/"),
                S3Directory = @"\",
                CannedACL   = S3CannedACLs.Private
            };

            var options = new UploadOptions
            {
                ReturnListOfObjectKeys = true,
                ThrowErrorIfNoMatch    = true
            };

            var param = new Parameters
            {
                // Invalid AwsAccesKeyId.
                AwsAccessKeyId = "fnvfdvfkdjvn",

                // Invalid AwsSecretAccessKey.
                AwsSecretAccessKey            = "bvfjhbvdjhvbjdhf",
                BucketName                    = Environment.GetEnvironmentVariable("HiQ_AWSS3Test_BucketName"),
                Region                        = (Regions)int.Parse(Environment.GetEnvironmentVariable("HiQ_AWSS3Test_Region")),
                ThrowExceptionOnErrorResponse = true
            };

            async Task <List <string> > UploadThatThrows()
            {
                var response = await UploadTask.UploadFiles(input, param, options, new CancellationToken());

                return(response);
            }

            Assert.That(UploadThatThrows, Throws.TypeOf <SecurityException>().With.Message.StartsWith("Invalid Amazon S3 Credentials - data was not uploaded."));
        }
示例#4
0
        public void Error_IfSwitchIsOnAndNothingMatches()
        {
            var input = new UploadInput
            {
                FileMask    = "there_is_no_spoon.text",
                FilePath    = Path.GetTempPath(),
                S3Directory = @"\"
            };

            var options = new UploadOptions
            {
                ReturnListOfObjectKeys = true,
                ThrowErrorIfNoMatch    = true
            };

            void UploadThatThrows()
            {
                UploadTask.UploadFiles(input, _param, options, new CancellationToken());
            }

            Assert.That(UploadThatThrows,
                        Throws.TypeOf <ArgumentException>()
                        .With.Message.StartsWith("No files match the filemask within supplied path."));
        }