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 EvaluatorResultsAreReturned()
        {
            MxEntityState mxStateFromDao = new MxEntityState("")
            {
                HostMxRecords = new List <HostMxRecord> {
                    new HostMxRecord("testHost1", 0, null)
                }
            };

            Dictionary <string, TlsEntityState> tlsEntityStatesFromDao     = new Dictionary <string, TlsEntityState>();
            DomainTlsEvaluatorResults           evaluatorResultFromFactory = new DomainTlsEvaluatorResults("", false);

            A.CallTo(() => _mxApiDao.GetMxEntityState("testDomain")).Returns(mxStateFromDao);
            A.CallTo(() => _mxApiDao.GetTlsEntityStates(A <List <string> > ._)).Returns(tlsEntityStatesFromDao);
            A.CallTo(() => _domainTlsEvaluatorResultsFactory.Create(mxStateFromDao, tlsEntityStatesFromDao)).Returns(evaluatorResultFromFactory);

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

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