Beispiel #1
0
        public void FipsExceptionUseArnRegionTrue()
        {
            try
            {
                var outpostsArn = "arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint";
                var request     = new PutObjectRequest
                {
                    BucketName  = outpostsArn,
                    Key         = "foo.txt",
                    ContentBody = "data"
                };

                var config = new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.GetBySystemName("fips-us-gov-east-1"),
                    UseArnRegion   = true
                };
                S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.Fail("AmazonClientException expected");
            }
            catch (AmazonClientException e)
            {
                Assert.AreEqual("Invalid configuration outpost access points do not support Fips- regions", e.Message);
            }
        }
Beispiel #2
0
        public void InvalidConfigurationTests(string arnString, string region, S3ConfigFlags flags, string expectedErrorMessage)
        {
            Exception exception = null;
            IRequest  result    = null;

            try
            {
                var request = new GetObjectRequest
                {
                    BucketName = arnString,
                    Key        = "foo.txt"
                };

                var config = S3ArnTestUtils.BuildFromRegionSystemName(region, flags);

                result = S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);
            }
            catch (Exception e)
            {
                exception = e;
            }

            Assert.IsNotNull(exception, "Expected exception, but got result " + result?.Endpoint);
            if (region == string.Empty)
            {
                Assert.IsInstanceOfType(exception, typeof(ArgumentException), "ArgumentException expected");
            }
            else
            {
                Assert.IsInstanceOfType(exception, typeof(AmazonClientException), "AmazonClientException expected");
            }
            Assert.AreEqual(expectedErrorMessage, exception.Message);
        }
Beispiel #3
0
        public void InvalidArn(string invalidArn)
        {
            try
            {
                var outpostsArn = invalidArn;
                var request     = new PutObjectRequest
                {
                    BucketName  = outpostsArn,
                    Key         = "foo.txt",
                    ContentBody = "data"
                };

                var config = new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.USWest2,
                    UseArnRegion   = true,
                };
                S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.Fail("AmazonClientException expected");
            }
            catch (AmazonClientException e)
            {
                Assert.AreEqual($"Invalid ARN: {invalidArn}/foo.txt, outpost resource format is incorrect", e.Message);
            }
        }
Beispiel #4
0
        public void AccelerateException()
        {
            try
            {
                var outpostsArn = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint";
                var request     = new PutObjectRequest
                {
                    BucketName  = outpostsArn,
                    Key         = "foo.txt",
                    ContentBody = "data"
                };

                var config = new AmazonS3Config
                {
                    RegionEndpoint        = RegionEndpoint.USWest2,
                    UseArnRegion          = true,
                    UseAccelerateEndpoint = true
                };
                S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.Fail("AmazonClientException expected");
            }
            catch (AmazonClientException e)
            {
                Assert.AreEqual("Invalid configuration outpost access points do not support accelerate", e.Message);
            }
        }
        public void InvalidConfigurationCrossPartitionTest()
        {
            var errorMessage = "Invalid configuration, cross partition S3ObjectLambda access point ARN";

            try
            {
                var arnString = "arn:aws-cn:s3-object-lambda:cn-north-1:123456789012:accesspoint/mybanner";
                var request   = new GetObjectRequest
                {
                    BucketName = arnString,
                    Key        = "foo.txt"
                };

                var config = new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.USWest2,
                    UseArnRegion   = true
                };

                S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);
                Assert.Fail("AmazonClientException expected");
            }
            catch (AmazonClientException e)
            {
                Assert.AreEqual(errorMessage, e.Message);
            }
        }
Beispiel #6
0
        public void InvalidArnOutpostId()
        {
            try
            {
                var outpostsArn = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-0123456.890123456:accesspoint:myaccesspoint";
                var request     = new PutObjectRequest
                {
                    BucketName  = outpostsArn,
                    Key         = "foo.txt",
                    ContentBody = "data"
                };

                var config = new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.USWest2,
                    UseArnRegion   = true,
                };
                S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.Fail("AmazonClientException expected");
            }
            catch (AmazonClientException e)
            {
                Assert.AreEqual("Invalid outpost ID: op-0123456.890123456. ID must contain only alphanumeric characters and dashes", e.Message);
            }
        }
        public void TestAccessPointArnVariations(string accessPointArn, string region, AdditionalFlags flags, bool useArnRegion, string host)
        {
            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint        = RegionEndpoint.GetBySystemName(region),
                UseArnRegion          = useArnRegion,
                UseDualstackEndpoint  = (flags & AdditionalFlags.Dualstack) != 0,
                UseAccelerateEndpoint = (flags & AdditionalFlags.Accelerate) != 0,
            };

            if (string.IsNullOrEmpty(host))
            {
                try
                {
                    S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                    Assert.Fail("Request should have failed");
                }
                catch (AmazonClientException)
                {
                }
            }
            else
            {
                var internalRequest = S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
                Assert.AreEqual(new Uri($"https://{host}"), internalRequest.Endpoint);
                Assert.AreEqual("/foo.txt", internalRequest.ResourcePath);
            }
        }
Beispiel #8
0
        public void ThrowExceptionCustomEndpointAndOutpostsDualstackNotSupported()
        {
            var request = new ListObjectsRequest
            {
                BucketName = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"
            };

            var config = CreateConfig("https://beta.example.com", Flags.Dualstack);

            S3ArnTestUtils.RunMockRequest(request, ListObjectsRequestMarshaller.Instance, config);
        }
        public void AbortMultipartUploadTest()
        {
            var accessPointArn = "arn:aws:s3:us-east-1:000011112222:accesspoint/testpoint";

            var request = new AbortMultipartUploadRequest
            {
                BucketName = accessPointArn,
                Key        = "foo.txt"
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, AbortMultipartUploadRequestMarshaller.Instance);

            Assert.AreEqual(new Uri("https://testpoint-000011112222.s3-accesspoint.us-east-1.amazonaws.com"), internalRequest.Endpoint);
            Assert.AreEqual("/foo.txt", internalRequest.ResourcePath);
        }
Beispiel #10
0
        public void CustomEndpointUrlTest(string arnString, string serviceUrl, bool useArnRegion, string expectedEndpointHost)
        {
            var request = new GetObjectRequest
            {
                BucketName = arnString,
                Key        = "foo.txt"
            };

            var config = new AmazonS3Config
            {
                ServiceURL   = serviceUrl,
                UseArnRegion = useArnRegion
            };
            var internalRequest = S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);

            Assert.AreEqual(expectedEndpointHost, internalRequest.Endpoint.Host);
        }
Beispiel #11
0
        public void ValidConfigurationsTest(string arnString, string clientRegion, bool useArnRegion, string expectedEndpointHost)
        {
            var request = new GetObjectRequest
            {
                BucketName = arnString,
                Key        = "foo.txt"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.GetBySystemName(clientRegion),
                UseArnRegion   = useArnRegion
            };
            var internalRequest = S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);

            Assert.AreEqual(expectedEndpointHost, internalRequest.Endpoint.Host);
        }
        public void PreSignedUrlTest(string accessPointArn, S3ConfigFlags flags, string expectedHost, string expectedQueryStringPiece, string expectedErrorMessage)
        {
            var request = new GetPreSignedUrlRequest
            {
                BucketName = accessPointArn,
                Key        = "foo.txt",
                Expires    = DateTime.Now.AddDays(1),
                Verb       = HttpVerb.GET
            };

            var config   = S3ArnTestUtils.BuildFromRegionSystemName("us-east-1", flags);
            var s3Client = new AmazonS3Client("access", "secret", config);

            Exception exception = null;
            Uri       uri       = null;

            try
            {
                uri = new Uri(s3Client.GetPreSignedURL(request));
            }
            catch (AmazonClientException e)
            {
                exception = e;
            }

            if (!string.IsNullOrEmpty(expectedHost))
            {
                Assert.IsNull(exception, "Unexpected exception was thrown: " + exception?.Message);

                Assert.IsNotNull(uri);
                Assert.AreEqual(expectedHost, uri.Host);
                Assert.AreEqual("/foo.txt", uri.AbsolutePath);
                Assert.IsTrue(uri.Query.Contains(expectedQueryStringPiece), $"Expected to find {expectedQueryStringPiece} in {uri.Query}");
            }
            else if (!string.IsNullOrEmpty(expectedErrorMessage))
            {
                Assert.IsNotNull(exception);
                Assert.IsInstanceOfType(exception, typeof(AmazonClientException));
                Assert.AreEqual(expectedErrorMessage, exception.Message);
            }
            else
            {
                Assert.Fail($"Bad test setup, {nameof(expectedHost)} or {nameof(expectedErrorMessage)} must be provided");
            }
        }
        public void ThrowExceptionUsingServiceUrl()
        {
            var accessPointArn = "arn:aws:s3:eu-central-1:000011112222:accesspoint/testpoint";

            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                ServiceURL = "https://s3.amazonaws.com"
            };

            S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
        }
        public void ThrowExceptionAccessPointAndServiceClientDifferentRegions()
        {
            var accessPointArn = "arn:aws:s3:eu-central-1:000011112222:accesspoint/testpoint";

            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USEast2
            };

            S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
        }
        public void CopyObjectValidAccessPoint()
        {
            var accessPointDestinationArn = "arn:aws:s3:us-east-1:000011112222:accesspoint/destinationpoint";
            var accessPointSourceArn      = "arn:aws:s3:us-east-1:000011112222:accesspoint/sourcepoint";

            var request = new CopyObjectRequest
            {
                SourceBucket      = accessPointSourceArn,
                SourceKey         = "source.txt",
                DestinationBucket = accessPointDestinationArn,
                DestinationKey    = "dest.txt"
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, CopyObjectRequestMarshaller.Instance);

            Assert.AreEqual(new Uri("https://destinationpoint-000011112222.s3-accesspoint.us-east-1.amazonaws.com"), internalRequest.Endpoint);
            Assert.AreEqual("/dest.txt", internalRequest.ResourcePath);
            Assert.AreEqual("arn%3Aaws%3As3%3Aus-east-1%3A000011112222%3Aaccesspoint%2Fsourcepoint%2Fobject%2Fsource.txt", internalRequest.Headers["x-amz-copy-source"]);
        }
        public void ThrowExceptionWhenUsingDifferentPartitions()
        {
            var accessPointArn = "arn:aws-cn:s3:cn-north-1:000011112222:accesspoint/testpoint";

            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USEast2,
                UseArnRegion   = true
            };

            S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
        }
        /// <summary>
        /// Test helper for S3 access point tests
        /// </summary>
        /// <param name="accessPointArn">Access point ARN (BucketName on the request)</param>
        /// <param name="region">Region, to be set on AmazonS3Config's RegionEndpoint</param>
        /// <param name="flags">Bit field of additional AmazonS3Config settings</param>
        /// <param name="host">Expected hostname, will be asserted for valid test cases</param>
        /// <param name="errorMessage">Expected error message, will be asserted for invalid test cases</param>
        /// <returns></returns>
        private IRequest TestAccessPointArnVariationHelper(string accessPointArn, string region, S3ConfigFlags flags, string host, string errorMessage)
        {
            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = S3ArnTestUtils.BuildFromRegionSystemName(region, flags);

            Exception exception         = null;
            IRequest  marshalledRequest = null;

            try
            {
                marshalledRequest = S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);
            }
            catch (Exception e)
            {
                exception = e;
            }

            if (!string.IsNullOrEmpty(host))
            {
                Assert.IsNull(exception, "Exception was thrown: " + exception?.Message);

                Assert.AreEqual(new Uri($"https://{host}"), marshalledRequest.Endpoint);
                Assert.AreEqual("/foo.txt", marshalledRequest.ResourcePath);
            }
            else if (!string.IsNullOrEmpty(errorMessage))
            {
                Assert.IsNotNull(exception, "Expected exception, but got result " + marshalledRequest?.Endpoint);
                Assert.IsInstanceOfType(exception, typeof(AmazonClientException));
                Assert.AreEqual(errorMessage, exception.Message);
            }
            else
            {
                Assert.Fail($"Bad Test Data, you must provide either {nameof(host)} or {nameof(errorMessage)}");
            }
            return(marshalledRequest);
        }
        public void UseArnRegionDefaultToTrueForUSEast1()
        {
            var accessPointArn = "arn:aws:s3:eu-central-1:000011112222:accesspoint/testpoint";

            var request = new PutObjectRequest
            {
                BucketName  = accessPointArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USEast1
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);

            Assert.AreEqual(new Uri("https://testpoint-000011112222.s3-accesspoint.eu-central-1.amazonaws.com"), internalRequest.Endpoint);
        }
Beispiel #19
0
        public void UseArnRegionTrueUsEast1WithSlashes()
        {
            var outpostsArn      = "arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-01234567890123456/accesspoint/myaccesspoint";
            var expectedEndpoint = new Uri("https://myaccesspoint-123456789012.op-01234567890123456.s3-outposts.us-east-1.amazonaws.com");
            var request          = new PutObjectRequest
            {
                BucketName  = outpostsArn,
                Key         = "foo.txt",
                ContentBody = "data"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USWest2,
                UseArnRegion   = true
            };
            var internalRequest = S3ArnTestUtils.RunMockRequest(request, PutObjectRequestMarshaller.Instance, config);

            Assert.AreEqual(expectedEndpoint, internalRequest.Endpoint);
        }
Beispiel #20
0
        public void WriteGetObjectResponseTests(string clientRegion, string endpointUrl, string expectedEndpointHost)
        {
            var request = new WriteGetObjectResponseRequest
            {
                RequestRoute = "route",
                RequestToken = "token"
            };

            var config = new AmazonS3Config();

            config.RegionEndpoint = RegionEndpoint.GetBySystemName(clientRegion);
            if (!string.IsNullOrEmpty(endpointUrl))
            {
                config.ServiceURL = endpointUrl;
            }

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, WriteGetObjectResponseRequestMarshaller.Instance, config);

            Assert.AreEqual(expectedEndpointHost, internalRequest.Endpoint.Host);
        }
Beispiel #21
0
        public void S3ObjectLambdaSignerTest()
        {
            var signer = new S3Signer();

            var arnString = "arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner";
            var request   = new GetObjectRequest()
            {
                BucketName = arnString,
                Key        = "foo.txt"
            };
            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USEast1
            };
            var iRequest = S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);

            signer.Sign(iRequest, config, new RequestMetrics(), new ImmutableCredentials("ACCESS", "SECRET", ""));

            Assert.IsTrue(iRequest.Headers.ContainsKey(HeaderKeys.AuthorizationHeader));
            Assert.IsTrue((iRequest.Headers["Authorization"]).Contains("s3-object-lambda"));
        }
Beispiel #22
0
        public void WriteGetObjectResponseSignerTest()
        {
            var signer  = new S3Signer();
            var request = new WriteGetObjectResponseRequest
            {
                RequestRoute = "route",
                RequestToken = "token"
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.EUWest1
            };

            var iRequest = S3ArnTestUtils.RunMockRequest(request, WriteGetObjectResponseRequestMarshaller.Instance, config);

            signer.Sign(iRequest, config, new RequestMetrics(), new ImmutableCredentials("ACCESS", "SECRET", ""));

            Assert.IsTrue(iRequest.Headers.ContainsKey(HeaderKeys.AuthorizationHeader));
            Assert.IsTrue((iRequest.Headers["Authorization"]).Contains("s3-object-lambda"));
        }
Beispiel #23
0
        public void WriteGetObjectResponseWithWithChunkedEncodingTest()
        {
            var request = new WriteGetObjectResponseRequest
            {
                RequestRoute = "route",
                RequestToken = "token",
                Body         = new MyTestStream(100, false),
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USWest2
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, WriteGetObjectResponseRequestMarshaller.Instance, config);

            Assert.AreEqual(false, internalRequest.ContentStream.CanSeek);
            Assert.IsTrue(!internalRequest.Headers.ContainsKey("Content-Length"));
            Assert.IsTrue(internalRequest.Headers.ContainsKey("transfer-encoding"));
            Assert.AreEqual("chunked", internalRequest.Headers["transfer-encoding"]);
        }
Beispiel #24
0
        public void DeleteObjectsWithNewLinesTest(string objectKey, string expectedEscapedKey)
        {
            var request = new DeleteObjectsRequest
            {
                BucketName = "foo",
                Objects    = new System.Collections.Generic.List <KeyVersion>
                {
                    new KeyVersion {
                        Key = objectKey
                    }
                }
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, DeleteObjectsRequestMarshaller.Instance, new AmazonS3Config {
                RegionEndpoint = RegionEndpoint.USEast1
            });
            var content = System.Text.Encoding.UTF8.GetString(internalRequest.Content);

            Assert.IsFalse(content.Contains(objectKey));
            Assert.IsTrue(content.Contains(expectedEscapedKey));
        }
Beispiel #25
0
        public void ChecksumHeaderIsSetToPayload()
        {
            var request = new PutBucketEncryptionRequest
            {
                BucketName = "test",
                ContentMD5 = "test",
                ServerSideEncryptionConfiguration = new ServerSideEncryptionConfiguration
                {
                    ServerSideEncryptionRules = new List <ServerSideEncryptionRule>()
                    {
                        new ServerSideEncryptionRule {
                            BucketKeyEnabled = true
                        }
                    }
                }
            };

            var response = S3ArnTestUtils.RunMockRequest(request, PutBucketEncryptionRequestMarshaller.Instance);

            Assert.AreEqual(response.Headers[Amazon.Util.HeaderKeys.ContentMD5Header], "test");
        }
Beispiel #26
0
        public void TestOutpostArnVariations(string arnString, string region, S3ConfigFlags flags, string host, string errorMessage)
        {
            var request = new GetObjectRequest
            {
                BucketName = arnString,
                Key        = "foo.txt"
            };

            var config = S3ArnTestUtils.BuildFromRegionSystemName(region, flags);

            Exception exception = null;
            IRequest  result    = null;

            try
            {
                result = S3ArnTestUtils.RunMockRequest(request, GetObjectRequestMarshaller.Instance, config);
            }
            catch (Exception e)
            {
                exception = e;
            }

            if (!string.IsNullOrEmpty(host))
            {
                Assert.IsNull(exception, "Exception was thrown");

                Assert.AreEqual(new Uri($"https://{host}"), result.Endpoint);
                Assert.AreEqual("/foo.txt", result.ResourcePath);
            }
            else if (!string.IsNullOrEmpty(errorMessage))
            {
                Assert.IsNotNull(exception);
                Assert.IsInstanceOfType(exception, typeof(AmazonClientException));
                Assert.AreEqual(errorMessage, exception.Message);
            }
            else
            {
                Assert.Fail($"Bad Test Data, you must provide either {nameof(host)} or {nameof(errorMessage)}");
            }
        }
Beispiel #27
0
        private void RunTestRequest(AmazonWebServiceRequest request, IMarshaller <IRequest, AmazonWebServiceRequest> marshaller,
                                    bool isArn, string serviceUrl, Flags flags,
                                    string expectedUri, string expectedRegion, string expectedService)
        {
            var clientConfig = CreateConfig(serviceUrl, flags);

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, marshaller, clientConfig);

            Assert.AreEqual(new Uri(expectedUri), internalRequest.Endpoint);

            if (isArn)
            {
                Assert.AreEqual(expectedRegion, internalRequest.AuthenticationRegion);
                Assert.AreEqual(expectedService, internalRequest.OverrideSigningServiceName);
            }

            var service       = DetermineService(clientConfig);
            var signingRegion = AWS4Signer.DetermineSigningRegion(clientConfig, service, internalRequest.AlternateEndpoint, internalRequest);

            Assert.AreEqual(expectedRegion, signingRegion);
            Assert.AreEqual(expectedService, internalRequest.OverrideSigningServiceName ?? service);
        }
Beispiel #28
0
        public void WriteGetObjectResponseWithNoChunkedEncodingTest(bool canseek, long?contentlength, bool expectedCanSeek, string expectedContentLength)
        {
            var request = new WriteGetObjectResponseRequest
            {
                RequestRoute  = "route",
                RequestToken  = "token",
                Body          = new MyTestStream(90, canseek),
                ContentLength = contentlength
            };

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USWest2
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, WriteGetObjectResponseRequestMarshaller.Instance, config);

            Assert.AreEqual(expectedCanSeek, internalRequest.ContentStream.CanSeek);
            Assert.IsTrue(internalRequest.Headers.ContainsKey("Content-Length"));
            Assert.AreEqual(expectedContentLength, internalRequest.Headers["Content-Length"]);
            Assert.IsTrue(!internalRequest.Headers.ContainsKey("transfer-encoding"));
        }
Beispiel #29
0
        public void ChecksumHeaderIsSet()
        {
            var request = new PutBucketEncryptionRequest
            {
                BucketName = "test",
                ServerSideEncryptionConfiguration = new ServerSideEncryptionConfiguration
                {
                    ServerSideEncryptionRules = new List <ServerSideEncryptionRule>()
                    {
                        new ServerSideEncryptionRule {
                            BucketKeyEnabled = true
                        }
                    }
                }
            };
            var expectedPayload = "<ServerSideEncryptionConfiguration><Rule><BucketKeyEnabled>true</BucketKeyEnabled></Rule></ServerSideEncryptionConfiguration>";
            var payloadChecksum = Amazon.Util.AWSSDKUtils.GenerateChecksumForContent(expectedPayload, true);
            var response        = S3ArnTestUtils.RunMockRequest(request, PutBucketEncryptionRequestMarshaller.Instance);

            Assert.IsTrue(response.Headers.ContainsKey(Amazon.Util.HeaderKeys.ContentMD5Header));
            Assert.AreEqual(payloadChecksum, response.Headers[Amazon.Util.HeaderKeys.ContentMD5Header]);
        }
        public void DeleteObjectsTest()
        {
            var accessPointArn = "arn:aws:s3:us-east-1:000011112222:accesspoint/testpoint";

            var request = new DeleteObjectsRequest
            {
                BucketName = accessPointArn,
                Objects    = new List <KeyVersion>
                {
                    new KeyVersion {
                        Key = "foo1.txt"
                    },
                    new KeyVersion {
                        Key = "foo2.txt"
                    }
                }
            };

            var internalRequest = S3ArnTestUtils.RunMockRequest(request, DeleteObjectsRequestMarshaller.Instance);

            Assert.AreEqual(new Uri("https://testpoint-000011112222.s3-accesspoint.us-east-1.amazonaws.com"), internalRequest.Endpoint);
        }