Exemple #1
0
        public void LocalStorageInstanceCreateTest()
        {
            var settingsRepo    = new SettingsRepository();
            var settingsService = new SettingsService(settingsRepo);
            var settings        = settingsService.Get(Path.Join(Directory.GetCurrentDirectory(), "settings.example.json"));

            var instance = CertificateStorageFactory.CreateCertificateStorage(settings);

            Assert.IsType <SiteStatus.Infrastructures.Certificates.Storage.Local>(instance);
        }
Exemple #2
0
        public void ThrowExceptionTest()
        {
            var settingsRepo    = new SettingsRepository();
            var settingsService = new SettingsService(settingsRepo);
            var settings        = settingsService.Get(Path.Join(Directory.GetCurrentDirectory(), "settings.example.json"));

            settings.StorageType = "dummy";

            Assert.Throws <ArgumentException>(() =>
            {
                CertificateStorageFactory.CreateCertificateStorage(settings);
            });
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var settingsRepo    = new SettingsRepository();
            var settingsService = new SettingsService(settingsRepo);
            var settings        = settingsService.Get(Path.Join(Directory.GetCurrentDirectory(), "settings.json"));

            // TODO: impl validation

            var domains = settings.Domains.Distinct();
            var slds    = domains
                          .Where(d => d.Contains("."))
                          .Select(d =>
            {
                var x = d.Split(".").Reverse().ToArray();
                return(string.Join(".", x[1], x[0]));
            })
                          .Distinct();

            try
            {
                var whoisStorage            = WhoisStorageFactory.CreateWhoisStorage(settings);
                var whoisRepository         = new WhoisRepository(whoisStorage);
                var whoisService            = new WhoisService(whoisRepository);
                var whoisApplicationService = new WhoisApplicationService(whoisService);

                var whoisInfos = whoisApplicationService.LookupParallelly(slds);
                whoisApplicationService.Put(whoisInfos);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                var certificateStorage            = CertificateStorageFactory.CreateCertificateStorage(settings);
                var certificateRepository         = new CertificateRepository(certificateStorage);
                var certificateService            = new CertificateService(certificateRepository);
                var certificateApplicationService = new CertificateApplicationService(certificateService);

                var certificates = certificateApplicationService.GetServerCertificateParallelly(domains);
                certificateApplicationService.Put(certificates);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }