Skip to content

Commit d0f3ea8

Browse files
authored
Adding PUT to the list of supported WebHook verbs (#9812)
1 parent d6653fb commit d0f3ea8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/WebJobs.Script.WebHost/Controllers/HostController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
454454
return Accepted();
455455
}
456456

457-
[AcceptVerbs("GET", "POST", "DELETE", "OPTIONS")]
457+
[AcceptVerbs("GET", "PUT", "POST", "DELETE", "OPTIONS")]
458458
[Authorize(Policy = PolicyNames.SystemKeyAuthLevel)]
459459
[Route("runtime/webhooks/{extensionName}/{*extra}")]
460460
[RequiresRunningHost]

test/WebJobs.Script.Tests.Integration/WebHostEndToEnd/SamplesEndToEndTests_CSharp.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,18 @@ public async Task ExtensionWebHook_Succeeds()
231231
_fixture.MockWebHookProvider.Setup(p => p.TryGetHandler("test", out handler)).Returns(true);
232232
_fixture.MockWebHookProvider.Setup(p => p.TryGetHandler("invalid", out handler)).Returns(false);
233233

234-
// successful request
234+
// successful request for all supported verbs
235235
string uri = "runtime/webhooks/test?code=SystemValue3";
236-
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);
237-
HttpResponseMessage response = await _fixture.Host.HttpClient.SendAsync(request);
238-
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
236+
HttpRequestMessage request = null;
237+
HttpResponseMessage response = null;
238+
var httpMethods = new HttpMethod[] { HttpMethod.Get, HttpMethod.Put, HttpMethod.Post, HttpMethod.Delete, HttpMethod.Options };
239+
foreach (var httpMethod in httpMethods)
240+
{
241+
uri = "runtime/webhooks/test?code=SystemValue3";
242+
request = new HttpRequestMessage(httpMethod, uri);
243+
response = await _fixture.Host.HttpClient.SendAsync(request);
244+
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
245+
}
239246

240247
// invalid system key value - no key match
241248
uri = "runtime/webhooks/test?code=invalid";

0 commit comments

Comments
 (0)