public void TestAddSignatureToRequest()
        {
            IRestRequest restRequest           = new RestRequest();
            string       expectedAccessKeyId   = TestAccessKeyId;
            string       expectedRegion        = TestRegion;
            string       expectedSignature     = "testCalculatedSignature";
            string       expectedSignedHeaders = "header1;header2";

            string expectedAuthorizationHeaderValue = string.Format("AWS4-HMAC-SHA256 " +
                                                                    "Credential={0}/{1}/{2}/execute-api/aws4_request, SignedHeaders={3}, Signature={4}",
                                                                    expectedAccessKeyId,
                                                                    ISOSigningDate,
                                                                    expectedRegion,
                                                                    expectedSignedHeaders,
                                                                    expectedSignature);

            awsSignerHelperUnderTest.AddSignature(restRequest,
                                                  expectedAccessKeyId,
                                                  expectedSignedHeaders,
                                                  expectedSignature,
                                                  expectedRegion,
                                                  SigningDate);

            Parameter actualParameter = restRequest.Parameters.Find(parameter =>
                                                                    ParameterType.HttpHeader.Equals(parameter.Type) && parameter.Name == AWSSignerHelper.AuthorizationHeaderName);

            Assert.Equal(expectedAuthorizationHeaderValue, actualParameter.Value);
        }
示例#2
0
        public void TestAddSignatureToRequest()
        {
            HttpRequestMessage restRequest           = new HttpRequestMessage();
            string             expectedAccessKeyId   = TestAccessKeyId;
            string             expectedRegion        = TestRegion;
            string             expectedSignature     = "testCalculatedSignature";
            string             expectedSignedHeaders = "header1;header2";

            string expectedAuthorizationHeaderValue = string.Format("AWS4-HMAC-SHA256 " +
                                                                    "Credential={0}/{1}/{2}/execute-api/aws4_request, SignedHeaders={3}, Signature={4}",
                                                                    expectedAccessKeyId,
                                                                    ISOSigningDate,
                                                                    expectedRegion,
                                                                    expectedSignedHeaders,
                                                                    expectedSignature);

            awsSignerHelperUnderTest.AddSignature(restRequest,
                                                  expectedAccessKeyId,
                                                  expectedSignedHeaders,
                                                  expectedSignature,
                                                  expectedRegion,
                                                  SigningDate);

            string SignatureHeaderValue = restRequest.Headers.GetValues(AWSSignerHelper.AuthorizationHeaderName).FirstOrDefault();

            Assert.Equal(expectedAuthorizationHeaderValue, SignatureHeaderValue);
        }