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 ListBuckets() { string tempBucketName = "testbucket-" + Guid.NewGuid(); await BucketClient.CreateBucketAsync(tempBucketName).ConfigureAwait(false); HeadBucketResponse headResp = await BucketClient.HeadBucketAsync(tempBucketName).ConfigureAwait(false); Assert.Equal(200, headResp.StatusCode); }
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 ListBuckets() { string tempBucketName = "testbucket-" + Guid.NewGuid(); await BucketClient.CreateBucketAsync(tempBucketName).ConfigureAwait(false); ListBucketsResponse listResp = await BucketClient.ListBucketsAsync().ConfigureAwait(false); Assert.True(listResp.Buckets.Count > 0); S3Bucket bucketObj = Assert.Single(listResp.Buckets, bucket => bucket.Name == tempBucketName); Assert.Equal(bucketObj.CreatedOn.UtcDateTime, DateTime.UtcNow, TimeSpan.FromSeconds(5)); }
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); }
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); } }