public async Task CreateAuthorizationHeader() { var signer = new AwsSigner(); var config = Helpers.CreateExampleConfig(); var request = Helpers.CreateExampleRequest(); var dateTime = DateTimeOffset.Parse("2015-08-30T12:36:00Z"); var signedHeaders = signer.BuildSignedHeaders(signer.BuildCanonicalHeaders(request)); const string expected = "Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7"; var signature = await signer.CreateSignature(config, request, dateTime); var result = signer.CreateAuthorizationHeader(config.AccessId, dateTime, config.Region, config.Service, signedHeaders, signature); Assert.AreEqual(expected, result, "Authorization string creation failed"); }
public void SignedHeadersBuilderTest() { var signer = new AwsSigner(); var inputBuilder = new StringBuilder(); inputBuilder.Append("content-type:application/x-www-form-urlencoded; charset=utf-8\n"); inputBuilder.Append("host:iam.amazonaws.com\n"); inputBuilder.Append("my-header1:a b c\n"); inputBuilder.Append("my-header1:\"a b c\"\n"); inputBuilder.Append("x-amz-date:20150830T123600Z\n"); var expected = "content-type;host;my-header1;my-header1;x-amz-date"; var output = signer.BuildSignedHeaders(inputBuilder.ToString()); Assert.AreEqual(expected, output, "Signed headers builder failed"); }