public async Task <IActionResult> Index() { if (!AppSettings.EnablePingBackReceive) { Logger.LogInformation("Pingback receive is disabled"); return(Forbid()); } var response = await _pingbackService.ProcessReceivedPingback(HttpContext); switch (response) { case PingbackServiceResponse.Success: return(Content(PingbackReceiver.SuccessResponseString, "text/xml")); case PingbackServiceResponse.Error17SourceNotContainTargetUri: return(XmlContent(17, "The source URI does not contain a link to the target URI, and so cannot be used as a source.")); case PingbackServiceResponse.Error32TargetUriNotExist: return(XmlContent(32, "The specified target URI does not exist.")); case PingbackServiceResponse.Error48PingbackAlreadyRegistered: return(XmlContent(48, "The pingback has already been registered.")); case PingbackServiceResponse.SpamDetectedFakeNotFound: return(NotFound()); case PingbackServiceResponse.GenericError: return(ServerError()); default: return(BadRequest()); } }
public async Task <IActionResult> Index() { if (!_blogConfig.AdvancedSettings.EnablePingBackReceive) { Logger.LogInformation("Pingback receive is disabled"); return(Forbid()); } var response = await _pingbackService.ProcessReceivedPingback(HttpContext); Logger.LogInformation($"Pingback Processor Response: {response.ToString()}"); return(new PingbackResult(response)); }
public async Task <PingbackServiceResponse> TestProcessReceivedPingbackInvalidRequest(PingbackValidationResult result) { var tcs = new TaskCompletionSource <PingbackValidationResult>(); tcs.SetResult(result); var pingbackReceiverMock = new Mock <IPingbackReceiver>(); pingbackReceiverMock.Setup(p => p.ValidatePingRequest(It.IsAny <HttpContext>())).Returns(tcs.Task); //var postMock = new Mock<PostService>(MockBehavior.Loose); var httpContextMock = new Mock <HttpContext>(); var svc = new PingbackService( _loggerMock.Object, pingbackReceiverMock.Object, _pingbackRepositoryMock.Object, _postRepositoryMock.Object, _notificationMock.Object); return(await svc.ProcessReceivedPingback(httpContextMock.Object)); }