public void AllProperty() { var target = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false, true) .Build(); var actual = target.Get <AppSettingsConfig>(); var expected = new AppSettingsConfig() { Option1 = "Value1", Option2 = 2, A = new AOption { A1 = "AA" }, B = new[] { new BOption { Name = "Gandalf", Age = 1000, }, new BOption { Name = "Harry", Age = 17, }, } }; actual.Should().BeEquivalentTo(expected); }
public void Init() { SetupMockServices(); var appSettingsConfig = new AppSettingsConfig() { LogEndpointOverride = false }; var logValidationRulesConfig = new LogValidationRulesConfig() { SeverityRegex = "^(ERROR|INFO|WARNING)$", PositiveNumbersRegex = "^[0-9]\\d*$", BuildVersionRegex = "^[1-9]{1}[0-9]*([.][0-9]*){1,2}?$", OperationSystemRegex = "^(IOS|Android-Google|Android-Huawei|Unknown)$", DeviceOSVersionRegex = "[1-9]{1}[0-9]{0,2}([.][0-9]{1,3}){1,2}?$", MaxTextFieldLength = 500, }; _controller = new LoggingController(_logMessageValidator.Object, _logger.Object, logValidationRulesConfig, appSettingsConfig) { ControllerContext = new ControllerContext() { HttpContext = MakeFakeContext(true).Object } }; }
/// <summary> /// Ctor initializing HangFire monitoring API object /// </summary> public HangFireHealthCheck(ILogger <HangFireHealthCheck> logger, IHealthCheckHangFireService healthCheckHangFireService, AppSettingsConfig appSettingsConfig) { _logger = logger; _hangFireMonitoringApi = healthCheckHangFireService.GetHangFireMonitoringApi(); _healthCheckHangFireService = healthCheckHangFireService; _appSettingsConfig = appSettingsConfig; }
private void SetupMockConfiguration() { _appSettingsConfig = new AppSettingsConfig() { ZipCertificatePath = _pemFilePath }; }
protected void Application_Start(object sender, EventArgs e) { // logging: XmlConfigurator.Configure(); // config: IConfig config = new AppSettingsConfig(); // DI - core components: var builder = new ContainerBuilder(); builder.RegisterInstance(config).As <IConfig>().SingleInstance(); builder.Register(c => LogManager.GetLogger(typeof(object))).As <ILog>(); builder.RegisterType <WideWorldImportersEntities>().InstancePerLifetimeScope(); // mappers: builder.RegisterAutoMapper(typeof(Global).Assembly); // cache: if (config.UseCache) { builder.RegisterType <MemoryCache>().As <ICache>().SingleInstance(); } else { builder.RegisterType <NullCache>().As <ICache>().SingleInstance(); } // services: builder.RegisterType <CitiesService>().InstancePerLifetimeScope(); var container = builder.Build(); AutofacHostFactory.Container = container; }
private EuGatewayService CreateGatewayServiceAndDependencies(IGatewayHttpClient httpClient) { var translationsRepositoryMock = new Mock <IGenericRepository <Translation> >(MockBehavior.Strict); IOriginSpecificSettings originConfig = new AppSettingsConfig() { OriginCountryCode = _originCountry.Code.ToUpper() }; var countryRepository = new CountryRepository(_dbContext, translationsRepositoryMock.Object, originConfig); var keysRepository = new TemporaryExposureKeyRepository(_dbContext, countryRepository, _logger.Object); var signatureServiceMock = new Mock <ISignatureService>(MockBehavior.Strict); signatureServiceMock.Setup(sigService => sigService.Sign(It.IsAny <TemporaryExposureKeyGatewayBatchProtoDto>(), Domain.SortOrder.ASC)) .Returns(new byte[] { 1, 2, 3, 4, 5, 6, 7 }); var webContextReaderMock = new Mock <IGatewayWebContextReader>(MockBehavior.Strict); var loggerMock = new Mock <ILogger <EuGatewayService> >(MockBehavior.Loose); var keyFilterMock = new Mock <IKeyFilter>(MockBehavior.Strict); var storeService = new Mock <IEFGSKeyStoreService>(MockBehavior.Strict); var autoMapper = CreateAutoMapperWithDependencies(countryRepository); return(CreateGatewayService(keysRepository, signatureServiceMock.Object, autoMapper, httpClient, keyFilterMock.Object, webContextReaderMock.Object, storeService.Object, loggerMock.Object, _config )); }
public AddTemporaryExposureKeyService CreateTestObject() { _temporaryExposureKeyRepositoryMock.Setup(x => x.GetNextBatchOfKeysWithRollingStartNumberThresholdAsync(It.IsAny <long>(), It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new List <TemporaryExposureKey>()); _temporaryExposureKeyRepositoryMock.Setup(x => x.GetNextBatchOfKeysWithRollingStartNumberThresholdAsync(It.IsAny <long>(), 0, It.IsAny <int>())).ReturnsAsync(new List <TemporaryExposureKey>() { new TemporaryExposureKey() }); var countryRepositoryMock = new Mock <ICountryRepository>(); countryRepositoryMock.Setup( m => m.FindByIsoCode(It.IsAny <string>())) .Returns(new Country() { Code = "DK" }); var temporaryExposureKeyCountryRepositoryMock = new Mock <IGenericRepository <TemporaryExposureKeyCountry> >(); var exposureKeyMapperMock = new Mock <IExposureKeyMapper>(); exposureKeyMapperMock.Setup(x => x.FromDtoToEntity(It.IsAny <TemporaryExposureKeyBatchDto>())).Returns(_exampleKeyList); var config = new AppSettingsConfig() { MaxKeysPerFile = 750000 }; var addTemporaryExposureKeyService = new AddTemporaryExposureKeyService( countryRepositoryMock.Object, temporaryExposureKeyCountryRepositoryMock.Object, exposureKeyMapperMock.Object, _temporaryExposureKeyRepositoryMock.Object, config); return(addTemporaryExposureKeyService); }
/// <summary> /// Ctor for HealthCheckAuthorizationHandler /// </summary> /// <param name="config"></param> /// <param name="httpContextAccessor"></param> /// <param name="authOptions"></param> /// <param name="logger"></param> public HealthCheckAuthorizationHandler(AppSettingsConfig config, IHttpContextAccessor httpContextAccessor, AuthOptions authOptions, ILogger <HealthCheckAuthorizationHandler> logger) { _httpContextAccessor = httpContextAccessor; _authOptions = authOptions; _logger = logger; _tokenEncrypted = config.HealthCheckSettings.AuthorizationHealthCheck; }
/// <summary> /// Ctor /// </summary> /// <param name="apiConfiguration"></param> /// <param name="logger"></param> /// <param name="fileSystem"></param> /// <param name="covidStatisticsRepository"></param> public NumbersTodayHealthCheck(AppSettingsConfig apiConfiguration, ILogger <NumbersTodayHealthCheck> logger, IFileSystem fileSystem, ICovidStatisticsRepository covidStatisticsRepository) { _appSettingsConfig = apiConfiguration; _logger = logger; _fileSystem = fileSystem; _covidStatisticsRepository = covidStatisticsRepository; }
public TypicodeService(ILogger <TypicodeService> logger, AppSettingsConfig appSettingsConfig, IHttpClientFactoryService httpClientFactoryService) { this._logger = logger; this._typicodeConfig = appSettingsConfig.Typicode; this._httpClientFactoryService = httpClientFactoryService; }
public StackoverflowService(ILogger <StackoverflowService> logger, AppSettingsConfig appSettingsConfig, IHttpClientFactoryService httpClientFactoryService) { this._logger = logger; this._stackoverflowConfig = appSettingsConfig.Stackoverflow; this._httpClientFactoryService = httpClientFactoryService; }
private void ServerConfigurationInjection(IServiceCollection services) { var dbConfig = new AppSettingsConfig(); Configuration.Bind(dbConfig); var serverConfiguration = new ServerConfiguration(dbConfig); services.AddSingleton <IServerConfiguration>(serverConfiguration); }
public AwsS3ServiceTests() { _faker = new Faker(); _appSettings = new AppSettingsConfig(); _appSettings.AwsS3Bucket = "s3-teste"; _amazonS3Mock = new Mock <IAmazonS3>(); _awsS3Service = new AwsS3Service(_amazonS3Mock.Object, _appSettings); }
public AddTemporaryExposureKeyService(ICountryRepository countryRepository, IGenericRepository <TemporaryExposureKeyCountry> temporaryExposureKeyCountryRepository, IExposureKeyMapper exposureKeyMapper, ITemporaryExposureKeyRepository temporaryExposureKeyRepository, AppSettingsConfig appSettingsConfig) { _countryRepository = countryRepository; _temporaryExposureKeyCountryRepository = temporaryExposureKeyCountryRepository; _temporaryExposureKeyRepository = temporaryExposureKeyRepository; _exposureKeyMapper = exposureKeyMapper; _appSettingsConfig = appSettingsConfig; }
public CacheOperations(IMemoryCache memoryCache, AppSettingsConfig appSettingsConfig, IPackageBuilderService cachePackageBuilder, ILogger <CacheOperations> logger) { _logger = logger; _memoryCache = memoryCache; _appSettingsConfig = appSettingsConfig; _cachePackageBuilder = cachePackageBuilder; _previousDayFileCaching = appSettingsConfig.PreviousDayFileCaching; _currentDayFileCaching = appSettingsConfig.CurrentDayFileCaching; }
private void SetupMockConfiguration() { _appSettingsConfig = new AppSettingsConfig() { CacheMonitorTimeout = 100, PreviousDayFileCaching = TimeSpan.Parse("15.00:00:00.000"), CurrentDayFileCaching = TimeSpan.Parse("02:00:00.000") }; _cachePackageBuilder = new Mock <IPackageBuilderService>(); }
/// <summary> /// Gets the message. /// </summary> /// <param name="appSettings">The application settings.</param> /// <param name="client">The client.</param> /// <returns></returns> private static MessageApiModel GetMessage(AppSettingsConfig appSettings, HttpClient client) { var endpoint = AppSettings.Get <Uri>(appSettings.GetMessageEndpoint); var response = client.GetAsync(endpoint).Result; var result = response.Content.ReadAsStringAsync().Result; response.Dispose(); return(JsonConvert.DeserializeObject <MessageApiModel>(result)); }
/// <summary> /// Configures the builder. /// </summary> /// <param name="appSettings">The application settings.</param> private static void ConfigureBuilder(out AppSettingsConfig appSettings) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(Constants.APPSETTINGS, optional: true, reloadOnChange: true); appSettings = new AppSettingsConfig(); var configuration = builder.Build(); configuration.GetSection(Constants.CROWE_EXERCISE_SETTINGS).Bind(appSettings); }
public GameServicesController( IOptions <AppSettingsConfig> appSettingsConfig, IOptions <AuthenticationConfig> authenticationConfig, GameServiceClient gameServiceClient, IMemcachedClient memcachedClient) { this.appSettingsConfig = appSettingsConfig.Value; this.authenticationConfig = authenticationConfig.Value; this.gameServiceClient = gameServiceClient; this.memcachedClient = memcachedClient; }
private AppSettingsConfig GetConfig() { var endpoint = (string)Configuration.GetValue(typeof(string), "ApiEndpoint"); var statusEndpoint = (string)Configuration.GetValue(typeof(string), "ApiStatusEndpoint"); var useDummyValue = (string)Configuration.GetValue(typeof(string), "UseDummyData"); var useDummyFlag = !string.IsNullOrWhiteSpace(useDummyValue) && useDummyValue.ToLowerInvariant() == "true"; var config = new AppSettingsConfig { ApiEndpoint = endpoint, UseDummyData = useDummyFlag, ApiStatusEndpoint = statusEndpoint }; return(config); }
private void SetupMockServices() { _logger = new Mock <ILogger <DiagnosticKeysController> >(); _temporaryExposureKeyRepository = new Mock <ITemporaryExposureKeyRepository>(); _configuration = new Mock <IConfiguration>(); _exposureKeyMapper = new Mock <IExposureKeyMapper>(); _exposureKeyMapper.Setup(mock => mock.FilterDuplicateKeys(It.IsAny <IList <TemporaryExposureKey> >(), It.IsAny <IList <TemporaryExposureKey> >())) .Returns(_exampleKeys); var configurationSection = new Mock <IConfigurationSection>(); configurationSection.Setup(a => a.Value).Returns("false"); _configuration.Setup(a => a.GetSection("deviceVerificationEnabled")).Returns(configurationSection.Object); _exposureKeyValidator = new Mock <IExposureKeyValidator>(); _addTemporaryExposureKeyService = new Mock <IAddTemporaryExposureKeyService>(MockBehavior.Strict); _exposureConfigurationService = new Mock <IExposureConfigurationService>(MockBehavior.Strict); _cacheOperation = new Mock <ICacheOperations>(MockBehavior.Strict); _countryServiceMock = new Mock <ICountryService>(); _countryRepository = new Mock <ICountryRepository>(); _appSettingsConfig = new AppSettingsConfig() { DeviceVerificationEnabled = false, CacheMonitorTimeout = 100, FetchCommandTimeout = 0, EnableCacheOverride = true }; var packageNames = new PackageNameConfig() { Apple = "com.netcompany.smittestop - exposure - notification", Google = "com.netcompany.smittestop_exposure_notification" }; _keyValidationConfiguration = new KeyValidationConfiguration() { PackageNames = packageNames }; _addTemporaryExposureKeyService.Setup(x => x.GetFilteredKeysEntitiesFromDTO(It.IsAny <TemporaryExposureKeyBatchDto>())) .ReturnsAsync(new List <TemporaryExposureKey>() { new TemporaryExposureKey() }); SetupMockExposureConfiugrationService(); SetupMockCacheOperation(1); }
/// <summary> /// Posts the message. /// </summary> /// <param name="appSettings">The application settings.</param> /// <param name="client">The client.</param> /// <returns>HttpStatusCode</returns> private static HttpStatusCode PostMessage(AppSettingsConfig appSettings, HttpClient client) { var json = JsonConvert.SerializeObject(new MessageApiModel { Message = appSettings.MessageToSend }); var content = new StringContent(json, Encoding.UTF8, "application/json"); var endpoint = AppSettings.Get <Uri>(appSettings.GetMessageEndpoint); var response = client.PostAsync(endpoint, content).Result; content.Dispose(); return(response.StatusCode); }
public LoggingController( ILogMessageValidator logMessageValidator, ILogger <LoggingController> logger, LogValidationRulesConfig logValidationRulesConfig, AppSettingsConfig appSettingsConfig) { _logMessageValidator = logMessageValidator; _logger = logger; _logMobilePatternsDictionary = InitializePatternDictionary(logValidationRulesConfig); _loggerMobile = MobileLoggerFactory.GetLogger(); _maxTextFieldLength = logValidationRulesConfig.MaxTextFieldLength; _logEndpointOverride = appSettingsConfig.LogEndpointOverride; }
public void RemoveKeyDuplicates_ShouldOnlyWorkOnKeysCreatedUpTo14DaysAgo() { var options = new DbContextOptionsBuilder <DigNDB_SmittestopContext>() .UseInMemoryDatabase(nameof(EuGatewayServiceUploadTest)) .Options; var dbContext = new DigNDB_SmittestopContext(options); dbContext.Database.EnsureDeleted(); var translationsRepositoryMock = new Mock <IGenericRepository <Translation> >(MockBehavior.Strict); var originSpecificSettings = new AppSettingsConfig() { OriginCountryCode = "dk" }; var countryRepository = new CountryRepository(dbContext, translationsRepositoryMock.Object, originSpecificSettings); var keysRepository = new TemporaryExposureKeyRepository(dbContext, countryRepository); _keyFilter = new KeyFilter(_keyMapper, _keyValidator.Object, new ExposureKeyMapper(), _logger.Object, keysRepository); var rollingStartNumberNewerThan14Days = DateTimeOffset.Now.Subtract(new TimeSpan(DaysOffset - 1, 0, 0, 0)).ToUnixTimeSeconds(); var rollingStartNumberOlderThan14Days = DateTimeOffset.Now.Subtract(new TimeSpan(DaysOffset + 3, 0, 0, 0)).ToUnixTimeSeconds(); var origin = new Country { Id = 1 }; var keysNewerThan14Days = new List <TemporaryExposureKey> { new TemporaryExposureKey { Id = Guid.NewGuid(), RollingStartNumber = rollingStartNumberNewerThan14Days, Origin = origin, KeyData = new byte[] { 1 } }, }; var keysOlderThan14Days = new List <TemporaryExposureKey> { new TemporaryExposureKey { Id = Guid.NewGuid(), RollingStartNumber = rollingStartNumberOlderThan14Days, Origin = origin, KeyData = new byte[] { 2 } }, new TemporaryExposureKey { Id = Guid.NewGuid(), RollingStartNumber = rollingStartNumberOlderThan14Days, Origin = origin, KeyData = new byte[] { 3 } }, }; var keyList = keysNewerThan14Days.Concat(keysOlderThan14Days).ToList(); dbContext.TemporaryExposureKey.AddRange(keyList); dbContext.SaveChanges(); var filteredList = _keyFilter.RemoveKeyDuplicatesAsync(keyList).Result; filteredList.Count.Should().Be(keysOlderThan14Days.Count); }
public static void RegisterRoutes(RouteCollection routes) { AppSettingsConfig appSettingsConfig = new AppSettingsConfig(); routes.MapUmbracoRoute("EpubBookCustomRoute", appSettingsConfig.BooksPathSegment + "/{booknameid}/" + appSettingsConfig.ReadPathSegment + "/{*readparameters}", // get paths sections for the app settings in web.config new { controller = "UmbEpubReader", action = "UmbEpubReader_Read", booknameid = "", readparameters = UrlParameter.Optional }, new BookContentFinderByNiceUrl()); // this UmbracoVirtualNodeRouteHandler allows '.' in the url so the plugin can route/serve files (embeded files in the epub) }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // (1) - Dependency Inyection DependencyInjectionConfig.Register(services); // (2) - AutoMapper Configuration AutoMapperConfig.Register(services); // (3) - Swagger Configuration SwaggerConfig.Register(services); // (4) - Setting Configuration AppSettingsConfig.Register(services, _env, Configuration); // (5) - services.AddControllers(); // (6) - Filters configurations FiltersConfig.Register(services); }
public void GetMessage(AppSettingsConfig appSettings, MessageDomainModel message, string expected) { using (var scope = new DefaultScope()) { // Arrange scope.AppSettingsMock.Setup(x => x.Value).Returns(appSettings); scope.MapperMock.Setup(x => x.Map <MessageDomainModel>(It.IsAny <AppSettingsConfig>())).Returns(message); // Act var result = scope.InstanceUnderTest.GetMessage(); // Assert Assert.Equal(expected, result.Message); } }
public DiagnosticKeyControllerV3( ILogger <DiagnosticKeyControllerV3> logger, IExposureConfigurationService exposureConfigurationService, IAddTemporaryExposureKeyService addTemporaryExposureKeyService, IZipFileInfoService zipFileInfoService, AppSettingsConfig appSettingsConfig, ICacheOperationsV3 cacheOperations, IExposureKeyReader exposureKeyReader) { _cacheOperations = cacheOperations; _logger = logger; _zipFileInfoService = zipFileInfoService; _appSettingsConfig = appSettingsConfig; _exposureConfigurationService = exposureConfigurationService; _addTemporaryExposureKeyService = addTemporaryExposureKeyService; _exposureKeyReader = exposureKeyReader; }
public DiagnosticKeyControllerV3( ILogger <DiagnosticKeyControllerV3> logger, IConfiguration configuration, IExposureKeyValidator exposureKeyValidator, IExposureConfigurationService exposureConfigurationService, KeyValidationConfiguration keyValidationConfig, IAddTemporaryExposureKeyService addTemporaryExposureKeyService, IZipFileInfoService zipFileInfoService, AppSettingsConfig appSettingsConfig) { _configuration = configuration; _exposureKeyValidator = exposureKeyValidator; _logger = logger; _zipFileInfoService = zipFileInfoService; _exposureConfigurationService = exposureConfigurationService; _keyValidationConfig = keyValidationConfig; _addTemporaryExposureKeyService = addTemporaryExposureKeyService; }
/// <summary> /// Ctor /// </summary> /// <param name="appSettingsConfig"></param> /// <param name="logger"></param> /// <param name="httpContextAccessor"></param> /// <param name="fileSystem"></param> /// <param name="pathHelper"></param> public LogFilesHealthCheck(AppSettingsConfig appSettingsConfig, ILogger <LogFilesHealthCheck> logger, IHttpContextAccessor httpContextAccessor, IFileSystem fileSystem, IPathHelper pathHelper) { _appSettingsConfig = appSettingsConfig; _logger = logger; _httpContextAccessor = httpContextAccessor; _fileSystem = fileSystem; _pathHelper = pathHelper; // Initialize Health Check AppSettings var apiRegex = _appSettingsConfig.HealthCheckSettings.ApiRegex; _apiRegex = new Regex(apiRegex); var jobsRegex = _appSettingsConfig.HealthCheckSettings.JobsRegex; _jobsRegex = new Regex(jobsRegex); var mobileRegex = _appSettingsConfig.HealthCheckSettings.MobileRegex; _mobileRegex = new Regex(mobileRegex); _logFilesDatePattern = _appSettingsConfig.HealthCheckSettings.LogFilesDatePattern; _mobileLogFilesDatePattern = _appSettingsConfig.HealthCheckSettings.MobileLogFilesDatePattern; }