Exemple #1
0
 /// <summary>
 /// Customizes the runtime pipeline by replacing the default retry handler with a custom one that retries certain STS errors.
 /// </summary>
 /// <param name="pipeline">The client runtime pipeline</param>
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     if (this.Config.RetryMode == RequestRetryMode.Legacy)
     {
         pipeline.ReplaceHandler <RetryHandler>(new RetryHandler(new SecurityTokenServiceRetryPolicy(this.Config)));
     }
     else if (this.Config.RetryMode == RequestRetryMode.Standard)
     {
         pipeline.ReplaceHandler <RetryHandler>(new RetryHandler(new SecurityTokenServiceStandardRetryPolicy(this.Config)));
     }
     else if (this.Config.RetryMode == RequestRetryMode.Adaptive)
     {
         pipeline.ReplaceHandler <RetryHandler>(new RetryHandler(new SecurityTokenServiceAdaptiveRetryPolicy(this.Config)));
     }
 }
        protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
        {
            _requestFactory = new AWSSDK.UnitTests.HttpHandlerTests.MockHttpRequestFactory();
            var httpHandler = new HttpHandler <Stream>(_requestFactory, this);

            pipeline.ReplaceHandler <HttpHandler <Stream> >(httpHandler);
        }
Exemple #3
0
 /// <summary>
 /// Customize the pipeline
 /// </summary>
 /// <param name="pipeline"></param>
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     if (this.Config.RetryMode == RequestRetryMode.Legacy)
     {
         pipeline.ReplaceHandler <Amazon.Runtime.Internal.RetryHandler>(new Amazon.Runtime.Internal.RetryHandler(new Amazon.DynamoDBv2.Internal.DynamoDBRetryPolicy(this.Config)));
     }
 }
        public void RunRetryTest(Action <IExecutionContext, MockAdaptiveRetryPolicy> DoAction, AmazonS3Config config, CapacityManager capacityManager = null)
        {
            try
            {
                if (capacityManager != null)
                {
                    MockAdaptiveRetryPolicy.SetCapacityManagerInstance(capacityManager);
                }

                var retryPolicy = new MockAdaptiveRetryPolicy(config);
                Handler = new RetryHandler(retryPolicy);
                if (RuntimePipeline.Handlers.Find(h => h is RetryHandler) != null)
                {
                    RuntimePipeline.ReplaceHandler <RetryHandler>(Handler);
                }
                else
                {
                    RuntimePipeline.AddHandler(Handler);
                }

                var executionContext = CreateTestContext(null, null, config);

                DoAction(executionContext, retryPolicy);
            }
            finally
            {
                if (capacityManager != null)
                {
                    MockAdaptiveRetryPolicy.RestoreManagers();
                }
            }
        }
Exemple #5
0
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler <Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler <AmazonCognitoSyncException>(this.Logger));
     pipeline.RemoveHandler <Amazon.Runtime.Internal.CredentialsRetriever>();
     pipeline.AddHandlerBefore <Amazon.Runtime.Internal.Marshaller>(new Amazon.CognitoSync.Internal.CognitoCredentialsRetriever(this.Credentials));
     pipeline.AddHandlerAfter <Amazon.Runtime.Internal.Marshaller>(new Amazon.CognitoSync.Internal.AmazonCognitoSyncPostMarshallHandler());
     pipeline.AddHandlerAfter <Amazon.Runtime.Internal.Signer>(new Amazon.CognitoSync.Internal.AmazonCognitoSyncPostSignHandler());
 }
Exemple #6
0
            protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
            {
                base.CustomizeRuntimePipeline(pipeline);

                this.MockFactory = new Mock <IHttpRequestFactory <Stream> >();
                this.MockFactory.Setup(foo => foo.CreateHttpRequest(It.IsAny <Uri>()))
                .Returns((Uri uri) =>
                {
                    var request = new Mock <IHttpRequest <Stream> >();
                    request.Setup(foo => foo.GetResponseAsync(new CancellationToken()))
                    .Throws(new IOException());
                    return(request.Object);
                })
                .Callback((Uri uri) => this.LastRequestUri = uri);
                pipeline.ReplaceHandler <HttpHandler <Stream> >(new HttpHandler <Stream>(this.MockFactory.Object, this));
            }
Exemple #7
0
            protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
            {
                base.CustomizeRuntimePipeline(pipeline);

                this.MockFactory = new Mock <IHttpRequestFactory <Stream> >();
                this.MockFactory.Setup(foo => foo.CreateHttpRequest(It.IsAny <Uri>()))
                .Returns((Uri uri) =>
                {
                    var request = new Mock <IHttpRequest <Stream> >();
                    request.Setup(foo => foo.GetResponse())
                    .Returns(new HttpWebRequestResponseData(MockWebResponse.CreateFromResource("PutItemResponse.txt")));
                    return(request.Object);
                })
                .Callback((Uri uri) => this.LastRequestUri = uri);
                pipeline.ReplaceHandler <HttpHandler <Stream> >(new HttpHandler <Stream>(this.MockFactory.Object, this));
            }
        public void ReplaceHandlerTest()
        {
            var handlerC = new TestHandlerC();
            var pipeline = new RuntimePipeline(handlerC);
            var handlerB = new TestHandlerB();            
            pipeline.AddHandler(handlerB);
            var handlerA = new TestHandlerA();
            //A->B->C
            pipeline.AddHandler(handlerA);
            ValidatePipeline(pipeline, handlerA, handlerB, handlerC);

            var handlerD = new TestHandlerD();
            //A->D->C
            pipeline.ReplaceHandler<TestHandlerB>(handlerD);
            ValidatePipeline(pipeline, handlerA, handlerD, handlerC);
            Assert.IsNull(handlerB.OuterHandler);
            Assert.IsNull(handlerB.InnerHandler);
        }
        public void ReplaceHandlerTest()
        {
            var handlerC = new TestHandlerC();
            var pipeline = new RuntimePipeline(handlerC);
            var handlerB = new TestHandlerB();

            pipeline.AddHandler(handlerB);
            var handlerA = new TestHandlerA();

            //A->B->C
            pipeline.AddHandler(handlerA);
            ValidatePipeline(pipeline, handlerA, handlerB, handlerC);

            var handlerD = new TestHandlerD();

            //A->D->C
            pipeline.ReplaceHandler <TestHandlerB>(handlerD);
            ValidatePipeline(pipeline, handlerA, handlerD, handlerC);
            Assert.IsNull(handlerB.OuterHandler);
            Assert.IsNull(handlerB.InnerHandler);
        }
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonCognitoIdentityException>(this.Logger));
 }    
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.RetryHandler>(new Amazon.Runtime.Internal.RetryHandler(new Amazon.DynamoDBv2.Internal.DynamoDBRetryPolicy(this.Config.MaxErrorRetry)));
 }
Exemple #12
0
 /// <summary>
 /// Customize the pipeline
 /// </summary>
 /// <param name="pipeline"></param>
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler <Amazon.Runtime.Internal.RetryHandler>(new Amazon.Runtime.Internal.RetryHandler(new Amazon.DynamoDBv2.Internal.DynamoDBRetryPolicy(this.Config.MaxErrorRetry)));
 }
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonSQSException>(this.Logger));
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Marshaller>(new Amazon.SQS.Internal.ProcessRequestHandler());
     pipeline.AddHandlerBefore<Amazon.Runtime.Internal.Unmarshaller>(new Amazon.SQS.Internal.ValidationResponseHandler());
 }    
 /// <summary>
 /// Customizes the runtime pipeline by replacing the default retry handler with a custom one that retries certain STS errors.
 /// </summary>
 /// <param name="pipeline">The client runtime pipeline</param>
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler <RetryHandler>(new RetryHandler(new SecurityTokenServiceRetryPolicy(this.Config)));
 }
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.AddHandlerBefore<Amazon.Runtime.Internal.Marshaller>(new Amazon.S3.Internal.AmazonS3PreMarshallHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Marshaller>(new Amazon.S3.Internal.AmazonS3PostMarshallHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.EndpointResolver>(new Amazon.S3.Internal.AmazonS3KmsHandler());
     pipeline.AddHandlerBefore<Amazon.Runtime.Internal.Unmarshaller>(new Amazon.S3.Internal.AmazonS3ResponseHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.ErrorCallbackHandler>(new Amazon.S3.Internal.AmazonS3ExceptionHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Unmarshaller>(new Amazon.S3.Internal.AmazonS3RedirectHandler());
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.RetryHandler>(new Amazon.Runtime.Internal.RetryHandler(new Amazon.S3.Internal.AmazonS3RetryPolicy(this.Config.MaxErrorRetry)));
 }
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonS3Exception>(this.Logger));
     pipeline.AddHandlerBefore<Amazon.Runtime.Internal.Marshaller>(new Amazon.S3.Internal.AmazonS3PreMarshallHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Marshaller>(new Amazon.S3.Internal.AmazonS3PostMarshallHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.EndpointResolver>(new Amazon.S3.Internal.AmazonS3KmsHandler());
 }    
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler <Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler <AmazonMobileAnalyticsException>(this.Logger));
 }
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonSecurityTokenServiceException>(this.Logger));
 }    
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonMobileAnalyticsException>(this.Logger));
 }    
 protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
 {
     pipeline.ReplaceHandler<Amazon.Runtime.Internal.ErrorHandler>(new Amazon.Runtime.Internal.ErrorHandler<AmazonCognitoSyncException>(this.Logger));
     pipeline.RemoveHandler<Amazon.Runtime.Internal.CredentialsRetriever>();
     pipeline.AddHandlerBefore<Amazon.Runtime.Internal.Marshaller>(new Amazon.CognitoSync.Internal.CognitoCredentialsRetriever(this.Credentials));
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Marshaller>(new Amazon.CognitoSync.Internal.AmazonCognitoSyncPostMarshallHandler());
     pipeline.AddHandlerAfter<Amazon.Runtime.Internal.Signer>(new Amazon.CognitoSync.Internal.AmazonCognitoSyncPostSignHandler());
 }    
        protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
        {
            _requestFactory = new AWSSDK.UnitTests.HttpHandlerTests.MockHttpRequestFactory();
            var httpHandler = new HttpHandler<Stream>(_requestFactory, this);

            pipeline.ReplaceHandler<HttpHandler<Stream>>(httpHandler);
        }