示例#1
0
        public async Task MissingDomainPublished()
        {
            A.CallTo(() => _mxApiDao.GetMxEntityState("testDomain")).Returns((MxEntityState)null);

            DomainTlsEvaluatorResults result = await _mxService.GetDomainTlsEvaluatorResults("testDomain");

            A.CallTo(() => _messagePublisher.Publish(A <DomainMissing> .That.Matches(x => x.Id == "testDomain"), "SnsTopicArn")).MustHaveHappenedOnceExactly();
            Assert.Null(result);
        }
示例#2
0
        public async Task <DomainTlsEvaluatorResults> GetDomainTlsEvaluatorResults(string domain)
        {
            MxEntityState mxState = await _mxApiDao.GetMxEntityState(domain);

            if (mxState == null)
            {
                _log.LogInformation($"Domain {domain} not found - publishing DomainMissing");
                await _messagePublisher.Publish(new DomainMissing(domain), _config.MicroserviceOutputSnsTopicArn);

                return(null);
            }

            if (mxState.HostMxRecords == null)
            {
                return(_domainTlsEvaluatorResultsFactory.CreatePending(domain));
            }

            List <string> hostNames = mxState.HostMxRecords.Select(x => x.Id).ToList();

            Dictionary <string, TlsEntityState> tlsEntityStates = await _mxApiDao.GetTlsEntityStates(hostNames);

            DomainTlsEvaluatorResults result = _domainTlsEvaluatorResultsFactory.Create(mxState, tlsEntityStates);

            return(result);
        }