public void CreateDefaultOptions()
 {
     BehaviorOptions           = new BehaviorOptions();
     DatabaseSchemaViewOptions = new DatabaseSchemaViewOptions();
     DesignPaneOptions         = new DesignPaneOptions();
     VisualOptions             = new VisualOptions();
     AddObjectDialogOptions    = new AddObjectDialogOptions();
     DataSourceOptions         = new DataSourceOptions();
     QueryNavBarOptions        = new QueryNavBarOptions();
     UserInterfaceOptions      = new UserInterfaceOptions();
     SqlFormattingOptions      = new SQLFormattingOptions();
     SqlGenerationOptions      = new SQLGenerationOptions();
 }
 public void SetOptions(Options options)
 {
     AddObjectDialogOptions.Assign(options.AddObjectDialogOptions);
     BehaviorOptions.Assign(options.BehaviorOptions);
     MainForm.DBView.Options.Assign(options.DatabaseSchemaViewOptions);
     DataSourceOptions.Assign(options.DataSourceOptions);
     DesignPaneOptions.Assign(options.DesignPaneOptions);
     ExpressionEditorOptions.Assign(options.ExpressionEditorOptions);
     QueryColumnListOptions.Assign(options.QueryColumnListOptions);
     QueryNavBarOptions.Assign(options.QueryNavBarOptions);
     SqlFormattingOptions.Assign(options.SqlFormattingOptions);
     SqlGenerationOptions.Assign(options.SqlGenerationOptions);
     TextEditorOptions.Assign(options.TextEditorOptions);
     TextEditorSqlOptions.Assign(options.TextEditorSqlOptions);
     UserInterfaceOptions.Assign(options.UserInterfaceOptions);
     VisualOptions.Assign(options.VisualOptions);
 }
 public void CreateDefaultOptions()
 {
     BehaviorOptions           = new BehaviorOptions();
     DatabaseSchemaViewOptions = new DatabaseSchemaViewOptions();
     DesignPaneOptions         = new DesignPaneOptions();
     VisualOptions             = new VisualOptions();
     AddObjectDialogOptions    = new AddObjectDialogOptions();
     DataSourceOptions         = new DataSourceOptions();
     QueryNavBarOptions        = new QueryNavBarOptions();
     UserInterfaceOptions      = new UserInterfaceOptions();
     SqlFormattingOptions      = new SQLFormattingOptions();
     SqlGenerationOptions      = new SQLGenerationOptions();
     ExpressionEditorOptions   = new ExpressionEditorOptions();
     TextEditorOptions         = new TextEditorOptions
     {
         Padding    = DefaultTextEditorPadding,
         LineHeight = new LengthUnit(90, SizeUnitType.Percent)
     };
     TextEditorSqlOptions = new SqlTextEditorOptions();
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the DelayRequestBehavior class.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayRequestBehavior(int delayInMs, Func <Session, bool> selector = null, BehaviorOptions options = null)
     : base(session => session.oRequest.pipeClient.TransmitDelay = delayInMs, selector, options, TriggerType.BeforeRequest)
 {
 }
Exemple #5
0
 /// <summary>
 /// DelayAllRequests returns a behavior that delays all requests the specified number of milliseconds.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior DelayAllRequests(int delayInMs, BehaviorOptions options = null)
 {
     return(new DelayRequestBehavior(delayInMs, null, options));
 }
 /// <summary>
 /// Sends a TCP reset after a given number of ms.
 /// </summary>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior SendTCPResetAfter(int delayInMs, Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(ExecuteAfter(EndSessionWithTCPReset(), delayInMs, selector, options));
 }
 /// <summary>
 /// InsertDownstreamNetworkDelay inserts a delay per KB downloaded.
 /// </summary>
 /// <param name="delayInMs">How much time, in milliseconds, to delay each KB.</param>
 /// <param name="selector">The predicate controlling when to insert downstream network delay.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior InsertDownstreamNetworkDelay(int delayInMs, Func<Session, bool> selector = null, BehaviorOptions options = null)
 {
     return new ProxyBehavior(session => session["response-trickle-delay"] = Convert.ToString(delayInMs), selector, options, TriggerType.BeforeResponse);
 }
 /// <summary>
 /// IgnoreAllResponses returns a behavior which ignores all responses.
 /// </summary>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior IgnoreAllResponses(BehaviorOptions options = null)
 {
     return new IgnoreResponseBehavior(null, options);
 }
 /// <summary>
 /// Executes a given action after a given number of ms.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior ExecuteAfter(Action <Session> action, int delayInMs, Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(new DelayedActionBehavior(action, delayInMs, null, selector, options));
 }
 /// <summary>
 /// TamperAllRequests returns a behavior which tampers with all requests.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior TamperAllRequests(Action <Session> tamperAction, BehaviorOptions options = null)
 {
     return(new TamperRequestBehavior(tamperAction, null, options));
 }
        internal AuthlambdaStack(Construct scope, string id, AuthlambdaStackProps props = null) : base(scope, id, props)
        {
            functionsStack = props.functionsStack;

            Bucket websiteBucket = new Bucket(this, "websiteBucket", new BucketProps()
            {
                BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
                PublicReadAccess  = false,
                //WebsiteIndexDocument = "index.html",
                RemovalPolicy = RemovalPolicy.DESTROY,
                Cors          = new ICorsRule[] {
                    new CorsRule()
                    {
                        AllowedHeaders = new string[] { "Authorization", "Content-Type", "Origin" },
                        AllowedMethods = new HttpMethods[] { HttpMethods.GET, HttpMethods.HEAD },
                        AllowedOrigins = new string[] { "*" }
                    }
                }
            });

            Bucket privateBucket = new Bucket(this, "privateBucket", new BucketProps()
            {
                BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
                PublicReadAccess  = false,
                RemovalPolicy     = RemovalPolicy.DESTROY,
                Cors = new ICorsRule[] {
                    new CorsRule()
                    {
                        AllowedHeaders = new string[] { "Authorization", "Content-Type", "Origin" },
                        AllowedMethods = new HttpMethods[] { HttpMethods.GET, HttpMethods.HEAD },
                        AllowedOrigins = new string[] { "*" }
                    }
                }
            });

            // The S3 bucket deployment for the website
            var websiteDeployment = new BucketDeployment(this, "TestStaticWebsiteDeployment", new BucketDeploymentProps()
            {
                Sources           = new [] { Source.Asset("./src/website") },
                DestinationBucket = websiteBucket,
                RetainOnDelete    = false
            });

            var privateDeployment = new BucketDeployment(this, "TestPrivateDeployment", new BucketDeploymentProps()
            {
                Sources           = new [] { Source.Asset("./src/private") },
                DestinationBucket = privateBucket,
                RetainOnDelete    = false
            });

            var cloudfrontOAI = OriginAccessIdentity.FromOriginAccessIdentityName(this, "CloudfrontOAIName", cloudfrontOAIName);

            websiteBucket.GrantRead(cloudfrontOAI.GrantPrincipal);
            privateBucket.GrantRead(cloudfrontOAI.GrantPrincipal);

            var cachePolicy = new CachePolicy(this, "TestCachePolicy", new CachePolicyProps()
            {
                CachePolicyName = "TestCachePolicy",
                Comment         = "Cache policy for Testing",
                DefaultTtl      = Duration.Seconds(0),
                CookieBehavior  = CacheCookieBehavior.All(),
                HeaderBehavior  = CacheHeaderBehavior.AllowList(
                    "Authorization",
                    "Content-Type",
                    "Origin"
                    ),
                QueryStringBehavior        = CacheQueryStringBehavior.All(),
                EnableAcceptEncodingBrotli = false,
                EnableAcceptEncodingGzip   = false
            });

            var websiteOrigin = new S3Origin(websiteBucket, new S3OriginProps()
            {
                OriginAccessIdentity = cloudfrontOAI
            });
            var privateOrigin = new S3Origin(privateBucket, new S3OriginProps()
            {
                OriginAccessIdentity = cloudfrontOAI
            });

            var dummyOrigin = new HttpOrigin("example.com", new HttpOriginProps()
            {
                ProtocolPolicy = OriginProtocolPolicy.HTTPS_ONLY
            });

            // default behavior is for the privateOrigin
            var defaultPrivateBehavior = new BehaviorOptions {
                AllowedMethods       = AllowedMethods.ALLOW_ALL,
                CachePolicy          = cachePolicy,
                OriginRequestPolicy  = OriginRequestPolicy.CORS_S3_ORIGIN,
                ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
                Origin      = privateOrigin,
                EdgeLambdas = new IEdgeLambda[] {
                    new EdgeLambda()
                    {
                        EventType       = LambdaEdgeEventType.VIEWER_REQUEST,
                        FunctionVersion = functionsStack.checkAuthHandler.CurrentVersion,
                    },
                    new EdgeLambda()
                    {
                        EventType       = LambdaEdgeEventType.ORIGIN_RESPONSE,
                        FunctionVersion = functionsStack.httpHeadersHandler.CurrentVersion
                    }
                }
            };

            // this behavior is for dummy origin
            var parseAuthBehavior = new BehaviorOptions {
                AllowedMethods       = AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
                CachePolicy          = cachePolicy,
                OriginRequestPolicy  = OriginRequestPolicy.CORS_S3_ORIGIN,
                ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
                Origin      = dummyOrigin,
                EdgeLambdas = new IEdgeLambda[] {
                    new EdgeLambda()
                    {
                        EventType       = LambdaEdgeEventType.VIEWER_REQUEST,
                        FunctionVersion = functionsStack.parseAuthHandler.CurrentVersion,
                    }
                }
            };

            var refreshAuthBehavior = new BehaviorOptions {
                AllowedMethods       = AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
                CachePolicy          = cachePolicy,
                OriginRequestPolicy  = OriginRequestPolicy.CORS_S3_ORIGIN,
                ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
                Origin      = dummyOrigin,
                EdgeLambdas = new IEdgeLambda[] {
                    new EdgeLambda()
                    {
                        EventType       = LambdaEdgeEventType.VIEWER_REQUEST,
                        FunctionVersion = functionsStack.refreshAuthHandler.CurrentVersion,
                    }
                }
            };

            var signOutBehavior = new BehaviorOptions {
                AllowedMethods       = AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
                CachePolicy          = cachePolicy,
                OriginRequestPolicy  = OriginRequestPolicy.CORS_S3_ORIGIN,
                ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
                Origin      = dummyOrigin,
                EdgeLambdas = new IEdgeLambda[] {
                    new EdgeLambda()
                    {
                        EventType       = LambdaEdgeEventType.VIEWER_REQUEST,
                        FunctionVersion = functionsStack.signOutHandler.CurrentVersion,
                    }
                }
            };

            Distribution distribution = new Distribution(this, "TestCloudfrontDistribution", new DistributionProps()
            {
                Comment           = "Test Website Distribution",
                DefaultRootObject = "index.html",
                PriceClass        = PriceClass.PRICE_CLASS_ALL,
                GeoRestriction    = GeoRestriction.Whitelist(new [] {
                    "IN"
                }),
                DefaultBehavior = defaultPrivateBehavior,
            });

            distribution.AddBehavior("/parseauth", dummyOrigin, parseAuthBehavior);
            distribution.AddBehavior("/refreshauth", dummyOrigin, refreshAuthBehavior);
            distribution.AddBehavior("/signout", dummyOrigin, signOutBehavior);

            var domainNameOutput = new CfnOutput(this, "TestWebsiteDistributionDomainName", new CfnOutputProps()
            {
                Value = distribution.DistributionDomainName
            });
        }
 /// <summary>
 /// Initializes a new instance of the DelayedActionBehavior class.
 /// </summary>
 /// <param name="action"> The Action to execute after the delay</param>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="pollingSelector">The interval in ms to poll. For single backoff delays this is the backoff in ms.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayedActionBehavior(Action<Session> action, int? delayInMs, Func<Session, bool> pollingSelector = null, Func<Session, bool> selector = null, BehaviorOptions options = null)
     : base((session) => DelayAction(session, action, delayInMs, pollingSelector), selector, options, TriggerType.BeforeRequest)
 {
 }
 /// <summary>
 /// Initializes a new instance of the TamperResponseBehavior class.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the response.</param>
 /// <param name="selector">The predicate controlling when to tamper with the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public TamperResponseBehavior(Action <Session> tamperAction, Func <Session, bool> selector = null, BehaviorOptions options = null)
     : base(tamperAction, selector, options, TriggerType.BeforeResponse)
 {
 }
 /// <summary>
 /// Sends a TCP reset after a given number of ms.
 /// </summary>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior SendTCPResetAfter(int delayInMs, Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return ExecuteAfter(EndSessionWithTCPReset(), delayInMs, selector, options);
 }
 /// <summary>
 /// Aborts an Session after a given number of ms.
 /// </summary>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior AbortRequestAfter(int delayInMs, Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return ExecuteAfter(AbortSession(), delayInMs, selector, options);
 }
 /// <summary>
 /// Executes a given action after a given number of ms.
 /// </summary>
 /// <param name="action">The action to execute.</param>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior ExecuteAfter(Action<Session> action, int delayInMs, Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return new DelayedActionBehavior(action, delayInMs, null, selector, options);
 }
 /// <summary>
 /// Initializes a new instance of the IgnoreResponseBehavior class.
 /// </summary>
 /// <param name="selector">The predicate controlling when to ignore the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public IgnoreResponseBehavior(Func<Session, bool> selector = null, BehaviorOptions options = null)
     : base(IgnoreResponse, selector, options, TriggerType.BeforeResponse)
 {
 }
 /// <summary>
 /// Initializes a new instance of the DelayRequestBehavior class.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayRequestBehavior(int delayInMs, Func<Session, bool> selector = null, BehaviorOptions options = null)
     : base(session => session.oRequest.pipeClient.TransmitDelay = delayInMs, selector, options, TriggerType.BeforeRequest)
 {
 }
 /// <summary>
 /// IgnoreAllResponses returns a behavior which ignores all responses.
 /// </summary>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior IgnoreAllResponses(BehaviorOptions options = null)
 {
     return(new IgnoreResponseBehavior(null, options));
 }
 /// <summary>
 /// DelayAllRequests returns a behavior that delays all requests the specified number of milliseconds.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior DelayAllRequests(int delayInMs, BehaviorOptions options = null)
 {
     return new DelayRequestBehavior(delayInMs, null, options);
 }
 /// <summary>
 /// TamperAllRequestsIf returns a behavior which tampers with all requests which meet a specified criterion.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the request.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior TamperAllRequestsIf(Action <Session> tamperAction, Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(new TamperRequestBehavior(tamperAction, selector, options));
 }
 /// <summary>
 /// IgnoreAllRequestsIf returns a behavior ignoring requests which meet some criterion.
 /// </summary>
 /// <param name="selector">The predicate controlling when to ignore the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior IgnoreAllRequestsIf(Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return new IgnoreRequestBehavior(selector, options);
 }
 /// <summary>
 /// Initializes a new instance of the DelayResponseBehavior class.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the response.</param>
 /// <param name="selector">The predicate controlling when to delay the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayResponseBehavior(int delayInMs, Func<Session, bool> selector = null, BehaviorOptions options = null)
     : base(session => session.oResponse.pipeServer.TransmitDelay = delayInMs, selector, options, TriggerType.BeforeResponse)
 {
 }
Exemple #24
0
 /// <summary>
 /// InsertDownstreamNetworkDelay inserts a delay per KB downloaded.
 /// </summary>
 /// <param name="delayInMs">How much time, in milliseconds, to delay each KB.</param>
 /// <param name="selector">The predicate controlling when to insert downstream network delay.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior InsertDownstreamNetworkDelay(int delayInMs, Func <Session, bool> selector = null, BehaviorOptions options = null)
 {
     return(new ProxyBehavior(session => session["response-trickle-delay"] = Convert.ToString(delayInMs), selector, options, TriggerType.BeforeResponse));
 }
 /// <summary>
 /// DelayAllRequestsIf returns a behavior that delays requests the specified number of milliseconds.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior DelayAllRequestsIf(int delayInMs, Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return new DelayRequestBehavior(delayInMs, selector, options);
 }
Exemple #26
0
 /// <summary>
 /// LogSessionPerfData raises an event when the perf counter for the session is available.
 /// </summary>
 /// <param name="onTimerAvailablity">The action to perform when the session timers are available.</param>
 /// <param name="selector">The predicate controlling when to log performance data.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior LogSessionPerfData(Action <Session, SessionTimers> onTimerAvailablity, Func <Session, bool> selector = null, BehaviorOptions options = null)
 {
     return(new ProxyBehavior(session => onTimerAvailablity(session, session.Timers), selector, options, TriggerType.AfterSessionComplete));
 }
 /// <summary>
 /// Aborts an Session after a given number of ms.
 /// </summary>
 /// <param name="delayInMs">The delay in MS.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior AbortRequestAfter(int delayInMs, Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(ExecuteAfter(AbortSession(), delayInMs, selector, options));
 }
 /// <summary>
 /// Initializes a new instance of the TamperResponseBehavior class.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the response.</param>
 /// <param name="selector">The predicate controlling when to tamper with the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public TamperResponseBehavior(Action<Session> tamperAction, Func<Session, bool> selector = null, BehaviorOptions options = null)
     : base(tamperAction, selector, options, TriggerType.BeforeResponse)
 {
 }
 /// <summary>
 /// Initializes a new instance of the DelayedActionBehavior class.
 /// </summary>
 /// <param name="action"> The Action to execute after the delay</param>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="pollingSelector">The interval in ms to poll. For single backoff delays this is the backoff in ms.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayedActionBehavior(Action <Session> action, int?delayInMs, Func <Session, bool> pollingSelector = null, Func <Session, bool> selector = null, BehaviorOptions options = null)
     : base((session) => DelayAction(session, action, delayInMs, pollingSelector), selector, options, TriggerType.BeforeRequest)
 {
 }
 /// <summary>
 /// TamperAllRequests returns a behavior which tampers with all requests.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior TamperAllRequests(Action<Session> tamperAction, BehaviorOptions options = null)
 {
     return new TamperRequestBehavior(tamperAction, null, options);
 }
 /// <summary>
 /// LogSessionPerfData raises an event when the perf counter for the session is available.
 /// </summary>
 /// <param name="onTimerAvailablity">The action to perform when the session timers are available.</param>
 /// <param name="selector">The predicate controlling when to log performance data.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior LogSessionPerfData(Action<Session, SessionTimers> onTimerAvailablity, Func<Session, bool> selector = null, BehaviorOptions options = null)
 {
     return new ProxyBehavior(session => onTimerAvailablity(session, session.Timers), selector, options, TriggerType.AfterSessionComplete);
 }
 /// <summary>
 /// TamperAllRequestsIf returns a behavior which tampers with all requests which meet a specified criterion.
 /// </summary>
 /// <param name="tamperAction">An action specifying how to tamper with the request.</param>
 /// <param name="selector">The predicate controlling when to tamper with the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior TamperAllRequestsIf(Action<Session> tamperAction, Func<Session, bool> selector, BehaviorOptions options = null)
 {
     return new TamperRequestBehavior(tamperAction, selector, options);
 }
Exemple #33
0
 /// <summary>
 /// Initializes a new instance of the DelayResponseBehavior class.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the response.</param>
 /// <param name="selector">The predicate controlling when to delay the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public DelayResponseBehavior(int delayInMs, Func <Session, bool> selector = null, BehaviorOptions options = null)
     : base(session => session.oResponse.pipeServer.TransmitDelay = delayInMs, selector, options, TriggerType.BeforeResponse)
 {
 }
 /// <summary>
 /// Initializes a new instance of the IgnoreResponseBehavior class.
 /// </summary>
 /// <param name="selector">The predicate controlling when to ignore the response.</param>
 /// <param name="options">The options controlling the behavior.</param>
 public IgnoreResponseBehavior(Func <Session, bool> selector = null, BehaviorOptions options = null)
     : base(IgnoreResponse, selector, options, TriggerType.BeforeResponse)
 {
 }
Exemple #35
0
 /// <summary>
 /// DelayAllRequestsIf returns a behavior that delays requests the specified number of milliseconds.
 /// </summary>
 /// <param name="delayInMs">The time in milliseconds to delay the request.</param>
 /// <param name="selector">The predicate controlling when to delay the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior DelayAllRequestsIf(int delayInMs, Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(new DelayRequestBehavior(delayInMs, selector, options));
 }
 /// <summary>
 /// IgnoreAllRequestsIf returns a behavior ignoring requests which meet some criterion.
 /// </summary>
 /// <param name="selector">The predicate controlling when to ignore the request.</param>
 /// <param name="options">The options controlling the behavior.</param>
 /// <returns>The relevant behavior.</returns>
 public static ProxyBehavior IgnoreAllRequestsIf(Func <Session, bool> selector, BehaviorOptions options = null)
 {
     return(new IgnoreRequestBehavior(selector, options));
 }