Пример #1
0
        public void TagBucket()
        {
            var request = new PutBucketTaggingRequest
            {
                BucketName = bucketName,
                TagSet     = new List <Tag>
                {
                    new Tag
                    {
                        Key   = "TagBucketKey",
                        Value = "TagBucketValue"
                    }
                }
            };

            Client.PutBucketTagging(request);

            var tags = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetBucketTagging(new GetBucketTaggingRequest {
                    BucketName = bucketName
                });
                return(res.TagSet?.FirstOrDefault(x => string.Equals(x.Key, "TagBucketKey")) != null ? res.TagSet : null);
            });

            var tag = tags.FirstOrDefault(x => string.Equals(x.Key, "TagBucketKey"));

            Assert.IsNotNull(tag);
            Assert.AreEqual("TagBucketValue", tag.Value);
        }
Пример #2
0
        void TestAccelerateUnsupportedOperations(IAmazonS3 client)
        {
            // List, Put and Delete bucket should hit regional endpoint
            var buckets = client.ListBuckets().Buckets;

            Assert.IsNotNull(buckets);
            var newBucket = UtilityMethods.GenerateName();

            client.PutBucket(newBucket);

            S3TestUtils.WaitForConsistency(() =>
            {
                var result = client.ListBuckets().Buckets.Any(b => b.BucketName.Equals(newBucket, StringComparison.Ordinal));
                return(result ? (bool?)true : null);
            });

            try
            {
                client.DeleteBucket(newBucket);
            }
            catch
            {
                Console.WriteLine($"Failed to clean up new bucket {newBucket}. Ignore leftover bucket.");
            }
        }
Пример #3
0
        public static void WaitForBucket(IAmazonS3 client, string bucketName, int maxSeconds)
        {
            var sleeper = UtilityMethods.ListSleeper.Create();

            UtilityMethods.WaitUntilSuccess(() => {
                //Check if a bucket exists by trying to put an object in it
                var key = Guid.NewGuid().ToString() + "_existskey";

                var res = client.PutObject(new PutObjectRequest
                {
                    BucketName  = bucketName,
                    Key         = key,
                    ContentBody = "exists..."
                });

                try
                {
                    client.Delete(bucketName, key, null);
                }
                catch
                {
                    Console.WriteLine($"Eventual consistency error: failed to delete key {key} from bucket {bucketName}");
                }

                return(true);
            });

            //Double check the bucket still exists using the DoesBucketExistV2 method
            var exists = S3TestUtils.WaitForConsistency(() =>
            {
                return(AmazonS3Util.DoesS3BucketExistV2(client, bucketName) ? (bool?)true : null);
            });
        }
Пример #4
0
        public static void Setup(TestContext context)
        {
            _bucketName = S3TestUtils.CreateBucketWithWait(Client);
            _mrapName   = UtilityMethods.SDK_TEST_PREFIX + DateTime.Now.Ticks;

            // Look up the account ID for the credentials being used to run the tests
            _accountId = new AmazonSecurityTokenServiceClient().GetCallerIdentity(new GetCallerIdentityRequest()).Account;

            var request = new CreateMultiRegionAccessPointRequest
            {
                AccountId = _accountId,
                Details   = new CreateMultiRegionAccessPointInput
                {
                    Name    = _mrapName,
                    Regions = new List <Region>
                    {
                        new Region
                        {
                            Bucket = _bucketName
                        }
                    }
                }
            };

            // All MRAP control plane requests must go to us-west-2 per
            // https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManagingMultiRegionAccessPoints.html
            var mrapAlias = S3TestUtils.CreateMRAPWithWait(new AmazonS3ControlClient(RegionEndpoint.USWest2), request);

            _mrapArn = $"arn:aws:s3::{_accountId}:accesspoint/{mrapAlias}";
        }
        public void BucketIntelligentTieringConfigurationsTagFilterTest()
        {
            Tag tag = new Tag()
            {
                Key   = "tagK",
                Value = "tagV"
            };
            var intelligentTieringFilter = new IntelligentTieringFilter()
            {
                IntelligentTieringFilterPredicate = new IntelligentTieringTagPredicate(tag)
            };

            var putBucketIntelligentTieringConfigurationRequest  = GeneratePutRequest(intelligentTieringId, intelligentTieringFilter);
            var putBucketIntelligentTieringConfigurationResponse = Client.PutBucketIntelligentTieringConfiguration(putBucketIntelligentTieringConfigurationRequest);

            GetBucketIntelligentTieringConfigurationRequest getBucketIntelligentTieringConfigurationRequest = new GetBucketIntelligentTieringConfigurationRequest()
            {
                IntelligentTieringId = intelligentTieringId,
                BucketName           = bucketName
            };

            var getBucketIntelligentTieringConfigurationResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetBucketIntelligentTieringConfiguration(getBucketIntelligentTieringConfigurationRequest);
                return(res.IntelligentTieringConfiguration?.IntelligentTieringId == getBucketIntelligentTieringConfigurationRequest.IntelligentTieringId ? res : null);
            });

            var getConfiguration = getBucketIntelligentTieringConfigurationResponse.IntelligentTieringConfiguration;
            var putConfiguration = putBucketIntelligentTieringConfigurationRequest.IntelligentTieringConfiguration;

            Assert.AreEqual(getConfiguration.IntelligentTieringId, putConfiguration.IntelligentTieringId);
            Assert.AreEqual(((IntelligentTieringTagPredicate)getConfiguration.IntelligentTieringFilter.IntelligentTieringFilterPredicate).Tag.Key, "tagK");
            Assert.AreEqual(((IntelligentTieringTagPredicate)getConfiguration.IntelligentTieringFilter.IntelligentTieringFilterPredicate).Tag.Value, "tagV");
        }
Пример #6
0
        public static void Initialize(TestContext a)
        {
            var config = new AmazonS3Config();

            s3Client   = new AmazonS3Client(config);
            bucketName = S3TestUtils.CreateBucketWithWait(s3Client);
        }
Пример #7
0
        public void TestVersionBucketName()
        {
            var count = 5;

            for (int i = 0; i < count; i++)
            {
                Client.PutObject(new PutObjectRequest
                {
                    BucketName  = bucketName,
                    Key         = key,
                    ContentBody = content
                });
            }

            var response = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.ListVersions(bucketName);
                return(res.Versions?.Count == count ? res : null);
            });

            var versions = response.Versions;

            Assert.AreEqual(count, versions.Count);

            foreach (var version in versions)
            {
                Assert.AreEqual(bucketName, version.BucketName);
                Assert.AreEqual(key, version.Key);
            }
        }
 public static void Initialize(TestContext a)
 {
     bucketName = S3TestUtils.CreateBucketWithWait(Client, new PutBucketRequest
     {
         ObjectLockEnabledForBucket = true
     });
 }
Пример #9
0
        public void TestKmsOverHttp()
        {
            var config = new AmazonS3Config
            {
                RegionEndpoint = AWSConfigs.RegionEndpoint,
                UseHttp        = true
            };

            using (var client = new AmazonS3Client(config))
            {
                var bucketName = S3TestUtils.CreateBucket(client);
                try
                {
                    var putObjectRequest = new PutObjectRequest
                    {
                        BucketName  = bucketName,
                        Key         = key,
                        ContentBody = testContents,
                        ServerSideEncryptionMethod = ServerSideEncryptionMethod.AWSKMS
                    };
                    Action action = () =>
                    {
                        client.PutObject(putObjectRequest);
                    };

                    AssertExtensions.ExpectException(action, typeof(AmazonClientException));
                }
                finally
                {
                    AmazonS3Util.DeleteS3BucketWithObjects(client, bucketName);
                }
            }
        }
Пример #10
0
        public void GetObjectFromDefaultEndpointBeforeDNSResolution()
        {
            var client = new AmazonS3Client(RegionEndpoint.USWest2);
            var defaultEndpointClient = new AmazonS3Client(RegionEndpoint.USEast1);
            var bucketName            = S3TestUtils.CreateBucket(client);

            try
            {
                var putObjectRequest = new PutObjectRequest
                {
                    BucketName  = bucketName,
                    Key         = key,
                    ContentBody = testContents,
                    ServerSideEncryptionMethod = ServerSideEncryptionMethod.AWSKMS
                };
                client.PutObject(putObjectRequest);

                using (var response = defaultEndpointClient.GetObject(bucketName, key))
                    using (var reader = new StreamReader(response.ResponseStream))
                    {
                        var data = reader.ReadToEnd();
                        Assert.AreEqual(testContents, data);
                    }
            }
            finally
            {
                AmazonS3Util.DeleteS3BucketWithObjects(client, bucketName);
                client.Dispose();
                defaultEndpointClient.Dispose();
            }
        }
        public void PutObjectLegalHold(string key, ObjectLockLegalHoldStatus status)
        {
            //Put the legal hold
            var objectLegalHold = new ObjectLockLegalHold();

            objectLegalHold.Status = status;
            var putRequest = new PutObjectLegalHoldRequest
            {
                BucketName   = bucketName,
                LegalHold    = objectLegalHold,
                RequestPayer = RequestPayer.Requester,
                Key          = key
            };

            var putResponse = Client.PutObjectLegalHold(putRequest);

            Assert.AreEqual(true, putResponse.HttpStatusCode == HttpStatusCode.OK);

            //Get the legal hold
            var getRequest = new GetObjectLegalHoldRequest
            {
                BucketName   = bucketName,
                Key          = key,
                RequestPayer = RequestPayer.Requester
            };

            var getResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetObjectLegalHold(getRequest);
                return(res.LegalHold?.Status == status ? res : null);
            });

            Assert.AreEqual(true, getResponse.HttpStatusCode == HttpStatusCode.OK);
            Assert.AreEqual(status, getResponse.LegalHold.Status);
        }
Пример #12
0
        private static void CreateBucketWithObjectLockConfiguration()
        {
            bucketName = S3TestUtils.CreateBucketWithWait(Client, new PutBucketRequest
            {
                ObjectLockEnabledForBucket = true,
            });

            var objectLockConfiguration = new ObjectLockConfiguration();

            objectLockConfiguration.ObjectLockEnabled = ObjectLockEnabled.Enabled;
            objectLockConfiguration.Rule = new ObjectLockRule
            {
                DefaultRetention = new DefaultRetention
                {
                    Days = 1,
                    Mode = ObjectLockRetentionMode.Governance
                }
            };

            var putRequest = new PutObjectLockConfigurationRequest
            {
                BucketName              = bucketName,
                RequestPayer            = RequestPayer.Requester,
                ObjectLockConfiguration = objectLockConfiguration
            };

            var putResponse = Client.PutObjectLockConfiguration(putRequest);
        }
Пример #13
0
        public void PutAndGetEventBridgeConfigurationTest()
        {
            using (var s3Client = new AmazonS3Client())
            {
                var bucketName = S3TestUtils.CreateBucketWithWait(s3Client);

                try
                {
                    var putRequest = new PutBucketNotificationRequest()
                    {
                        BucketName = bucketName,
                        EventBridgeConfiguration  = new EventBridgeConfiguration(),
                        SkipDestinationValidation = true
                    };

                    var putResponse = s3Client.PutBucketNotification(putRequest);

                    Assert.AreEqual(HttpStatusCode.OK, putResponse.HttpStatusCode);

                    var getRequest = new GetBucketNotificationRequest
                    {
                        BucketName = bucketName
                    };

                    var getResponse = s3Client.GetBucketNotification(getRequest);

                    Assert.IsNotNull(getResponse.EventBridgeConfiguration);
                }
                finally
                {
                    AmazonS3Util.DeleteS3BucketWithObjects(s3Client, bucketName);
                }
            }
        }
        public void BucketIntelligentTieringConfigurationsPrefixFilterTest()
        {
            var intelligentTieringFilter = new IntelligentTieringFilter()
            {
                IntelligentTieringFilterPredicate = new IntelligentTieringPrefixPredicate("string")
            };

            var putBucketIntelligentTieringConfigurationRequest  = GeneratePutRequest(intelligentTieringId, intelligentTieringFilter);
            var putBucketIntelligentTieringConfigurationResponse = Client.PutBucketIntelligentTieringConfiguration(putBucketIntelligentTieringConfigurationRequest);

            GetBucketIntelligentTieringConfigurationRequest getBucketIntelligentTieringConfigurationRequest = new GetBucketIntelligentTieringConfigurationRequest()
            {
                IntelligentTieringId = intelligentTieringId,
                BucketName           = bucketName
            };

            var getBucketIntelligentTieringConfigurationResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetBucketIntelligentTieringConfiguration(getBucketIntelligentTieringConfigurationRequest);
                return(res.IntelligentTieringConfiguration?.IntelligentTieringId == getBucketIntelligentTieringConfigurationRequest.IntelligentTieringId ? res : null);
            });

            var getConfiguration = getBucketIntelligentTieringConfigurationResponse.IntelligentTieringConfiguration;
            var putConfiguration = putBucketIntelligentTieringConfigurationRequest.IntelligentTieringConfiguration;

            Assert.AreEqual(getConfiguration.IntelligentTieringId, putConfiguration.IntelligentTieringId);
            Assert.AreEqual(((IntelligentTieringPrefixPredicate)getConfiguration.IntelligentTieringFilter.IntelligentTieringFilterPredicate).Prefix, "string");
        }
Пример #15
0
        public void BucketMetricsConfigurationsAndFilterTest()
        {
            Tag tag = new Tag()
            {
                Key   = "tagK",
                Value = "tagV"
            };
            List <MetricsFilterPredicate> list = new List <MetricsFilterPredicate>();

            list.Add(new MetricsPrefixPredicate("string"));
            list.Add(new MetricsTagPredicate(tag));
            PutBucketMetricsConfigurationRequest putBucketMetricsConfigurationRequest = new PutBucketMetricsConfigurationRequest()
            {
                BucketName           = bucketName,
                MetricsId            = "configId",
                MetricsConfiguration = new MetricsConfiguration()
                {
                    MetricsId     = "configId",
                    MetricsFilter = new MetricsFilter()
                    {
                        MetricsFilterPredicate = new MetricsAndOperator(list)
                    }
                }
            };
            var putBucketMetricsConfigurationResponse = Client.PutBucketMetricsConfiguration(putBucketMetricsConfigurationRequest);

            GetBucketMetricsConfigurationRequest getBucketMetricsConfigurationRequest = new GetBucketMetricsConfigurationRequest()
            {
                MetricsId  = "configId",
                BucketName = bucketName
            };

            var getBucketMetricsConfigurationResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetBucketMetricsConfiguration(getBucketMetricsConfigurationRequest);
                return(res.MetricsConfiguration?.MetricsId == getBucketMetricsConfigurationRequest.MetricsId ? res : null);
            });

            var getMetricsConfiguration = getBucketMetricsConfigurationResponse.MetricsConfiguration;
            var putMetricsConfiguration = putBucketMetricsConfigurationRequest.MetricsConfiguration;

            Assert.AreEqual(getMetricsConfiguration.MetricsId, putMetricsConfiguration.MetricsId);

            foreach (var predicate in ((MetricsNAryOperator)getMetricsConfiguration.MetricsFilter.MetricsFilterPredicate).Operands)
            {
                if (predicate is MetricsPrefixPredicate)
                {
                    Assert.AreEqual(((MetricsPrefixPredicate)predicate).Prefix, "string");
                }
                else
                {
                    Assert.AreEqual(((MetricsTagPredicate)predicate).Tag.Key, "tagK");
                    Assert.AreEqual(((MetricsTagPredicate)predicate).Tag.Value, "tagV");
                }
            }

            ListBucketMetrics();

            DeleteBucketMetricsAndValidate();
        }
Пример #16
0
        public void TestPostUpload()
        {
            var region = RegionEndpoint.USWest1;

            using (var client = new AmazonS3Client(region))
            {
                var bucketName = S3TestUtils.CreateBucket(client);
                client.PutACL(new PutACLRequest
                {
                    BucketName = bucketName,
                    CannedACL  = S3CannedACL.BucketOwnerFullControl
                });

                var credentials = GetCredentials(client);
                try
                {
                    var response = testPost("foo/bar/content.txt", bucketName, testContentStream("Line one\nLine two\nLine three\n"), "", credentials, region);
                    Assert.IsNotNull(response.RequestId);
                    Assert.IsNotNull(response.HostId);
                    Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
                }
                finally
                {
                    AmazonS3Util.DeleteS3BucketWithObjects(client, bucketName);
                }
            }
        }
        public void BucketAnalyticsConfigurationsPrefixFilterTest()
        {
            PutBucketAnalyticsConfigurationRequest putBucketAnalyticsConfigurationRequest = new PutBucketAnalyticsConfigurationRequest()
            {
                BucketName             = bucketName,
                AnalyticsId            = "configId",
                AnalyticsConfiguration = new AnalyticsConfiguration()
                {
                    AnalyticsFilter = new AnalyticsFilter()
                    {
                        AnalyticsFilterPredicate = new AnalyticsPrefixPredicate("string")
                    },
                    AnalyticsId          = "configId",
                    StorageClassAnalysis = new StorageClassAnalysis()
                    {
                        DataExport = new StorageClassAnalysisDataExport()
                        {
                            OutputSchemaVersion = StorageClassAnalysisSchemaVersion.V_1,
                            Destination         = new AnalyticsExportDestination()
                            {
                                S3BucketDestination = new AnalyticsS3BucketDestination()
                                {
                                    Format          = AnalyticsS3ExportFileFormat.CSV,
                                    BucketAccountId = "599169622985",
                                    Prefix          = "string",
                                    BucketName      = "arn:aws:s3:::" + bucketName
                                }
                            }
                        }
                    }
                }
            };
            var putBucketAnalyticsConfigurationResponse = Client.PutBucketAnalyticsConfiguration(putBucketAnalyticsConfigurationRequest);

            GetBucketAnalyticsConfigurationRequest getBucketAnalyticsConfigurationRequest = new GetBucketAnalyticsConfigurationRequest()
            {
                BucketName  = bucketName,
                AnalyticsId = "configId"
            };

            var getBucketAnalyticsConfigurationResponse = S3TestUtils.WaitForConsistency(() =>
            {
                var res = Client.GetBucketAnalyticsConfiguration(getBucketAnalyticsConfigurationRequest);
                return(res.AnalyticsConfiguration?.AnalyticsId == putBucketAnalyticsConfigurationRequest.AnalyticsConfiguration.AnalyticsId ? res : null);
            });

            var getAnalyticsConfiguration = getBucketAnalyticsConfigurationResponse.AnalyticsConfiguration;
            var putAnalyticsConfiguration = putBucketAnalyticsConfigurationRequest.AnalyticsConfiguration;

            Assert.AreEqual(((AnalyticsPrefixPredicate)getAnalyticsConfiguration.AnalyticsFilter.AnalyticsFilterPredicate).Prefix, "string");

            GetBucketAnalyticsValidation(getAnalyticsConfiguration, putAnalyticsConfiguration);


            ListBucketAnalytics();

            DeleteAnalyticsBucketAndValidate();
        }
Пример #18
0
        public void TestInitialize()
        {
            transferClient = new TransferUtility(Client);

            tempFilePath = System.IO.Path.GetTempFileName();
            bucketName   = S3TestUtils.CreateBucket(Client);

            UtilityMethods.GenerateFile(tempFilePath, 1024 * 1024 * 20);
        }
Пример #19
0
        public static void Cleanup()
        {
            // Delete the objects in the MRAP bucket, but leave the
            // MRAP and bucket for future test runs
            S3TestUtils.DeleteObjects(Client, _mrapArn);

            // Delete the entire bucket used for the SigV4 tests
            AmazonS3Util.DeleteS3BucketWithObjects(Client, _bucketName);
        }
Пример #20
0
        public void ServerSideEncryptionBYOKTransferUtility()
        {
            var bucketName = S3TestUtils.CreateBucket(Client);

            try
            {
                Aes aesEncryption = Aes.Create();
                aesEncryption.KeySize = 256;
                aesEncryption.GenerateKey();
                string base64Key = Convert.ToBase64String(aesEncryption.Key);

                TransferUtility utility = new TransferUtility(Client);

                var uploadRequest = new TransferUtilityUploadRequest
                {
                    BucketName = bucketName,
                    Key        = key,
                    ServerSideEncryptionCustomerMethod      = ServerSideEncryptionCustomerMethod.AES256,
                    ServerSideEncryptionCustomerProvidedKey = base64Key
                };

                uploadRequest.InputStream = new MemoryStream(UTF8Encoding.UTF8.GetBytes("Encrypted Content"));

                utility.Upload(uploadRequest);

                GetObjectMetadataRequest getObjectMetadataRequest = new GetObjectMetadataRequest
                {
                    BucketName = bucketName,
                    Key        = key,

                    ServerSideEncryptionCustomerMethod      = ServerSideEncryptionCustomerMethod.AES256,
                    ServerSideEncryptionCustomerProvidedKey = base64Key
                };

                GetObjectMetadataResponse getObjectMetadataResponse = Client.GetObjectMetadata(getObjectMetadataRequest);
                Assert.AreEqual(ServerSideEncryptionCustomerMethod.AES256, getObjectMetadataResponse.ServerSideEncryptionCustomerMethod);

                var openRequest = new TransferUtilityOpenStreamRequest
                {
                    BucketName = bucketName,
                    Key        = key,

                    ServerSideEncryptionCustomerMethod      = ServerSideEncryptionCustomerMethod.AES256,
                    ServerSideEncryptionCustomerProvidedKey = base64Key
                };

                using (var stream = new StreamReader(utility.OpenStream(openRequest)))
                {
                    var content = stream.ReadToEnd();
                    Assert.AreEqual(content, "Encrypted Content");
                }
            }
            finally
            {
                AmazonS3Util.DeleteS3BucketWithObjects(Client, bucketName);
            }
        }
Пример #21
0
        public static void Initialize(TestContext a)
        {
            StreamWriter writer = File.CreateText("PutObjectFile.txt");

            writer.Write("This is some sample text.!!");
            writer.Close();

            bucketName = S3TestUtils.CreateBucket(Client);
        }
Пример #22
0
        public void SetTopicConfigurationTests()
        {
            var s3Config = new AmazonS3Config();

            using (var s3Client = new AmazonS3Client(s3Config))
                using (var snsClient = new AmazonSimpleNotificationServiceClient())
                {
                    var snsCreateResponse = snsClient.CreateTopic("events-test-" + DateTime.Now.Ticks);
                    var bucketName        = S3TestUtils.CreateBucketWithWait(s3Client);

                    try
                    {
                        snsClient.AuthorizeS3ToPublish(snsCreateResponse.TopicArn, bucketName);

                        PutBucketNotificationRequest putRequest = new PutBucketNotificationRequest
                        {
                            BucketName          = bucketName,
                            TopicConfigurations = new List <TopicConfiguration>
                            {
                                new TopicConfiguration
                                {
                                    Id     = "the-topic-test",
                                    Topic  = snsCreateResponse.TopicArn,
                                    Events = new List <EventType> {
                                        EventType.ObjectCreatedPut
                                    }
                                }
                            }
                        };

                        s3Client.PutBucketNotification(putRequest);

                        var getResponse = S3TestUtils.WaitForConsistency(() =>
                        {
                            var res = s3Client.GetBucketNotification(bucketName);
                            return(res.TopicConfigurations?.Count > 0 && res.TopicConfigurations[0].Id == "the-topic-test" ? res : null);
                        });

                        Assert.AreEqual(1, getResponse.TopicConfigurations.Count);
                        Assert.AreEqual(1, getResponse.TopicConfigurations[0].Events.Count);
                        Assert.AreEqual(EventType.ObjectCreatedPut, getResponse.TopicConfigurations[0].Events[0]);

#pragma warning disable 618
                        Assert.AreEqual("s3:ObjectCreated:Put", getResponse.TopicConfigurations[0].Event);
#pragma warning restore 618
                        Assert.AreEqual("the-topic-test", getResponse.TopicConfigurations[0].Id);
                        Assert.AreEqual(snsCreateResponse.TopicArn, getResponse.TopicConfigurations[0].Topic);
                    }
                    finally
                    {
                        snsClient.DeleteTopic(snsCreateResponse.TopicArn);
                        AmazonS3Util.DeleteS3BucketWithObjects(s3Client, bucketName);
                    }
                }
        }
Пример #23
0
        public static void Initialize(TestContext a)
        {
            bucketName = S3TestUtils.CreateBucketWithWait(Client);

            Client.PutObject(new PutObjectRequest
            {
                BucketName  = bucketName,
                ContentBody = content,
                Key         = "TestObject"
            });
        }
Пример #24
0
 private void WaitForEnabledVersioning(IAmazonS3 client, string bucketName)
 {
     S3TestUtils.WaitForConsistency(() =>
     {
         var res = client.GetBucketVersioning(new GetBucketVersioningRequest
         {
             BucketName = bucketName
         });
         return(res.VersioningConfig?.Status == VersionStatus.Enabled ? res : null);
     });
 }
        public static void CreateTestBase()
        {
            Client     = new AmazonS3Client();
            bucketName = S3TestUtils.CreateBucket(Client);


            Client.PutObject(new PutObjectRequest
            {
                BucketName = bucketName
            });
        }
Пример #26
0
        public static void Initialize(TestContext testContext)
        {
            _bucketName = S3TestUtils.CreateBucketWithWait(Client);
            _keyName    = UtilityMethods.GenerateName(nameof(SelectObjectContentTests));

            Client.PutObject(new PutObjectRequest()
            {
                BucketName  = _bucketName,
                Key         = _keyName,
                ContentBody = TestContent
            });
        }
Пример #27
0
 public static void Initialize(TestContext tc)
 {
     bucketName = S3TestUtils.CreateBucket(Client);
     Client.PutBucketVersioning(new PutBucketVersioningRequest
     {
         BucketName       = bucketName,
         VersioningConfig = new S3BucketVersioningConfig
         {
             Status = VersionStatus.Enabled
         }
     });
 }
Пример #28
0
        public void DeleteBucketUsingS3RegionUSEast1Enum()
        {
            using (var runner = new BucketRegionTestRunner(true, true))
            {
                var bucketName = S3TestUtils.CreateBucketWithWait(runner.USEast1Client);

                runner.USWest1Client.DeleteBucket(new DeleteBucketRequest
                {
                    BucketName   = bucketName,
                    BucketRegion = S3Region.US
                });
            }
        }
        private string CreateBucketAndObject(AmazonS3Client client)
        {
            var bucketName = S3TestUtils.CreateBucketWithWait(client);

            client.PutObject(new PutObjectRequest
            {
                BucketName  = bucketName,
                Key         = TestKey,
                ContentBody = TestContent
            });
            S3TestUtils.WaitForObject(client, bucketName, TestKey, 30);
            return(bucketName);
        }
Пример #30
0
        public static void Cleanup()
        {
            var deleteRequest = new DeleteMultiRegionAccessPointRequest
            {
                AccountId = _accountId,
                Details   = new DeleteMultiRegionAccessPointInput {
                    Name = _mrapName
                }
            };

            S3TestUtils.DeleteMRAPWithWait(new AmazonS3ControlClient(RegionEndpoint.USWest2), deleteRequest);
            AmazonS3Util.DeleteS3BucketWithObjects(Client, _bucketName);
        }