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 OverwriteExistingLock(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            PutBucketLockConfigurationResponse putResp = await client.PutBucketLockConfigurationAsync(tempBucket, true, r =>
            {
                r.LockMode        = LockMode.Compliance;
                r.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(2);
            }).ConfigureAwait(false);
            Assert.Equal(200, putResp.StatusCode);

            GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, getResp.StatusCode);
            Assert.Equal(LockMode.Compliance, getResp.LockMode);
            Assert.Equal(DateTimeOffset.UtcNow.AddDays(2 - 1).DateTime, getResp.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1));

            PutBucketLockConfigurationResponse putResp2 = await client.PutBucketLockConfigurationAsync(tempBucket, true, r =>
            {
                r.LockMode        = LockMode.Governance;
                r.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(5);
            }).ConfigureAwait(false);
            Assert.Equal(200, putResp2.StatusCode);

            GetBucketLockConfigurationResponse getResp2 = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, getResp2.StatusCode);
            Assert.Equal(LockMode.Governance, getResp2.LockMode);
            Assert.Equal(DateTimeOffset.UtcNow.AddDays(5 - 1).DateTime, getResp2.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1));
        }).ConfigureAwait(false);
    }
 public async Task GetWhenBucketLockIsDisabled()
 {
     await CreateTempBucketAsync(async x =>
     {
         GetBucketLockConfigurationResponse getResp = await BucketClient.GetBucketLockConfigurationAsync(x).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
 public async Task GetWhenBucketLockIsDisabled(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
 public async Task GetEmptyBucketLock(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(200, getResp.StatusCode);
         Assert.Equal(LockMode.Unknown, getResp.LockMode);
         Assert.Null(getResp.LockRetainUntil);
     }, r => r.EnableObjectLocking = true).ConfigureAwait(false);
 }
    public async Task GetPutBucketLockConfiguration(S3Provider provider, string _, ISimpleClient client, LockMode mode)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            PutBucketLockConfigurationResponse putResp = await client.PutBucketLockConfigurationAsync(tempBucket, true, x =>
            {
                x.LockMode        = mode;
                x.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(2);
            }).ConfigureAwait(false);
            Assert.Equal(200, putResp.StatusCode);

            GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, getResp.StatusCode);
            Assert.Equal(mode, getResp.LockMode);
            Assert.Equal(DateTimeOffset.UtcNow.AddDays(2 - 1).DateTime, getResp.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1));
        }, r => r.EnableObjectLocking = true).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);
        }