public async Task Handle(DkimRecordEvaluationResult message)
        {
            string id = message.Id.ToLower();

            DkimEntityState state = await LoadDkimState(id, message.Timestamp, nameof(DkimRecordEvaluationResult));

            if (!state.CanUpdate(nameof(DkimRecordEvaluationResult).ToLower(), message.Timestamp))
            {
                _log.LogInformation("Cannot handle event DkimRecordEvaluationResult as newer state exists for {id}.");
                return;
            }

            _changeNotifierComposite.Handle(state, message);
            _domainStatusPublisher.Publish(message);

            List <DkimSelector> selectors = message.ToDkimSelectors();

            state.UpdateRecords(selectors, message.Timestamp);

            DkimEvaluationUpdated evaluationUpdated = state.UpdateEvaluations(message.Timestamp);

            state.Version++;
            state.UpdateSource(nameof(DkimRecordEvaluationResult).ToLower(), message.Timestamp);
            await _dao.Save(state);

            _dispatcher.Dispatch(evaluationUpdated, _config.SnsTopicArn);
            _log.LogInformation("Updated DkimEntity evaluation results for {Id}", id);
        }
Пример #2
0
 public static DkimHistoryRecord ToDkimHistoryRecord(this DkimEvaluationUpdated dkimevaluationUpdated)
 {
     return(new DkimHistoryRecord(dkimevaluationUpdated.Timestamp, null,
                                  dkimevaluationUpdated.DkimEvaluationResults?.Where(_ => _.Records != null && _.Records.Any())
                                  .Select(_ => new DkimHistoryRecordEntry(_.Selector, _.Records.Select(r => r.Record).ToList()))
                                  .ToList()));
 }
Пример #3
0
        public void Test(DkimEvaluationUpdated input, DkimHistoryRecord expected)
        {
            DkimHistoryRecord actual = input.ToDkimHistoryRecord();

            Assert.That(actual.StartDate, Is.EqualTo(expected.StartDate));
            Assert.That(actual.EndDate, Is.EqualTo(expected.EndDate));
            CollectionAssert.AreEqual(actual.Entries, expected.Entries);
        }
Пример #4
0
        public void UpdatesEmptyRecordEvaluationMessages()
        {
            DkimSelector selector1 = CreateSelector(Selector1, CreateRecord(Dkim1, new Message(Guid.NewGuid(), "oh boy!", string.Empty, MessageType.Warning)));

            DkimEntityState state = CreateState(Domain, DkimState.PollPending, selector1);

            DkimSelector selector2 = CreateSelector(Selector1, CreateRecordWithEmptyList(Dkim1));

            state.UpdateRecords(new List <DkimSelector> {
                selector2
            }, DateTime.UtcNow);

            DkimEvaluationUpdated evaluationUpdated = state.UpdateEvaluations(DateTime.UtcNow);

            Assert.AreEqual(evaluationUpdated.DkimEvaluationResults[0].Records[0].EvaluationMessages.Count, 0);
        }
Пример #5
0
        public void UpdatesWithNoChangesRecordEvaluationMessages()
        {
            DkimSelector selector1 = CreateSelector(Selector1, CreateRecord(Dkim1));

            DkimEntityState state = CreateState(Domain, DkimState.PollPending, selector1);

            DkimSelector selector2 = CreateSelector(Selector1, CreateRecord(Dkim1));

            state.UpdateRecords(new List <DkimSelector> {
                selector2
            }, DateTime.UtcNow);

            DkimEvaluationUpdated evaluationUpdated = state.UpdateEvaluations(DateTime.UtcNow);

            Assert.That(evaluationUpdated, Is.Not.Null);
        }