public void TestPutObjectAPMKMS() { // Request object is modified internally, therefore, it is required to have separate requests for every test PutObjectRequest requestV1 = new PutObjectRequest() { BucketName = bucketName, Key = $"key-{Guid.NewGuid()}", ContentBody = SampleContent }; AssertExtensions.ExpectException(() => { PutObjectResponse response = s3EncryptionClientMetadataModeKMSV1N.EndPutObject( s3EncryptionClientMetadataModeKMSV1N.BeginPutObject(requestV1, null, null)); }, typeof(NotSupportedException), APMKMSErrorRegex); PutObjectRequest requestV2 = new PutObjectRequest() { BucketName = bucketName, Key = $"key-{Guid.NewGuid()}", ContentBody = SampleContent }; AssertExtensions.ExpectException(() => { PutObjectResponse response = s3EncryptionClientMetadataModeKMSV2.EndPutObject( s3EncryptionClientMetadataModeKMSV2.BeginPutObject(requestV2, null, null)); }, typeof(NotSupportedException), APMKMSErrorRegex); }
private static void TestPutGetAPM(AmazonS3EncryptionClient s3EncryptionClient, string filePath, byte[] inputStreamBytes, string contentBody, S3CannedACL cannedACL, string expectedContent) { PutObjectRequest request = new PutObjectRequest() { BucketName = bucketName, Key = "key-" + random.Next(), FilePath = filePath, InputStream = inputStreamBytes == null ? null : new MemoryStream(inputStreamBytes), ContentBody = contentBody, CannedACL = cannedACL }; PutObjectResponse response = s3EncryptionClient.EndPutObject(s3EncryptionClient.BeginPutObject(request, null, null)); TestGetAPM(request.Key, expectedContent, s3EncryptionClient); }
public void TestPutObjectAPMKMS() { PutObjectRequest request = new PutObjectRequest() { BucketName = bucketName, Key = "key-" + random.Next(), ContentBody = sampleContent, CannedACL = S3CannedACL.AuthenticatedRead }; AssertExtensions.ExpectException(() => { PutObjectResponse response = s3EncryptionClientMetadataModeKMS.EndPutObject( s3EncryptionClientMetadataModeKMS.BeginPutObject(request, null, null)); }, typeof(NotSupportedException), APMKMSErrorRegex); }