public async Task <IActionResult> GetDkimDomainStats(DomainProviderIpDateRangeRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorResponse(ModelState.Values)));
            }

            return(Ok(await _aggregateReportService.GetDkimDomainStatsDto(request.Domain, request.Provider, request.Ip, request.StartDate, request.EndDate)));
        }
Exemple #2
0
        public async Task CheckGetDkimDomainStatsDtoReturnsDkimDomainStatsDto()
        {
            string domain       = "ncsc.gov.uk";
            string ip           = "192.168.72.11";
            string dkimDomain   = "ncsc.gov.uk";
            string dkimSelector = "selector";

            string provider = "testProvider";
            string alias    = "testAlias";
            string markdown = "testMarkdown";

            A.CallTo(() => _providerDetailsProvider.GetProviderAliasIn(alias))
            .Returns(provider);
            A.CallTo(() => _providerDetailsProvider.GetProviderAliasOut(provider))
            .Returns(alias);
            A.CallTo(() => _providerDetailsProvider.GetProviderMarkdown(provider))
            .Returns(markdown);

            DkimDomainStats dkimDomainStat = new DkimDomainStats(domain, provider, ip, dkimDomain, dkimSelector, 5, 10);

            List <DkimDomainStats> dkimDomainStats = new List <DkimDomainStats>()
            {
                dkimDomainStat
            };

            A.CallTo(() => _aggregateReportApiDao.GetDkimDomainStats(domain, provider, ip, A <DateTime> ._,
                                                                     A <DateTime> ._))
            .Returns(Task.FromResult(dkimDomainStats));

            DkimDomainStatsDto dkimDomainStatsDto = new DkimDomainStatsDto(domain, provider, ip, dkimDomain, dkimSelector, 5, 10, alias, markdown);

            A.CallTo(() => _dkimDomainStatsMapper.Map(dkimDomainStat, alias, markdown))
            .Returns(dkimDomainStatsDto);

            List <DkimDomainStatsDto> dkimDomainStatsDtoResult = await _aggregateReportService.GetDkimDomainStatsDto(domain, alias, ip, DateTime.MinValue, DateTime.MaxValue);

            Assert.AreSame(dkimDomainStatsDto, dkimDomainStatsDtoResult[0]);
        }