public void TestChunkedRequest() { var signer = new CrtAWS4aSigner(); var request = BuildMockChunkedRequest(); var clientConfig = BuildSigningClientConfig(SigningTestService); var headerResult = signer.SignRequest(request, clientConfig, null, SigningTestCredentials); var config = BuildDefaultSigningConfig(SigningTestService); config.SignatureType = AwsSignatureType.CANONICAL_REQUEST_VIA_HEADERS; config.SignedBodyValue = AWS4Signer.V4aStreamingBodySha256; Assert.True(AwsSigner.VerifyV4aCanonicalSigning(GetExpectedCanonicalRequestForChunkedSigningTest(), config, headerResult.Signature, SigningTestEccPubX, SigningTestEccPubY)); var chunk1Result = signer.SignChunk(CreateChunkStream(Chunk1Size), headerResult.Signature, headerResult); Assert.True(AwsSigner.VerifyV4aSignature(BuildV4aChunkedStringToSignHelper(headerResult, headerResult.Signature, Chunk1Size), Encoding.ASCII.GetBytes(chunk1Result), SigningTestEccPubX, SigningTestEccPubY)); var chunk2Result = signer.SignChunk(CreateChunkStream(Chunk2Size), chunk1Result, headerResult); Assert.True(AwsSigner.VerifyV4aSignature(BuildV4aChunkedStringToSignHelper(headerResult, chunk1Result, Chunk2Size), Encoding.ASCII.GetBytes(chunk2Result), SigningTestEccPubX, SigningTestEccPubY)); var chunk3Result = signer.SignChunk(null, chunk2Result, headerResult); Assert.True(AwsSigner.VerifyV4aSignature(BuildV4aChunkedStringToSignHelper(headerResult, chunk2Result, 0), Encoding.ASCII.GetBytes(chunk3Result), SigningTestEccPubX, SigningTestEccPubY)); }
public void SignRequestViaQueryParamsWithSigv4a() { var signer = new CrtAWS4aSigner(); var request = BuildQueryParamRequestToSign(); var clientConfig = BuildSigningClientConfig("service"); var result = signer.Presign4a(request, clientConfig, null, SigningTestCredentials, "service", SigningTestRegion); var signatureValue = result.Signature; var canonicalRequest = GetExpectedCanonicalRequestForQueryParamSigningTest(); var config = BuildDefaultSigningConfig("service"); config.SignatureType = AwsSignatureType.CANONICAL_REQUEST_VIA_QUERY_PARAMS; Assert.True(AwsSigner.VerifyV4aCanonicalSigning(canonicalRequest, config, signatureValue, SigningTestEccPubX, SigningTestEccPubY)); }
[InlineData("s3", "my-object//example//photo.user", "/my-object//example//photo.user")] // should not normalize public void SignRequestViaHeadersWithSigv4a(string service, string resourcePath, string canonicalizedResourcePath) { var signer = new CrtAWS4aSigner(); var request = BuildHeaderRequestToSign(resourcePath); var clientConfig = BuildSigningClientConfig(service); var result = signer.SignRequest(request, clientConfig, null, SigningTestCredentials); string signatureValue = result.Signature; var canonicalRequest = GetExpectedCanonicalRequestForHeaderSigningTest(canonicalizedResourcePath); var config = BuildDefaultSigningConfig(service); config.SignatureType = AwsSignatureType.CANONICAL_REQUEST_VIA_HEADERS; Assert.True(AwsSigner.VerifyV4aCanonicalSigning(canonicalRequest, config, signatureValue, SigningTestEccPubX, SigningTestEccPubY)); }