Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            if (!_blogConfig.AdvancedSettings.EnablePingBackReceive)
            {
                Logger.LogInformation("Pingback receive is disabled");
                return(Forbid());
            }

            var response = await _pingbackService.ProcessReceivedPayloadAsync(HttpContext);

            Logger.LogInformation($"Pingback Processor Response: {response.ToString()}");
            return(new PingbackResult(response));
        }
Exemplo n.º 2
0
        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.ProcessReceivedPayloadAsync(httpContextMock.Object));
        }