public async Task<HttpResponseMessage> TryHandle(HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeJobFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            string route = request.RequestUri.LocalPath.ToLowerInvariant();
            IWebHookReceiver receiver = null;
            string receiverId = null;

            if (TryParseReceiver(route, out receiver, out receiverId))
            {
                HttpRequestContext context = new HttpRequestContext
                {
                    Configuration = _httpConfiguration
                };
                request.SetConfiguration(_httpConfiguration);

                // add the anonymous handler function from above to the request properties
                // so our custom WebHookHandler can invoke it at the right time
                request.Properties.Add(WebHookJobFunctionInvokerKey, invokeJobFunction);

                return await receiver.ReceiveAsync(receiverId, context, request);
            }

            return null;
        }
        private static HttpRequestMessage CreateHttpRequestMessage(HttpActionDescriptor actionDescriptor, ODataRoute oDataRoute, HttpConfiguration httpConfig)
        {
            Contract.Requires(httpConfig != null);
            Contract.Requires(oDataRoute != null);
            Contract.Requires(httpConfig != null);
            Contract.Ensures(Contract.Result<HttpRequestMessage>() != null);

            Contract.Assume(oDataRoute.Constraints != null);

            var httpRequestMessage = new HttpRequestMessage(actionDescriptor.SupportedHttpMethods.First(), "http://any/");

            var requestContext = new HttpRequestContext
            {
                Configuration = httpConfig
            };
            httpRequestMessage.SetConfiguration(httpConfig);
            httpRequestMessage.SetRequestContext(requestContext);

            var httpRequestMessageProperties = httpRequestMessage.ODataProperties();
            Contract.Assume(httpRequestMessageProperties != null);
            httpRequestMessageProperties.Model = oDataRoute.GetEdmModel();
            httpRequestMessageProperties.RouteName = oDataRoute.GetODataPathRouteConstraint().RouteName;
            httpRequestMessageProperties.RoutingConventions = oDataRoute.GetODataPathRouteConstraint().RoutingConventions;
            httpRequestMessageProperties.PathHandler = oDataRoute.GetODataPathRouteConstraint().PathHandler;
            return httpRequestMessage;
        }
 //Automation Constructor
 public AttributesController(IAttributesManager IAttributesManager, HttpRequestMessage Request, HttpRequestContext RequestContext)
 {
     parameters = new Dictionary<string, string>();
     this.RequestContext = RequestContext;
     this.Request = Request;
     this.AttributesManager = IAttributesManager;
 }
        /// <summary>Initializes a new instance of the <see cref="HttpControllerContext"/> class.</summary>
        /// <param name="requestContext">The request context.</param>
        /// <param name="request">The HTTP request.</param>
        /// <param name="controllerDescriptor">The controller descriptor.</param>
        /// <param name="controller">The controller.</param>
        public HttpControllerContext(HttpRequestContext requestContext, HttpRequestMessage request,
            HttpControllerDescriptor controllerDescriptor, IHttpController controller)
        {
            if (requestContext == null)
            {
                throw Error.ArgumentNull("requestContext");
            }

            if (request == null)
            {
                throw Error.ArgumentNull("request");
            }

            if (controllerDescriptor == null)
            {
                throw Error.ArgumentNull("controllerDescriptor");
            }

            if (controller == null)
            {
                throw Error.ArgumentNull("controller");
            }

            _requestContext = requestContext;
            _request = request;
            _controllerDescriptor = controllerDescriptor;
            _controller = controller;
        }
        public Task Register(ApiServices services, HttpRequestContext context,
        NotificationRegistration registration)
        {
            try
            {
                // Perform a check here for user ID tags, which are not allowed.
                if (!ValidateTags(registration))
                {
                    throw new InvalidOperationException(
                        "You cannot supply a tag that is a user ID.");
                }

                // Get the logged-in user.
                var currentUser = context.Principal as ServiceUser;

                // Add a new tag that is the user ID.
                registration.Tags.Add(currentUser.Id);

                //services.Log.Info("Registered tag for userId: " + currentUser.Id);
            }
            catch (Exception ex)
            {
                //services.Log.Error(ex.ToString());
            }
            return Task.FromResult(true);
        }
        public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            HttpBindingMetadata httpFunctionMetadata = (HttpBindingMetadata)function.Metadata.InputBindings.FirstOrDefault(p => p.Type == BindingType.HttpTrigger);
            string webHookReceiver = httpFunctionMetadata.WebHookType;
            IWebHookReceiver receiver = null;
            if (string.IsNullOrEmpty(webHookReceiver) || !_receiverLookup.TryGetValue(webHookReceiver, out receiver))
            {
                // If the function is a not a correctly configured WebHook return 500
                return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
            }

            HttpRequestContext context = new HttpRequestContext
            {
                Configuration = _httpConfiguration
            };
            request.SetConfiguration(_httpConfiguration);

            // add the anonymous handler function from above to the request properties
            // so our custom WebHookHandler can invoke it at the right time
            request.Properties.Add(AzureFunctionsCallbackKey, invokeFunction);

            // TODO: Is there a better way? Requests content can't be read multiple
            // times, so this forces it to buffer
            await request.Content.ReadAsStringAsync();

            string receiverId = function.Name.ToLowerInvariant();
            return await receiver.ReceiveAsync(receiverId, context, request);
        }
Exemplo n.º 7
0
        public StripeWebHookReceiverTests()
        {
            _settings = new SettingsDictionary();
            _settings["MS_WebHookReceiverSecret_Stripe"] = TestSecret;

            _config = HttpConfigurationMock.Create(new Dictionary<Type, object> { { typeof(SettingsDictionary), _settings } });
            _context = new HttpRequestContext { Configuration = _config };

            _stripeResponse = new HttpResponseMessage();
            _stripeResponse.Content = new StringContent("{ \"type\": \"action\" }", Encoding.UTF8, "application/json");

            _handlerMock = new HttpMessageHandlerMock();
            _handlerMock.Handler = (req, counter) =>
            {
                string expected = string.Format(CultureInfo.InvariantCulture, StripeWebHookReceiver.EventUriTemplate, TestId);
                Assert.Equal(req.RequestUri.AbsoluteUri, expected);
                return Task.FromResult(_stripeResponse);
            };

            _httpClient = new HttpClient(_handlerMock);
            _receiverMock = new Mock<StripeWebHookReceiver>(_httpClient) { CallBase = true };

            _postRequest = new HttpRequestMessage { Method = HttpMethod.Post };
            _postRequest.SetRequestContext(_context);
        }
        public HttpControllerContext(HttpConfiguration configuration, IHttpRouteData routeData,
            HttpRequestMessage request)
        {
            if (configuration == null)
            {
                throw Error.ArgumentNull("configuration");
            }

            if (routeData == null)
            {
                throw Error.ArgumentNull("routeData");
            }

            if (request == null)
            {
                throw Error.ArgumentNull("request");
            }

            _requestContext = new HttpRequestContext
            {
                Configuration = configuration,
                RouteData = routeData
            };
            _request = request;
        }
Exemplo n.º 9
0
        /// <inheritdoc />
        public override async Task<HttpResponseMessage> ReceiveAsync(string id, HttpRequestContext context, HttpRequestMessage request)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (request.Method == HttpMethod.Post)
            {
                // Ensure that we use https and have a valid code parameter
                await EnsureValidCode(request, id);

                // Read the request entity body.
                JObject data = await ReadAsJsonAsync(request);

                // Call registered handlers
                return await ExecuteWebHookAsync(id, context, request, new string[] { DefaultAction }, data);
            }
            else
            {
                return CreateBadMethodResponse(request);
            }
        }
Exemplo n.º 10
0
        public DropboxWebHookReceiverTests()
        {
            _settings = new SettingsDictionary();
            _settings["MS_WebHookReceiverSecret_Dropbox"] = TestSecret;

            _config = HttpConfigurationMock.Create(new Dictionary<Type, object> { { typeof(SettingsDictionary), _settings } });
            _context = new HttpRequestContext { Configuration = _config };

            _receiverMock = new Mock<DropboxWebHookReceiver> { CallBase = true };

            _getRequest = new HttpRequestMessage();
            _getRequest.SetRequestContext(_context);

            _postRequest = new HttpRequestMessage() { Method = HttpMethod.Post };
            _postRequest.SetRequestContext(_context);
            _postRequest.Content = new StringContent(TestContent, Encoding.UTF8, "application/json");

            byte[] secret = Encoding.UTF8.GetBytes(TestSecret);
            using (var hasher = new HMACSHA256(secret))
            {
                byte[] data = Encoding.UTF8.GetBytes(TestContent);
                byte[] testHash = hasher.ComputeHash(data);
                _testSignature = EncodingUtilities.ToHex(testHash);
            }
        }
        public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            HttpTriggerBindingMetadata httpFunctionMetadata = (HttpTriggerBindingMetadata)function.Metadata.InputBindings.FirstOrDefault(p => p.Type == BindingType.HttpTrigger);
            string webHookReceiver = httpFunctionMetadata.WebHookType;
            IWebHookReceiver receiver = null;
            if (string.IsNullOrEmpty(webHookReceiver) || !_receiverLookup.TryGetValue(webHookReceiver, out receiver))
            {
                // The function is not correctly configured. Log an error and return 500
                string configurationError = string.Format(CultureInfo.InvariantCulture, "Invalid WebHook configuration. Unable to find a receiver for WebHook type '{0}'", webHookReceiver);
                function.Invoker.OnError(new FunctionInvocationException(configurationError));

                return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
            }

            HttpRequestContext context = new HttpRequestContext
            {
                Configuration = _httpConfiguration
            };
            request.SetConfiguration(_httpConfiguration);

            // add the anonymous handler function from above to the request properties
            // so our custom WebHookHandler can invoke it at the right time
            request.Properties.Add(AzureFunctionsCallbackKey, invokeFunction);

            // Request content can't be read multiple
            // times, so this forces it to buffer
            await request.Content.LoadIntoBufferAsync();

            string receiverId = function.Name.ToLowerInvariant();
            return await receiver.ReceiveAsync(receiverId, context, request);
        }
Exemplo n.º 12
0
        public TrelloWebHookReceiverTests()
        {
            _settings = new SettingsDictionary();
            _settings["MS_WebHookReceiverSecret_Trello"] = TestSecret;

            _config = HttpConfigurationMock.Create(new Dictionary<Type, object> { { typeof(SettingsDictionary), _settings } });
            _context = new HttpRequestContext { Configuration = _config };

            _receiverMock = new Mock<TrelloWebHookReceiver> { CallBase = true };

            _headRequest = new HttpRequestMessage() { Method = HttpMethod.Head };
            _headRequest.SetRequestContext(_context);

            _postRequest = new HttpRequestMessage(HttpMethod.Post, TestAddress);
            _postRequest.SetRequestContext(_context);
            _postRequest.Content = new StringContent(TestContent, Encoding.UTF8, "application/json");

            byte[] secret = Encoding.UTF8.GetBytes(TestSecret);
            using (var hasher = new HMACSHA1(secret))
            {
                byte[] data = Encoding.UTF8.GetBytes(TestContent);
                byte[] requestUri = Encoding.UTF8.GetBytes(TestAddress);
                byte[] combo = new byte[data.Length + requestUri.Length];
                Buffer.BlockCopy(data, 0, combo, 0, data.Length);
                Buffer.BlockCopy(requestUri, 0, combo, data.Length, requestUri.Length);
                byte[] testHash = hasher.ComputeHash(combo);
                _signature = EncodingUtilities.ToBase64(testHash, uriSafe: false);
            }
        }
Exemplo n.º 13
0
 public static void AddNavigationUrl(this IList<Map> maps, HttpRequestContext context)
 {
     foreach (var map in maps)
     {
         map.Href = string.Format("{0}/{1}", context.Url.Request.RequestUri.AbsoluteUri, map.Id);
     }
 }
        /// <inheritdoc />
        public override async Task<HttpResponseMessage> ReceiveAsync(string id, HttpRequestContext context, HttpRequestMessage request)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (request.Method != HttpMethod.Post)
            {
                return CreateBadMethodResponse(request);
            }

            // Ensure that the request was made with HTTPS and contains a valid `code` parameter.
            await EnsureValidCode(request, id);

            // Read the request entity body.
            JObject data = await ReadAsJsonAsync(request);
            string messageName = data != null ? data.Value<string>("MessageName") : string.Empty;

            // Call registered WebHook handlers.
            return await ExecuteWebHookAsync(id, context, request, new string[] { messageName }, data);
        }
Exemplo n.º 15
0
        public ApiInfo ApiInfo(HttpRequestContext request)
        {
            var k = request.Url.Request;

            var urlRoot = UrlRoot(request.Url.Request);
            return new ApiInfo
            {
                Title = "CalRecycle Used Oil LCA API",
                Maintainer = new Contact
                {
                    Name = "Brandon Kuczenski",
                    Email = "*****@*****.**"
                },
                Version = ServicesVersion(),
                Links = new List<Link>
                {
                    HelpLink(urlRoot),
                    new Link () {
                        Rel = "license",
                        Title = "BSD License",
                        Href = urlRoot + "LICENSE"
                    }
                }
            };
        }
Exemplo n.º 16
0
 public static void AddNavigationUrl(this IList<PointOfInterest> pois, HttpRequestContext context)
 {
     foreach (var poi in pois)
     {
         poi.Href = string.Format("{0}/pois/{1}", context.Url.Request.RequestUri.AbsoluteUri, poi.Id);
     }
 }
Exemplo n.º 17
0
        public ApiControllerExtensionsTests()
        {
            HttpConfiguration config = new HttpConfiguration();
            IWebHookUser user = new WebHookUser();

            _managerMock = new Mock<IWebHookManager>();
            _resolverMock = new Mock<IDependencyResolver>();
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookManager)))
                .Returns(_managerMock.Object)
                .Verifiable();
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
                .Returns(user)
                .Verifiable();

            config.DependencyResolver = _resolverMock.Object;

            ClaimsIdentity identity = new ClaimsIdentity();
            Claim claim = new Claim(ClaimTypes.Name, "TestUser");
            identity.AddClaim(claim);
            _principal = new ClaimsPrincipal(identity);

            _context = new HttpRequestContext()
            {
                Configuration = config,
                Principal = _principal
            };
            _controller = new TestController()
            {
                RequestContext = _context
            };
        }
Exemplo n.º 18
0
        public void RequestContext_Roundtrips()
        {
            // Arrange
            HttpRequestContext requestContext = new HttpRequestContext();

            // Act/Assert
            PropertyAssert.Roundtrips(_context, c => c.RequestContext, PropertySetter.NullRoundtrips, roundtripValue: requestContext);
        }
 //Automation Constructor
 public TestOffersController(IOffersManager IOffersManager, HttpRequestMessage Request, HttpRequestContext RequestContext)
 {
     parameters = new Dictionary<string, string>();
     this.RequestContext = RequestContext;
     this.RequestContext.RouteData = new HttpRouteData(RequestContext.RouteData.Route, new HttpRouteValueDictionary { { "controller", "testoffers" } });
     this.Request = Request;
     this.OffersManager = IOffersManager;
 }
        public static Guid GetCartId(HttpRequestContext context)
        {
            Guid cartId;
            if (CartIds.TryGetValue(context, out cartId))
                return cartId;

            throw new NotImplementedException($"Cart ID not found for request. Did you apply the {nameof(GetCartIdFromHeadersAttribute)}?");
        }
            public BatchHttpRequestContext(HttpRequestContext batchContext)
            {
                if (batchContext == null)
                {
                    throw new ArgumentNullException("batchContext");
                }

                _batchContext = batchContext;
            }
Exemplo n.º 22
0
 public Model.Map Get(string id, HttpRequestContext context)
 {
     var map = _mapRepository.Get(id);
     map.AddNavigationUrl(context);
     if (map.PoIs != null)
     {
         map.PoIs.AddNavigationUrl(context);
     }
     return map;
 }
        private static bool IsInRoles(HttpRequestContext context, params SecurityRole[] roles)
        {
            bool inRoles = false;

            foreach (var role in roles)
            {
                inRoles |= context.Principal.IsInRole(role.ToString());
            }
            return inRoles;
        }
Exemplo n.º 24
0
        /// <inheritdoc />
        public override async Task<HttpResponseMessage> ReceiveAsync(string receiver, HttpRequestContext context, HttpRequestMessage request)
        {
            if (receiver == null)
            {
                throw new ArgumentNullException("receiver");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (request.Method == HttpMethod.Post)
            {
                EnsureSecureConnection(request);

                // Read the request entity body
                NameValueCollection data = await ReadAsFormDataAsync(request);

                // Verify that the token is correct
                string token = data[TokenParameter];
                string secretKey = GetWebHookSecret(request, SecretKey, 8, 64);
                if (!WebHookReceiver.SecretEqual(token, secretKey))
                {
                    string msg = string.Format(CultureInfo.CurrentCulture, SlackReceiverResources.Receiver_BadToken, TokenParameter);
                    context.Configuration.DependencyResolver.GetLogger().Error(msg);
                    HttpResponseMessage invalidCode = request.CreateErrorResponse(HttpStatusCode.BadRequest, msg);
                    return invalidCode;
                }

                // Get the action
                string action = data[ActionParameter];
                if (string.IsNullOrEmpty(action))
                {
                    string msg = string.Format(CultureInfo.CurrentCulture, SlackReceiverResources.Receiver_BadBody, ActionParameter);
                    context.Configuration.DependencyResolver.GetLogger().Error(msg);
                    HttpResponseMessage badType = request.CreateErrorResponse(HttpStatusCode.BadRequest, msg);
                    return badType;
                }

                // Get the subtext by removing the trigger word
                string text = data[TextParameter];
                data[SubtextParameter] = GetSubtext(action, text);

                // Call registered handlers
                return await ExecuteWebHookAsync(receiver, context, request, new string[] { action }, data);
            }
            else
            {
                return CreateBadMethodResponse(request);
            }
        }
Exemplo n.º 25
0
        /// <inheritdoc />
        public override async Task<HttpResponseMessage> ReceiveAsync(string id, HttpRequestContext context, HttpRequestMessage request)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (request.Method == HttpMethod.Post)
            {
                // Ensure that we use https and have a valid code parameter
                await EnsureValidCode(request, id);

                // Read the request entity body.
                JObject data = await ReadAsJsonAsync(request);

                // Pick out action from headers
                IEnumerable<string> actions;
                if (!request.Headers.TryGetValues(EventHeaderKey, out actions))
                {
                    string msg = string.Format(CultureInfo.CurrentCulture, BitbucketReceiverResources.Receiver_NoEvent, EventHeaderKey);
                    context.Configuration.DependencyResolver.GetLogger().Error(msg);
                    HttpResponseMessage noEventHeader = request.CreateErrorResponse(HttpStatusCode.BadRequest, msg);
                    return noEventHeader;
                }

                // Get the WebHook ID
                IEnumerable<string> webHookId;
                if (!request.Headers.TryGetValues(UUIDHeaderName, out webHookId))
                {
                    string msg = string.Format(CultureInfo.CurrentCulture, BitbucketReceiverResources.Receiver_NoId, UUIDHeaderName);
                    context.Configuration.DependencyResolver.GetLogger().Error(msg);
                    HttpResponseMessage noWebHookIdHeader = request.CreateErrorResponse(HttpStatusCode.BadRequest, msg);
                    return noWebHookIdHeader;
                }

                // Set the WebHook ID in the payload
                data[WebHookIdKey] = webHookId.FirstOrDefault();

                // Call registered handlers
                return await ExecuteWebHookAsync(id, context, request, actions, data);
            }
            else
            {
                return CreateBadMethodResponse(request);
            }
        }
Exemplo n.º 26
0
        public static string GetAuthenticatedUserEmail(HttpRequestContext context)
        {
            var identity = (ClaimsIdentity)context.Principal.Identity;
            var claims = identity.Claims;

            var claimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier";

            return (from c in claims
                    where c.Type == claimType
                    select c.Value).Single();
        }
        public WebHookRegistrationsControllerTests()
        {
            _resolverMock = new Mock<IDependencyResolver>();
            _managerMock = new Mock<IWebHookManager>();
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookManager)))
                .Returns(_managerMock.Object)
                .Verifiable();

            _store = new MemoryWebHookStore();
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookStore)))
                .Returns(_store)
                .Verifiable();

            _user = new WebHookUser();
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookUser)))
                .Returns(_user)
                .Verifiable();

            _filterProviderMock = new Mock<IWebHookFilterProvider>();
            _filterManager = new WebHookFilterManager(new[]
            {
                new WildcardWebHookFilterProvider(),
                _filterProviderMock.Object
            });
            _resolverMock.Setup(r => r.GetService(typeof(IWebHookFilterManager)))
                .Returns(_filterManager)
                .Verifiable();

            _config = new HttpConfiguration();
            _config.DependencyResolver = _resolverMock.Object;

            ClaimsIdentity identity = new ClaimsIdentity();
            Claim claim = new Claim(ClaimTypes.Name, TestUser);
            identity.AddClaim(claim);
            IPrincipal principal = new ClaimsPrincipal(identity);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, Address);
            request.SetConfiguration(_config);
            HttpRequestContext requestContext = new HttpRequestContext()
            {
                Configuration = _config,
                Principal = principal,
                Url = new UrlHelper(request),
            };

            _controllerContext = new HttpControllerContext()
            {
                Configuration = _config,
                Request = new HttpRequestMessage(),
                RequestContext = requestContext,
            };
            _controller = new WebHookRegistrationsControllerMock();
            _controller.Initialize(_controllerContext);
        }
Exemplo n.º 28
0
 public override Task<HttpResponseMessage> ReceiveAsync(string id, HttpRequestContext context, HttpRequestMessage request)
 {
     if (_response != null)
     {
         return Task.FromResult(_response);
     }
     if (_exception != null)
     {
         throw _exception;
     }
     return Task.FromResult(new HttpResponseMessage());
 }
Exemplo n.º 29
0
        public SlackWebHookReceiverTests()
        {
            _settings = new SettingsDictionary();
            _settings["MS_WebHookReceiverSecret_Slack"] = TestSecret;

            _config = HttpConfigurationMock.Create(new Dictionary<Type, object> { { typeof(SettingsDictionary), _settings } });
            _context = new HttpRequestContext { Configuration = _config };

            _receiverMock = new Mock<SlackWebHookReceiver> { CallBase = true };

            _postRequest = new HttpRequestMessage(HttpMethod.Post, "https://some.ssl.host");
            _postRequest.SetRequestContext(_context);
        }
Exemplo n.º 30
0
        public WebHookReceiverTests()
        {
            _config = new HttpConfiguration();
            _resolverMock = new Mock<IDependencyResolver>();
            _config.DependencyResolver = _resolverMock.Object;
            WebHooksConfig.Initialize(_config);
            _request = new HttpRequestMessage();
            _receiverMock = new WebHookReceiverMock();

            _context = new HttpRequestContext();
            _context.Configuration = _config;
            _request.SetRequestContext(_context);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpControllerContext"/> class.
 /// </summary>
 /// <remarks>The default constructor is intended for use by unit testing only.</remarks>
 public HttpControllerContext()
 {
     // Note: This constructor is also used by a FormDataCollectionExtensions where we attempt to create a
     // controller context with incomplete request context.
     _requestContext = new HttpRequestContext();
 }