public async Task SupportNullContentAsync() { // Act var actual = await ContentHash.CalculateAsync(null); // Assert actual.ShouldBe(EmptyContentHash); }
public async Task SupportEmptyStringContentAsync() { // Arrange HttpContent content = new StringContent(string.Empty); // Act var actual = await ContentHash.CalculateAsync(content); // Assert actual.ShouldBe(EmptyContentHash); }
public async Task CalculateValidHashAsync() { // Arrange HttpContent content = new StringContent("foo"); // Act var actual = await ContentHash.CalculateAsync(content); // Assert actual.Length.ShouldBe(64); IsHex(actual).ShouldBeTrue(); }
public async Task PassTestSuite(params string[] scenarioName) { // Arrange var scenario = context.LoadScenario(scenarioName); // Add header 'X-Amz-Date' since the algorithm at this point expects it on the request scenario.Request.AddHeader(HeaderKeys.XAmzDateHeader, context.UtcNow.ToIso8601BasicDateTime()); // Calculate the content hash, since it's one of the parameters to the canonical request var contentHash = await ContentHash.CalculateAsync(scenario.Request.Content); // Act var(canonicalRequest, signedHeaders) = CanonicalRequest.Build("execute-api", scenario.Request, null, contentHash); // Assert canonicalRequest.ShouldBe(scenario.ExpectedCanonicalRequest); signedHeaders.ShouldBe(scenario.ExpectedSignedHeaders); }