public async Task ExecuteAsync_Dispatches_TeamRoomMessagePosted() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.message.posted.json", "message.posted"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<TeamRoomMessagePostedPayload>()), Times.Once()); }
public async Task ExecuteAsync_Dispatches_WorkItemCommentedOn() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.workitem.commented.json", "workitem.commented"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<WorkItemCommentedOnPayload>()), Times.Once()); }
public async Task ExecuteAsync_Dispatches_BuildCompleted() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.build.complete.json", "build.complete"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<BuildCompletedPayload>()), Times.Once()); }
public async Task ExecuteAsync_Dispatches_CodeCheckedIn() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.tfvc.checkin.json", "tfvc.checkin"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<CodeCheckedInPayload>()), Times.Once()); }
public async Task ExecuteAsync_Dispatches_PackageDeleted() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.PackageDeletedMessage.json", "PackageDeletedWebHookEventPayloadV1"); // Act await _handler.ExecuteAsync(MyGetWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(MyGetWebHookReceiver.ReceiverName, _context, It.IsAny<PackageDeletedPayload>()), Times.Once()); }
public async Task ExecuteAsync_Handles_NoPayloadProperty() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.NoPayloadMessage.json", "None"); // Act await _handler.ExecuteAsync(MyGetWebHookReceiver.ReceiverName, _context); // Assert HttpError error = await _context.Response.Content.ReadAsAsync<HttpError>(); Assert.Equal("The WebHook request must contain a 'Payload' JSON property containing the event payload.", error.Message); }
public override void UnknownEvent(WebHookHandlerContext context, JObject payload) { context.RequestContext.Configuration.DependencyResolver.GetLogger().Info($"Unknown event"); }
public override void ClientEvent(WebHookHandlerContext context, ClientEventPayload payload) { context.RequestContext.Configuration.DependencyResolver.GetLogger().Info($"Client event"); }
public override void MemberRemoved(WebHookHandlerContext context, MemberRemovedPayload payload) { context.RequestContext.Configuration.DependencyResolver.GetLogger().Info($"Member {payload.UserId} removed from channel {payload.Channel}"); }
public override async Task ExecuteAsync(string generator, WebHookHandlerContext context) { var content = await context.Request.Content.ReadAsStringAsync(); Trace.WriteLine(string.Format("Generator: {0} - Content: {1}", generator, content)); }
public async Task ExecuteAsync_Handles_UnknownPayloadProperty() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.UnknownMessage.json", "Unknown"); // Act await _handler.ExecuteAsync(MyGetWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteUnknownPayloadAsync(MyGetWebHookReceiver.ReceiverName, _context, It.IsAny<JObject>()), Times.Once()); }
public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { // For more information about Slack WebHook payloads, please see // 'https://api.slack.com/outgoing-webhooks' NameValueCollection command = context.GetDataOrDefault <NameValueCollection>(); // We can trace to see what is going on. Trace.WriteLine(command.ToString()); // Switch over the IDs we used when configuring this WebHook switch (context.Id) { case "trigger": // Parse the trigger text of the form 'action parameters'. var triggerCommand = SlackCommand.ParseActionWithValue(command["subtext"]); // Information can be returned using a SlackResponse string reply1 = string.Format( "Received trigger '{0}' with action '{1}' and value '{2}'", command["trigger_word"], triggerCommand.Key, triggerCommand.Value); var triggerReply = new SlackResponse(reply1); context.Response = context.Request.CreateResponse(triggerReply); break; case "slash": // Parse the slash text of the form 'action p1=v1; p2=v2; ...'. var slashCommand = SlackCommand.ParseActionWithParameters(command["text"]); string reply2 = string.Format( "Received slash command '{0}' with action '{1}' and value '{2}'", command["command"], slashCommand.Key, slashCommand.Value.ToString()); // Information can be returned using a SlackSlashResponse with attachments var slashReply = new SlackSlashResponse(reply2); // Slash replies can be augmented with attachments containing data, images, and more var att = new SlackAttachment("Attachment Text", "Fallback description") { Color = "#439FE0", Pretext = "Hello from ASP.NET WebHooks!", Title = "Attachment title", }; // Slash attachments can contain tabular data as well att.Fields.Add(new SlackField("Field1", "1234")); att.Fields.Add(new SlackField("Field2", "5678")); // A reply can contain multiple attachments slashReply.Attachments.Add(att); // Return slash command response context.Response = context.Request.CreateResponse(slashReply); break; } return(Task.FromResult(true)); }
public override Task ExecuteAsync(WebHookHandlerContext context, GitPullRequestUpdatedPayload payload) { return(_updatedPullRequestHandler.Handle(payload)); }
public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { CustomNotifications notifications = context.GetDataOrDefault <CustomNotifications>(); foreach (var notification in notifications.Notifications) {
public override void ChannelOccupied(WebHookHandlerContext context, ChannelOccupiedPayload payload) { context.RequestContext.Configuration.DependencyResolver.GetLogger().Info($"Channel {payload.Channel} is occupied"); }
public async Task ExecuteAsync_Dispatches_GitPullRequestUpdated() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.git.pullrequest.updated.json", "git.pullrequest.created"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<GitPullRequestCreatedPayload>()), Times.Once()); }
public async Task ExecuteAsync_Handles_UnknownEventType() { // Arrange _context = GetContext("Microsoft.AspNet.WebHooks.Messages.bad.notMappedEventType.json", "unknown"); // Act await _handler.ExecuteAsync(VstsWebHookReceiver.ReceiverName, _context); // Assert _handlerMock.Verify(h => h.ExecuteAsync(_context, It.IsAny<JObject>()), Times.Once()); }
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context) { WebHookCounter.AddToCount(); return(Task.CompletedTask); }
/// <summary> /// This one processes the <see cref="PackageDeletedPayload"/> WebHook. /// </summary> public override Task ExecuteAsync(string receiver, WebHookHandlerContext context, PackageDeletedPayload payload) { return(Task.FromResult(true)); }
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context) { return(Task.FromResult(true)); }
private static object GetWebHookData(Type dataType, WebHookHandlerContext context) { MethodInfo getDataMethod = _getWebHookDataMethod.Value.MakeGenericMethod(dataType); return(getDataMethod.Invoke(null, new object[] { context })); }
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context) { GithubPayload payload = GetPayload(context); return(Task.WhenAll(_notifierProvider.Provide().Select(n => n.Notify(payload)))); }
public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { IWebSubContent content = context.Data as IWebSubContent; return(Task.FromResult(true)); }
private static GithubPayload GetPayload(WebHookHandlerContext context) { var json = context.GetDataOrDefault <JObject>(); return(json.ToObject <GithubPayload>()); }
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context) { // Console.WriteLine("Received notification with payload:"); SetWebHookData(context); return(Task.FromResult(true)); }
public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { JObject entry = context.GetDataOrDefault <JObject>(); return(Task.FromResult(true)); }