Exemplo n.º 1
0
        public async Task MxExceptionNotThrownWhenAllowNullResultsSetAndEmptyResult()
        {
            string domain = "abc.com";

            A.CallTo(() => _config.AllowNullResults).Returns(true);

            MxPollResult result = await _mxProcessor.Process(domain);

            Assert.AreEqual(0, result.Records.Count);
        }
Exemplo n.º 2
0
        public async Task ErroredWhenRetrievingMxRecordTest()
        {
            string domain = "abc.com";

            A.CallTo(() => _config.AllowNullResults).Returns(true);

            A.CallTo(() => _dnsClient.GetMxRecords(A <string> ._))
            .Returns(new DnsResult <List <HostMxRecord> >("error"));

            MxPollResult result = await _mxProcessor.Process(domain);

            Assert.That(domain, Is.EqualTo(result.Id));
        }
        public async Task Handle(MxPollPending message)
        {
            try
            {
                MxPollResult dmarcPollResult = await _processor.Process(message.Id);

                _log.LogInformation("Polled MX records for {Domain}", message.Id);

                MxRecordsPolled mxRecordsPolled = dmarcPollResult.ToMxRecordsPolled();

                _dispatcher.Dispatch(mxRecordsPolled, _config.SnsTopicArn);

                _log.LogInformation("Published MX records for {Domain}", message.Id);
            }
            catch (System.Exception ex)
            {
                _log.LogError(ex, $"Error occurred polling domain {message.Id}");
                throw;
            }
        }
 public static MxRecordsPolled ToMxRecordsPolled(this MxPollResult pollResult)
 {
     return(new MxRecordsPolled(pollResult.Id, pollResult.Records, pollResult.Elapsed, pollResult.Error?.ToMessage()));
 }