Ejemplo n.º 1
0
        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));
        }