public OAuthAuthenticationProvider( IOAuthTokenValidator oauthTokenValidator, IApiKeyContextProvider apiKeyContextProvider, IClaimsIdentityProvider claimsIdentityProvider, IConfigValueProvider configValueProvider) { OAuthTokenValidator = oauthTokenValidator; ApiKeyContextProvider = apiKeyContextProvider; ClaimsIdentityProvider = claimsIdentityProvider; _expectedUseSandboxValue = new Lazy <bool?>( () => configValueProvider.GetValue(ExpectedUseSandboxValue) == null ? (bool?)null : Convert.ToBoolean(configValueProvider.GetValue(ExpectedUseSandboxValue))); }
protected override void Arrange() { _configValueProvider = A.Fake <IConfigValueProvider>(); A.CallTo(() => _configValueProvider.GetValue(A <string> ._)).Returns("5"); _clientAppRepo = A.Fake <IClientAppRepo>(); _defaultApplicationCreator = A.Fake <IDefaultApplicationCreator>(); _sandboxProvisioner = A.Fake <ISandboxProvisioner>(); _clientCreator = new ClientCreator(_configValueProvider, _clientAppRepo, _defaultApplicationCreator, _sandboxProvisioner); _user = A.Fake <User>(); A.CallTo(() => _user.ApiClients).Returns( new List <ApiClient> { A.Fake <ApiClient>(), A.Fake <ApiClient>(), A.Fake <ApiClient>(), A.Fake <ApiClient>(), A.Fake <ApiClient>() }); }
private int GetMaximumSandboxesPerUserOrDefault() { string configValue = _configValueProvider.GetValue(MaximumSandboxesPerUserConfigKey); return(int.TryParse(configValue, out int configResult) ? configResult : MaximumSandboxesPerUserDefault); }
/// <summary> /// Look for an existing default application for this particular sandbox type. Also, make sure that all /// Local Education Agency associations are updated. /// </summary> /// <param name="vendorId"></param> /// <param name="sandboxType"></param> /// <returns></returns> public Application FindOrCreateUpdatedDefaultSandboxApplication(int vendorId, SandboxType sandboxType) { using (var context = _usersContextFactory.CreateContext()) { var vendor = context.Vendors .Where(x => x.VendorId == vendorId) .Include(x => x.Applications.Select(a => a.ApplicationEducationOrganizations)) .Single(); var defaultAppName = _configValueProvider.GetValue("DefaultApplicationName"); var applicationName = defaultAppName + " " + sandboxType; var application = GetApplication(context, vendor, applicationName); context.SaveChanges(); return(application); } }
/// <summary> /// Gets the specified value from the collection by name. /// </summary> /// <param name="name">The name of the value to be retrieved.</param> /// <returns>The value as a string.</returns> public string GetValue(string name) { if (Values[name] != null) { return(Values[name]); } return(_next?.GetValue(name)); }
protected override void Arrange() { _configValueProvider = A.Fake <IConfigValueProvider>(); _configConnectionStringsProvider = A.Fake <IConfigConnectionStringsProvider>(); _databaseEngineProvider = A.Fake <IDatabaseEngineProvider>(); A.CallTo(() => _configValueProvider.GetValue(ApiConfigurationConstants.ApiStartupType)) .Returns("unknown"); }
public CacheInterceptor(ICacheProvider[] cacheProviders, ICacheKeyGenerator cacheKeyGenerator, IConfigValueProvider configValueProvider, IServiceLocator serviceLocator, ISerializer serializer) { this.cacheProviders = cacheProviders; this.cacheKeyGenerator = cacheKeyGenerator; this.serviceLocator = serviceLocator; this.serializer = serializer; cacheExpiryMinutes = Convert.ToInt32(configValueProvider.GetValue("CacheInterceptor.SlidingExpiration")); //The first cache provider is the default. defaultCacheProvider = cacheProviders.First(); // Default to 5 minutes sliding expiration if (cacheExpiryMinutes == 0) cacheExpiryMinutes = 5; cacheEnabled = Convert.ToBoolean(configValueProvider.GetValue("CacheInterceptor.Enabled")); }
private void RegisterPersonUniqueIdToUsiCache(IWindsorContainer container) { container.Register(Component.For <IPersonUniqueIdToUsiCache>() .ImplementedBy <PersonUniqueIdToUsiCache>() .DependsOn(Dependency.OnValue("slidingExpiration", TimeSpan.FromSeconds(Convert.ToInt32(_configValueProvider.GetValue(PersonCacheSlidingExpirationSecondsKey) ?? "14400")))) .DependsOn(Dependency.OnValue("absoluteExpirationPeriod", TimeSpan.FromSeconds(Convert.ToInt32(_configValueProvider.GetValue(PersonCacheAbsoluteExpirationSecondsKey) ?? "86400")))) .DependsOn(Dependency.OnValue("synchronousInitialization", false))); }
public OpenApiMetadataController(IOpenApiMetadataCacheProvider openApiMetadataCacheProvider, IConfigValueProvider configValueProvider) { _openApiMetadataCacheProvider = openApiMetadataCacheProvider; bool tempConfigValue; _useProxyHeaders = bool.TryParse( configValueProvider.GetValue(UseReverseProxyHeadersConfigKey), out tempConfigValue) && tempConfigValue; }
private void RegisterComponentsUsingLegacyMechanism(IWindsorContainer container) { if (!int.TryParse(_configValueProvider.GetValue(CacheTimeoutKey), out int cacheTimeoutInMinutes)) { cacheTimeoutInMinutes = 0; } if (cacheTimeoutInMinutes <= 0) { // Default to no caching container.Register( Component.For <ISecurityRepository>() .ImplementedBy <SecurityRepository>()); } else { container.Register( Component.For <ISecurityRepository>() .ImplementedBy <CachedSecurityRepository>() .DependsOn(Dependency.OnValue("cacheTimeoutInMinutes", cacheTimeoutInMinutes))); } container.Register( Component.For <IClientAppRepo>() .ImplementedBy <ClientAppRepo>(), Component.For <IAccessTokenClientRepo>() .ImplementedBy <AccessTokenClientRepo>(), Component.For <IUsersContextFactory>() .ImplementedBy <UsersContextFactory>(), Component.For <ISecurityContextFactory>() .ImplementedBy <SecurityContextFactory>(), Component .For <IResourceClaimUriProvider>() .ImplementedBy <ResourceClaimUriProvider>(), // Register authorization context pipeline steps Component.For(typeof(SetAuthorizationContextForGet <, , ,>)) .ImplementedBy(typeof(SetAuthorizationContextForGet <, , ,>)), Component.For(typeof(SetAuthorizationContextForPut <, , ,>)) .ImplementedBy(typeof(SetAuthorizationContextForPut <, , ,>)), Component.For(typeof(SetAuthorizationContextForDelete <, , ,>)) .ImplementedBy(typeof(SetAuthorizationContextForDelete <, , ,>)), Component.For(typeof(SetAuthorizationContextForPost <, , ,>)) .ImplementedBy(typeof(SetAuthorizationContextForPost <, , ,>)), // ----------------------------------------------- // Register authorization subsystem components // ----------------------------------------------- Component .For <IEdFiAuthorizationProvider>() .ImplementedBy <EdFiAuthorizationProvider>(), Component .For <IResourceAuthorizationMetadataProvider>() .ImplementedBy <ResourceAuthorizationMetadataProvider>()); }
protected SandboxProvisionerBase(IConfigValueProvider configValueProvider, IConfigConnectionStringsProvider connectionStringsProvider, IDatabaseNameBuilder databaseNameBuilder) { _configValueProvider = configValueProvider; _connectionStringsProvider = connectionStringsProvider; _databaseNameBuilder = databaseNameBuilder; CommandTimeout = int.TryParse(_configValueProvider.GetValue("SandboxAdminSQLCommandTimeout"), out int timeout) ? timeout : 30; ConnectionString = _connectionStringsProvider.GetConnectionString("EdFi_master"); }
/// <summary> /// Initializes a new instance of the <see cref="CachingOAuthTokenValidatorDecorator"/> class. /// </summary> /// <param name="next">The decorated implementation.</param> /// <param name="cacheProvider">The cache provider.</param> /// <param name="configValueProvider">The configuration value provider.</param> public CachingOAuthTokenValidatorDecorator( IOAuthTokenValidator next, ICacheProvider cacheProvider, IConfigValueProvider configValueProvider) { _next = next; _cacheProvider = cacheProvider; // Lazy initialization _bearerTokenTimeoutMinutes = new Lazy <int>( () => Convert.ToInt32(configValueProvider.GetValue(ConfigBearerTokenTimeoutMinutes) ?? "30")); }
protected override void Arrange() { _configValueProvider = A.Fake <IConfigValueProvider>(); _configConnectionStringsProvider = A.Fake <IConfigConnectionStringsProvider>(); _databaseEngineProvider = A.Fake <IDatabaseEngineProvider>(); A.CallTo(() => _configValueProvider.GetValue(ApiConfigurationConstants.ApiStartupType)) .Returns(ApiConfigurationConstants.YearSpecific); A.CallTo(() => _configConnectionStringsProvider.ConnectionStringProviderByName) .Returns(new Dictionary <string, string> { { "db", ApiConfigurationConstants.SqlServerProviderName } }); _systemUnderTest = new ApiConfigurationProvider(_configValueProvider, _databaseEngineProvider); }
public void Should_attempt_to_get_config_value() { A.CallTo(() => _configValueProvider.GetValue(A <string> ._)).MustHaveHappened(); }