public async Task CRUDTest() { string bucket1 = "testbucket-" + Guid.NewGuid(); string bucket2 = "testbucket-" + Guid.NewGuid(); await BucketClient.PutBucketAsync(bucket1, AwsRegion.EUWest1).ConfigureAwait(false); await BucketClient.PutBucketAsync(bucket2, AwsRegion.EUWest1).ConfigureAwait(false); List <S3Bucket> list = await ServiceClient.GetServiceAllAsync().ToListAsync().ConfigureAwait(false); Assert.True(list.Count >= 2); //Larger than because other tests might have run at the same time S3Bucket bucket1obj = Assert.Single(list, x => x.Name == bucket1); Assert.Equal(DateTime.UtcNow, bucket1obj.CreationDate.DateTime, TimeSpan.FromSeconds(5)); S3Bucket bucket2obj = Assert.Single(list, x => x.Name == bucket2); Assert.Equal(DateTime.UtcNow, bucket2obj.CreationDate.DateTime, TimeSpan.FromSeconds(5)); //Cleanup await BucketClient.DeleteBucketAsync(bucket1).ConfigureAwait(false); await BucketClient.DeleteBucketAsync(bucket2).ConfigureAwait(false); }
public async Task GetPutBucketLockConfiguration(LockMode mode) { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse createResp = await BucketClient.CreateBucketAsync(tempBucketName, req => req.EnableObjectLocking = true).ConfigureAwait(false); Assert.True(createResp.IsSuccess); PutBucketLockConfigurationResponse putResp = await BucketClient.PutBucketLockConfigurationAsync(tempBucketName, true, x => { x.LockMode = mode; x.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(2); }).ConfigureAwait(false); Assert.True(putResp.IsSuccess); GetBucketLockConfigurationResponse getResp = await BucketClient.GetBucketLockConfigurationAsync(tempBucketName).ConfigureAwait(false); Assert.True(getResp.IsSuccess); Assert.Equal(mode, getResp.LockMode); Assert.Equal(DateTimeOffset.UtcNow.AddDays(2 - 1).DateTime, getResp.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1)); //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task CreateBucket() { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse resp = await BucketClient.CreateBucketAsync(tempBucketName).ConfigureAwait(false); Assert.True(resp.IsSuccess); //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task CreateBucketObjectLocking() { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse resp = await BucketClient.CreateBucketAsync(tempBucketName, req => req.EnableObjectLocking = true).ConfigureAwait(false); Assert.True(resp.IsSuccess); //TODO: Check locking is enabled once we have that functionality //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task CreateBucketCannedAcl() { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse resp = await BucketClient.CreateBucketAsync(tempBucketName, req => req.Acl = BucketCannedAcl.PublicReadWrite).ConfigureAwait(false); Assert.True(resp.IsSuccess); //TODO: Check ACL once we have that functionality //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task GetEmptyBucketLock() { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse createResp = await BucketClient.CreateBucketAsync(tempBucketName, req => req.EnableObjectLocking = true).ConfigureAwait(false); Assert.True(createResp.IsSuccess); GetBucketLockConfigurationResponse getResp = await BucketClient.GetBucketLockConfigurationAsync(tempBucketName).ConfigureAwait(false); Assert.True(getResp.IsSuccess); Assert.Equal(LockMode.Unknown, getResp.LockMode); Assert.Null(getResp.LockRetainUntil); //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task CreateBucketCustomAcl() { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse resp = await BucketClient.CreateBucketAsync(tempBucketName, req => { req.AclGrantReadAcp.AddEmail(TestConstants.TestEmail); req.AclGrantWriteAcp.AddEmail(TestConstants.TestEmail); req.AclGrantRead.AddEmail(TestConstants.TestEmail); req.AclGrantWrite.AddEmail(TestConstants.TestEmail); req.AclGrantFullControl.AddEmail(TestConstants.TestEmail); }).ConfigureAwait(false); Assert.True(resp.IsSuccess); //TODO: Check ACL once we have that functionality //Delete again to cleanup await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); }
public async Task DeleteBucket() { string tempBucketName = "testbucket-" + Guid.NewGuid(); DeleteBucketResponse deleteResp1 = await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); Assert.False(deleteResp1.IsSuccess); Assert.Equal(ErrorCode.NoSuchBucket, deleteResp1.Error?.Code); await BucketClient.CreateBucketAsync(tempBucketName).ConfigureAwait(false); DeleteBucketResponse deleteResp2 = await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); Assert.True(deleteResp2.IsSuccess); Assert.Equal(204, deleteResp2.StatusCode); ListObjectsResponse listResp = await ObjectClient.ListObjectsAsync(tempBucketName).ConfigureAwait(false); Assert.False(listResp.IsSuccess); Assert.Equal(404, listResp.StatusCode); }
public async Task DeleteBucket() { string tempBucketName = "testbucket-" + Guid.NewGuid(); DeleteBucketResponse delete1 = await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); Assert.False(delete1.IsSuccess); Assert.Equal(ErrorCode.NoSuchBucket, delete1.Error.Code); await BucketClient.PutBucketAsync(tempBucketName, request => request.Region = Config.Region).ConfigureAwait(false); DeleteBucketResponse delete2 = await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); Assert.True(delete2.IsSuccess); Assert.Equal(204, delete2.StatusCode); GetBucketResponse resp = await BucketClient.GetBucketAsync(tempBucketName).ConfigureAwait(false); Assert.False(resp.IsSuccess); Assert.Equal(404, resp.StatusCode); }
protected async Task CreateTempBucketAsync(Func <string, Task> action) { string tempBucketName = "testbucket-" + Guid.NewGuid(); CreateBucketResponse createResponse = await BucketClient.CreateBucketAsync(tempBucketName).ConfigureAwait(false); Assert.True(createResponse.IsSuccess); try { await action(tempBucketName).ConfigureAwait(false); } finally { DeleteAllObjectsStatus delResp = await ObjectClient.DeleteAllObjectsAsync(tempBucketName).ConfigureAwait(false); Assert.Equal(DeleteAllObjectsStatus.Ok, delResp); DeleteBucketResponse del2Resp = await BucketClient.DeleteBucketAsync(tempBucketName).ConfigureAwait(false); Assert.True(del2Resp.IsSuccess); } }