Esempio n. 1
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);
        }
Esempio n. 2
0
        public async Task MissingHostMxRecordsReturnPending()
        {
            MxEntityState             mxStateFromDao = new MxEntityState("");
            DomainTlsEvaluatorResults pendingEvaluatorResultFromFactory = new DomainTlsEvaluatorResults("", true);

            A.CallTo(() => _mxApiDao.GetMxEntityState("testDomain")).Returns(mxStateFromDao);
            A.CallTo(() => _domainTlsEvaluatorResultsFactory.CreatePending("testDomain")).Returns(pendingEvaluatorResultFromFactory);

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

            A.CallTo(() => _messagePublisher.Publish(A <DomainMissing> ._, A <string> ._)).MustNotHaveHappened();
            Assert.AreSame(pendingEvaluatorResultFromFactory, result);
        }