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);
        }
Пример #2
0
        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 = Client.GetObjectLegalHold(getRequest);

            Assert.AreEqual(true, getResponse.HttpStatusCode == HttpStatusCode.OK);
            Assert.AreEqual(status, getResponse.LegalHold.Status);
        }