aspnet / WebHooks

[Archived] Libraries to create and consume web hooks on ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
Apache License 2.0
627 stars 439 forks source link

Specifying WebHookBodyType.Form continues to allow application/json #294

Closed pranavkm closed 6 years ago

pranavkm commented 6 years ago

Not sure if this is the expected behavior, but it seemed anomalous. I started with a GitHubWebHookAttribute on an action and replaced it with a GeneralWebHook. I configured the appsettings.json and restarted the site. Sending payloads from GitHub worked. I edited the bodyType for the parameter to WebHookBodyType.Form but I continue to see the requests go through:

Controller:

public class ValuesController : ControllerBase
{
    [HttpGet("/api/values")]
    public IActionResult Get() => Content("Hello");

    // GET api/values
    [GeneralWebHook(Microsoft.AspNetCore.WebHooks.Metadata.WebHookBodyType.Form, Id ="test")]
    public IActionResult Action()
    {
        return Ok();
    }
}

GitHub request:

image

Application log:

Application started. Press Ctrl+C to shut down. info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 POST https://52.175.238.250/api/webhooks/incoming/github/test application/json 5727 info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Route matched with {action = "Action", controller = "Values"}. Executing action WebApplication3.Controllers.ValuesController.Action (WebApplication3) info: Microsoft.AspNetCore.WebHooks.Filters.WebHookReceiverExistsFilter[3] Processing incoming WebHook request with receiver 'github' and id 'test'. info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Executing action method WebApplication3.Controllers.ValuesController.Action (WebApplication3) - Validation state: Valid info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2] Executed action method WebApplication3.Controllers.ValuesController.Action (WebApplication3), returned result Microsoft.AspNetCore.Mvc.OkResult in 0.3254ms. info: Microsoft.AspNetCore.Mvc.StatusCodeResult[1] Executing HttpStatusCodeResult, setting HTTP status code 200 info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2] Executed action WebApplication3.Controllers.ValuesController.Action (WebApplication3) in 65.7481ms info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 217.1139ms 200

Tested using 2.1.0-rc1-30678

dougbu commented 6 years ago

Placing onto the backlog, pending customer requests in this area.

aspnet-hello commented 6 years ago

This issue was moved to aspnet/AspLabs#39