public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides() { // no need to test for attributes, it's tested for parent class configurationObject.Type = typeof(Object); configurationObject.Formatter = "formatter"; configurationObject.InitData = "init data"; configurationObject.TraceOutputOptions = TraceOptions.Callstack; configurationObject.Filter = SourceLevels.Error; machineKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.ProviderTypePropertyName, typeof(Object).AssemblyQualifiedName); machineKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.AttributesPropertyName, ""); machineKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter"); machineKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.InitDataPropertyName, "overriden init data"); machineKey.AddStringValue(CustomTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical"); machineKey.AddSubKey(MsmqTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey); machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null); Assert.AreEqual("overriden formatter", configurationObject.Formatter); Assert.AreEqual("overriden init data", configurationObject.InitData); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter); }
public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides() { configurationObject.AddCategoryStoredProcName = "add category"; configurationObject.DatabaseInstanceName = "database"; configurationObject.Formatter = "formatter"; configurationObject.WriteLogStoredProcName = "write"; configurationObject.TraceOutputOptions = TraceOptions.None; configurationObject.Filter = SourceLevels.Error; machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.AddCategoryStoredProcNamePropertyName, "overriden add category"); machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.DatabaseInstanceNamePropertyName, "overriden database"); machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter"); machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.WriteLogStoredProcNamePropertyName, "overriden write"); machineKey.AddStringValue(FormattedDatabaseTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical"); machineKey.AddSubKey(FormattedDatabaseTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey); machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null); Assert.AreEqual("overriden add category", configurationObject.AddCategoryStoredProcName); Assert.AreEqual("overriden database", configurationObject.DatabaseInstanceName); Assert.AreEqual("overriden formatter", configurationObject.Formatter); Assert.AreEqual("overriden write", configurationObject.WriteLogStoredProcName); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); }
public void CacheManagerIsOverridenIfThereAreUserPolicyOverrides() { CacheManagerData data1 = new CacheManagerData(); data1.Name = "cache manager 1"; data1.CacheStorage = "cache storage"; data1.ExpirationPollFrequencyInSeconds = 100; data1.MaximumElementsInCacheBeforeScavenging = 200; data1.NumberToRemoveWhenScavenging = 300; section.CacheManagers.Add(data1); MockRegistryKey userCacheManagersKey = new MockRegistryKey(false); userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, userCacheManagersKey); MockRegistryKey userCacheManager1Key = new MockRegistryKey(false); userCacheManagersKey.AddSubKey(data1.Name, userCacheManager1Key); userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 160); userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 260); userCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 360); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual("cache storage", data1.CacheStorage); Assert.AreEqual(160, data1.ExpirationPollFrequencyInSeconds); Assert.AreEqual(260, data1.MaximumElementsInCacheBeforeScavenging); Assert.AreEqual(360, data1.NumberToRemoveWhenScavenging); Assert.IsTrue( MockRegistryKey.CheckAllClosed(userCacheManagersKey, userCacheManager1Key)); }
public void ConfigurationObjectIsNotModifiedIfThereArePolicyOverridesForDifferentName() { OracleConnectionData connectionData = new OracleConnectionData(); connectionData.Name = "data1"; connectionData.Packages.Add(new OraclePackageData("package11", "prefix11")); connectionData.Packages.Add(new OraclePackageData("package12", "prefix12")); section.OracleConnectionsData.Add(connectionData); MockRegistryKey machinePackageKey = new MockRegistryKey(false); machineKey.AddSubKey("data2", machinePackageKey); machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName, "package23=prefix23; package24=prefix24; package25=prefix25"); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.AreEqual(2, connectionData.Packages.Count); Assert.IsNotNull(connectionData.Packages.Get("package11")); Assert.AreEqual("prefix11", connectionData.Packages.Get("package11").Prefix); Assert.IsNotNull(connectionData.Packages.Get("package12")); Assert.AreEqual("prefix12", connectionData.Packages.Get("package12").Prefix); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackageKey)); }
public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides() { configurationObject.Formatter = "formatter"; configurationObject.Log = "log"; configurationObject.MachineName = "machine name"; configurationObject.Source = "source"; configurationObject.TraceOutputOptions = TraceOptions.None; configurationObject.Filter = SourceLevels.Error; machineKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter"); machineKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.LogPropertyName, "overriden log"); machineKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.MachineNamePropertyName, "overriden machine name"); machineKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.SourcePropertyName, "overriden source"); machineKey.AddStringValue(FormattedEventLogTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical"); machineKey.AddSubKey(FormattedEventLogTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey); machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null); Assert.AreEqual("overriden formatter", configurationObject.Formatter); Assert.AreEqual("overriden log", configurationObject.Log); Assert.AreEqual("overriden machine name", configurationObject.MachineName); Assert.AreEqual("overriden source", configurationObject.Source); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter); }
public void ProviderMappingWithDisabledPolicyIsRemoved() { DbProviderMapping providerMapping1 = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping1); DbProviderMapping providerMapping2 = new DbProviderMapping("provider2", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping2); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); MockRegistryKey providerMapping1MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMapping1MachineKey); providerMapping1MachineKey.AddBooleanValue(DatabaseSettingsManageabilityProvider.PolicyValueName, false); MockRegistryKey providerMapping2MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider2", providerMapping2MachineKey); providerMapping2MachineKey.AddBooleanValue(DatabaseSettingsManageabilityProvider.PolicyValueName, true); providerMapping2MachineKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(GenericDatabase).AssemblyQualifiedName); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.AreEqual(1, section.ProviderMappings.Count); Assert.IsNotNull(section.ProviderMappings.Get("provider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMapping1MachineKey, providerMapping2MachineKey, providerMappingsMachineKey)); }
public void ProviderMappingWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { DbProviderMapping providerMapping1 = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping1); DbProviderMapping providerMapping2 = new DbProviderMapping("provider2", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping2); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); MockRegistryKey providerMapping1MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMapping1MachineKey); providerMapping1MachineKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); MockRegistryKey providerMapping2MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider2", providerMapping2MachineKey); providerMapping2MachineKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, true); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings); Assert.AreEqual(2, section.ProviderMappings.Count); Assert.IsNotNull(section.ProviderMappings.Get("provider1")); Assert.IsNotNull(section.ProviderMappings.Get("provider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMapping1MachineKey, providerMapping2MachineKey, providerMappingsMachineKey)); }
public void CanApplyMachinePolicyOverridesToExistingPolicyType() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); MockRegistryKey machinePoliciesKey = new MockRegistryKey(false); machineKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, machinePoliciesKey); MockRegistryKey machinePolicy1Key = new MockRegistryKey(false); machinePoliciesKey.AddSubKey("policy1", machinePolicy1Key); MockRegistryKey machinePolicy1TypesKey = new MockRegistryKey(false); machinePolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, machinePolicy1TypesKey); MockRegistryKey machinePolicy1Type1Key = new MockRegistryKey(false); machinePolicy1TypesKey.AddSubKey("type1", machinePolicy1Type1Key); machinePolicy1Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.NotifyRethrow.ToString()); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, null, false, wmiSettings); Assert.AreEqual(PostHandlingAction.NotifyRethrow, exceptionType1.PostHandlingAction); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinePoliciesKey, machinePolicy1Key, machinePolicy1TypesKey, machinePolicy1Type1Key)); }
public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides() { configurationObject.TraceOutputOptions = TraceOptions.None; configurationObject.Filter = SourceLevels.Error; machineKey.AddStringValue(WmiTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical"); machineKey.AddSubKey(WmiTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey); machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter); }
public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides() { configurationObject.FileName = "file name"; configurationObject.Footer = "footer"; configurationObject.Formatter = "formatter"; configurationObject.Header = "header"; configurationObject.TraceOutputOptions = TraceOptions.None; configurationObject.Filter = SourceLevels.Error; userKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FileNamePropertyName, "overriden file name"); userKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FooterPropertyName, "overriden footer"); userKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter"); userKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.HeaderPropertyName, "overriden header"); userKey.AddStringValue(FlatFileTraceListenerDataManageabilityProvider.FilterPropertyName, "Critical"); userKey.AddSubKey(FlatFileTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, userOptionsKey); userOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); userOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, null, userKey); Assert.AreEqual("overriden file name", configurationObject.FileName); Assert.AreEqual("overriden footer", configurationObject.Footer); Assert.AreEqual("overriden formatter", configurationObject.Formatter); Assert.AreEqual("overriden header", configurationObject.Header); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter); }
public void CacheManagerWithDisabledPolicyIsRemoved() { CacheManagerData data1 = new CacheManagerData(); data1.Name = "cache manager 1"; section.CacheManagers.Add(data1); CacheManagerData data2 = new CacheManagerData(); data2.Name = "cache manager 2"; section.CacheManagers.Add(data2); MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey); MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false); machineCacheManagersKey.AddSubKey("cache manager 1", machineCacheManager1Key); machineCacheManager1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.AreEqual(1, section.CacheManagers.Count); Assert.IsNotNull(section.CacheManagers.Get("cache manager 2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key)); }
public void CacheManagerIsNotOverridenIfThereArePolicyOverridesForDifferentName() { CacheManagerData data1 = new CacheManagerData(); data1.Name = "cache manager 1"; data1.CacheStorage = "cache storage"; data1.ExpirationPollFrequencyInSeconds = 100; data1.MaximumElementsInCacheBeforeScavenging = 200; data1.NumberToRemoveWhenScavenging = 300; section.CacheManagers.Add(data1); MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey); MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false); machineCacheManagersKey.AddSubKey("cache manager 2", machineCacheManager1Key); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 150); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 250); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 350); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.AreEqual("cache storage", data1.CacheStorage); Assert.AreEqual(100, data1.ExpirationPollFrequencyInSeconds); Assert.AreEqual(200, data1.MaximumElementsInCacheBeforeScavenging); Assert.AreEqual(300, data1.NumberToRemoveWhenScavenging); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key)); }
public void UserOverridesForMissingPolicyCausesNoProblems() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); MockRegistryKey userPoliciesKey = new MockRegistryKey(false); userKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, userPoliciesKey); MockRegistryKey userPolicy1Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy2", userPolicy1Key); MockRegistryKey userPolicy1TypesKey = new MockRegistryKey(false); userPolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy1TypesKey); MockRegistryKey userPolicy1Type1Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type1", userPolicy1Type1Key); userPolicy1Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.NotifyRethrow.ToString()); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, null, userKey, false, wmiSettings); Assert.AreEqual(PostHandlingAction.None, exceptionType1.PostHandlingAction); Assert.IsTrue( MockRegistryKey.CheckAllClosed(userPoliciesKey, userPolicy1Key, userPolicy1TypesKey, userPolicy1Type1Key)); }
public void CanApplyMachinePolicyOverridesToExistingPolicyType() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); MockRegistryKey machinePoliciesKey = new MockRegistryKey(false); machineKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, machinePoliciesKey); MockRegistryKey machinePolicy1Key = new MockRegistryKey(false); machinePoliciesKey.AddSubKey("policy1", machinePolicy1Key); MockRegistryKey machinePolicy1TypesKey = new MockRegistryKey(false); machinePolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, machinePolicy1TypesKey); MockRegistryKey machinePolicy1Type1Key = new MockRegistryKey(false); machinePolicy1TypesKey.AddSubKey("type1", machinePolicy1Type1Key); machinePolicy1Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.NotifyRethrow.ToString()); provider.OverrideWithGroupPolicies(section, true, machineKey, null); Assert.AreEqual(PostHandlingAction.NotifyRethrow, exceptionType1.PostHandlingAction); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinePoliciesKey, machinePolicy1Key, machinePolicy1TypesKey, machinePolicy1Type1Key)); }
public void UnknownCacheManagerWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { MockCacheManagerData data1 = new MockCacheManagerData(); data1.Name = "cache manager 1"; data1.Type = typeof(object); section.CacheManagers.Add(data1); MockCacheManagerData data2 = new MockCacheManagerData(); data2.Name = "cache manager 2"; data2.Type = typeof(object); section.CacheManagers.Add(data2); MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey); MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false); machineCacheManagersKey.AddSubKey("cache manager 1", machineCacheManager1Key); machineCacheManager1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.CacheManagers.Count); Assert.IsNotNull(section.CacheManagers.Get("cache manager 1")); Assert.IsNotNull(section.CacheManagers.Get("cache manager 2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key)); }
public void AuthorizationProviderWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(AuthorizationProviderData), registeredProvider); provider = new ConfigurationSectionManageabilityProviderWrapper( new SecuritySettingsManageabilityProvider(subProviders)); AuthorizationProviderData authorizationProvider1Data = new AuthorizationProviderData("authorizationProvider1", typeof(Object)); section.AuthorizationProviders.Add(authorizationProvider1Data); AuthorizationProviderData authorizationProvider2Data = new AuthorizationProviderData("authorizationProvider2", typeof(Object)); section.AuthorizationProviders.Add(authorizationProvider2Data); MockRegistryKey machineAuthorizationProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.AuthorizationProvidersKeyName, machineAuthorizationProvidersKey); MockRegistryKey machineAuthorizationProvider2Key = new MockRegistryKey(false); machineAuthorizationProvidersKey.AddSubKey("authorizationProvider2", machineAuthorizationProvider2Key); machineAuthorizationProvider2Key.AddBooleanValue(SecuritySettingsManageabilityProvider.PolicyValueName, false); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings); Assert.AreEqual(2, section.AuthorizationProviders.Count); Assert.IsNotNull(section.AuthorizationProviders.Get("authorizationProvider1")); Assert.IsNotNull(section.AuthorizationProviders.Get("authorizationProvider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineAuthorizationProvidersKey, machineAuthorizationProvider2Key)); }
public void SymmetricCryptoProviderWithDisabledPolicyIsRemoved() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SymmetricAlgorithmProviderData), registeredProvider); provider = new ConfigurationSectionManageabilityProviderWrapper( new CryptographySettingsManageabilityProvider(subProviders)); SymmetricAlgorithmProviderData symmetricCryptoProvider1Data = new SymmetricAlgorithmProviderData("symmetricCryptoProvider1", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProvider1Data); SymmetricAlgorithmProviderData symmetricCryptoProvider2Data = new SymmetricAlgorithmProviderData("symmetricCryptoProvider2", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProvider2Data); MockRegistryKey machineSymmetricCryptoProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, machineSymmetricCryptoProvidersKey); MockRegistryKey machineSymmetricCryptoProvider2Key = new MockRegistryKey(false); machineSymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", machineSymmetricCryptoProvider2Key); machineSymmetricCryptoProvider2Key.AddBooleanValue(CryptographySettingsManageabilityProvider.PolicyValueName, false); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.AreEqual(1, section.SymmetricCryptoProviders.Count); Assert.IsNotNull(section.SymmetricCryptoProviders.Get("symmetricCryptoProvider1")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineSymmetricCryptoProvidersKey, machineSymmetricCryptoProvider2Key)); }
public void SecurityCacheProviderWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SecurityCacheProviderData), registeredProvider); provider = new SecuritySettingsManageabilityProvider(subProviders); SecurityCacheProviderData securityCacheProvider1Data = new SecurityCacheProviderData("securityCacheProvider1", typeof(Object)); section.SecurityCacheProviders.Add(securityCacheProvider1Data); SecurityCacheProviderData securityCacheProvider2Data = new SecurityCacheProviderData("securityCacheProvider2", typeof(Object)); section.SecurityCacheProviders.Add(securityCacheProvider2Data); MockRegistryKey machineSecurityCacheProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, machineSecurityCacheProvidersKey); MockRegistryKey machineSecurityCacheProvider2Key = new MockRegistryKey(false); machineSecurityCacheProvidersKey.AddSubKey("securityCacheProvider2", machineSecurityCacheProvider2Key); machineSecurityCacheProvider2Key.AddBooleanValue(SecuritySettingsManageabilityProvider.PolicyValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.SecurityCacheProviders.Count); Assert.IsNotNull(section.SecurityCacheProviders.Get("securityCacheProvider1")); Assert.IsNotNull(section.SecurityCacheProviders.Get("securityCacheProvider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineSecurityCacheProvidersKey, machineSecurityCacheProvider2Key)); }
public void MachineOverrideTakesPrecedenceOverUserOverride() { DbProviderMapping providerMapping = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping); MockRegistryKey providerMappingUserKey = new MockRegistryKey(false); providerMappingUserKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(GenericDatabase).AssemblyQualifiedName); MockRegistryKey providerMappingsUserKey = new MockRegistryKey(false); providerMappingsUserKey.AddSubKey("provider1", providerMappingUserKey); userKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsUserKey); MockRegistryKey providerMappingMachineKey = new MockRegistryKey(false); providerMappingMachineKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(OracleDatabase).AssemblyQualifiedName); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMappingMachineKey); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, false, wmiSettings); Assert.AreSame(typeof(OracleDatabase), providerMapping.DatabaseType); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMappingUserKey, providerMappingsUserKey, providerMappingMachineKey, providerMappingsMachineKey)); }
public void HashProviderWithDisabledPolicyIsRemoved() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(HashAlgorithmProviderData), registeredProvider); provider = new CryptographySettingsManageabilityProvider(subProviders); HashAlgorithmProviderData hashProvider1Data = new HashAlgorithmProviderData("hashProvider1", typeof(Object), false); section.HashProviders.Add(hashProvider1Data); HashAlgorithmProviderData hashProvider2Data = new HashAlgorithmProviderData("hashProvider2", typeof(Object), false); section.HashProviders.Add(hashProvider2Data); MockRegistryKey machineHashProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.HashProvidersKeyName, machineHashProvidersKey); MockRegistryKey machineHashProvider2Key = new MockRegistryKey(false); machineHashProvidersKey.AddSubKey("hashProvider2", machineHashProvider2Key); machineHashProvider2Key.AddBooleanValue(CryptographySettingsManageabilityProvider.PolicyValueName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(1, section.HashProviders.Count); Assert.IsNotNull(section.HashProviders.Get("hashProvider1")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineHashProvidersKey, machineHashProvider2Key)); }
public void RegisteredCacheStorageDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(CacheStorageData), registeredProvider); provider = new ConfigurationSectionManageabilityProviderWrapper( new CacheManagerSettingsManageabilityProvider(subProviders)); CacheStorageData data = new CacheStorageData("store1", typeof(NullBackingStore)); section.BackingStores.Add(data); MockRegistryKey machineStoresKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, machineStoresKey); MockRegistryKey machineStoreKey = new MockRegistryKey(false); machineStoresKey.AddSubKey("store1", machineStoreKey); MockRegistryKey machineOtherStoreKey = new MockRegistryKey(false); machineStoresKey.AddSubKey("store2", machineOtherStoreKey); MockRegistryKey userStoresKey = new MockRegistryKey(false); userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.BackingStoresKeyName, userStoresKey); MockRegistryKey userStoreKey = new MockRegistryKey(false); userStoresKey.AddSubKey("store1", userStoreKey); MockRegistryKey userOtherStoreKey = new MockRegistryKey(false); userStoresKey.AddSubKey("store2", userOtherStoreKey); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.IsTrue(registeredProvider.called); Assert.AreSame(data, registeredProvider.LastConfigurationObject); Assert.AreEqual(machineStoreKey, registeredProvider.machineKey); Assert.AreEqual(userStoreKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineStoresKey, machineStoreKey, machineOtherStoreKey, userStoresKey, userStoreKey, userOtherStoreKey)); }
public void RegisteredSymmetricCryptoProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SymmetricAlgorithmProviderData), registeredProvider); provider = new ConfigurationSectionManageabilityProviderWrapper( new CryptographySettingsManageabilityProvider(subProviders)); SymmetricAlgorithmProviderData symmetricCryptoProviderData = new SymmetricAlgorithmProviderData("symmetricCryptoProvider1", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProviderData); MockRegistryKey machinesymmetricCryptoProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, machinesymmetricCryptoProvidersKey); MockRegistryKey machinesymmetricCryptoProviderKey = new MockRegistryKey(false); machinesymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider1", machinesymmetricCryptoProviderKey); MockRegistryKey machineOthersymmetricCryptoProviderKey = new MockRegistryKey(false); machinesymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", machineOthersymmetricCryptoProviderKey); MockRegistryKey usersymmetricCryptoProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, usersymmetricCryptoProvidersKey); MockRegistryKey usersymmetricCryptoProviderKey = new MockRegistryKey(false); usersymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider1", usersymmetricCryptoProviderKey); MockRegistryKey userOthersymmetricCryptoProviderKey = new MockRegistryKey(false); usersymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", userOthersymmetricCryptoProviderKey); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.IsTrue(registeredProvider.called); Assert.AreSame(symmetricCryptoProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machinesymmetricCryptoProviderKey, registeredProvider.machineKey); Assert.AreSame(usersymmetricCryptoProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinesymmetricCryptoProvidersKey, machinesymmetricCryptoProviderKey, machineOthersymmetricCryptoProviderKey, usersymmetricCryptoProvidersKey, usersymmetricCryptoProviderKey, userOthersymmetricCryptoProviderKey)); }
public void RegisteredSecurityCacheProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(CustomSecurityCacheProviderData), registeredProvider); provider = new ConfigurationSectionManageabilityProviderWrapper( new SecuritySettingsManageabilityProvider(subProviders)); CustomSecurityCacheProviderData securitycacheProviderData = new CustomSecurityCacheProviderData("securitycacheProvider1", typeof(Object)); section.SecurityCacheProviders.Add(securitycacheProviderData); MockRegistryKey machinesecuritycacheProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, machinesecuritycacheProvidersKey); MockRegistryKey machinesecuritycacheProviderKey = new MockRegistryKey(false); machinesecuritycacheProvidersKey.AddSubKey("securitycacheProvider1", machinesecuritycacheProviderKey); MockRegistryKey machineOthersecuritycacheProviderKey = new MockRegistryKey(false); machinesecuritycacheProvidersKey.AddSubKey("securitycacheProvider2", machineOthersecuritycacheProviderKey); MockRegistryKey usersecuritycacheProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, usersecuritycacheProvidersKey); MockRegistryKey usersecuritycacheProviderKey = new MockRegistryKey(false); usersecuritycacheProvidersKey.AddSubKey("securitycacheProvider1", usersecuritycacheProviderKey); MockRegistryKey userOthersecuritycacheProviderKey = new MockRegistryKey(false); usersecuritycacheProvidersKey.AddSubKey("securitycacheProvider2", userOthersecuritycacheProviderKey); provider.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings); Assert.IsTrue(registeredProvider.called); Assert.AreSame(securitycacheProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machinesecuritycacheProviderKey, registeredProvider.machineKey); Assert.AreSame(usersecuritycacheProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinesecuritycacheProvidersKey, machinesecuritycacheProviderKey, machineOthersecuritycacheProviderKey, usersecuritycacheProvidersKey, usersecuritycacheProviderKey, userOthersecuritycacheProviderKey)); }
public void CanApplyUserPolicyOverridesToExistingPolicyTyqpeWhenMultiplePolicyOverridesExist() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); MockRegistryKey userPoliciesKey = new MockRegistryKey(false); userKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, userPoliciesKey); MockRegistryKey userPolicy0Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy0", userPolicy0Key); MockRegistryKey userPolicy0TypesKey = new MockRegistryKey(false); userPolicy0Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy0TypesKey); MockRegistryKey userPolicy0Type1Key = new MockRegistryKey(false); userPolicy0TypesKey.AddSubKey("type1", userPolicy0Type1Key); userPolicy0Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.ThrowNewException.ToString()); MockRegistryKey userPolicy1Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy1", userPolicy1Key); MockRegistryKey userPolicy1TypesKey = new MockRegistryKey(false); userPolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy1TypesKey); MockRegistryKey userPolicy1Type1Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type1", userPolicy1Type1Key); userPolicy1Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.NotifyRethrow.ToString()); provider.OverrideWithGroupPolicies(section, true, null, userKey); Assert.AreEqual(PostHandlingAction.NotifyRethrow, exceptionType1.PostHandlingAction); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userPoliciesKey, userPolicy0Key, userPolicy0TypesKey, userPolicy0Type1Key, userPolicy1Key, userPolicy1TypesKey, userPolicy1Type1Key)); }
public void RegisteredEncryptionProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(StorageEncryptionProviderData), registeredProvider); provider = new CacheManagerSettingsManageabilityProvider(subProviders); StorageEncryptionProviderData data = new StorageEncryptionProviderData("encryptionprovider1", typeof(Object)); section.EncryptionProviders.Add(data); MockRegistryKey machineEncryptionProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.EncryptionProvidersKeyName, machineEncryptionProvidersKey); MockRegistryKey machineEncryptionProviderKey = new MockRegistryKey(false); machineEncryptionProvidersKey.AddSubKey("encryptionprovider1", machineEncryptionProviderKey); MockRegistryKey machineOtherEncryptionProviderKey = new MockRegistryKey(false); machineEncryptionProvidersKey.AddSubKey("encryptionprovider2", machineOtherEncryptionProviderKey); MockRegistryKey userEncryptionProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.EncryptionProvidersKeyName, userEncryptionProvidersKey); MockRegistryKey userEncryptionProviderKey = new MockRegistryKey(false); userEncryptionProvidersKey.AddSubKey("encryptionprovider1", userEncryptionProviderKey); MockRegistryKey userOtherEncryptionProviderKey = new MockRegistryKey(false); userEncryptionProvidersKey.AddSubKey("encryptionprovider2", userOtherEncryptionProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(data, registeredProvider.LastConfigurationObject); Assert.AreEqual(machineEncryptionProviderKey, registeredProvider.machineKey); Assert.AreEqual(userEncryptionProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineEncryptionProvidersKey, machineEncryptionProviderKey, machineOtherEncryptionProviderKey, userEncryptionProvidersKey, userEncryptionProviderKey, userOtherEncryptionProviderKey)); }
public void RegisteredAuthorizationProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(AuthorizationRuleProviderData), registeredProvider); provider = new SecuritySettingsManageabilityProvider(subProviders); AuthorizationRuleProviderData authorizationProviderData = new AuthorizationRuleProviderData("authorizationProvider1"); section.AuthorizationProviders.Add(authorizationProviderData); MockRegistryKey machineauthorizationProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.AuthorizationProvidersKeyName, machineauthorizationProvidersKey); MockRegistryKey machineauthorizationProviderKey = new MockRegistryKey(false); machineauthorizationProvidersKey.AddSubKey("authorizationProvider1", machineauthorizationProviderKey); MockRegistryKey machineOtherauthorizationProviderKey = new MockRegistryKey(false); machineauthorizationProvidersKey.AddSubKey("authorizationProvider2", machineOtherauthorizationProviderKey); MockRegistryKey userauthorizationProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(SecuritySettingsManageabilityProvider.AuthorizationProvidersKeyName, userauthorizationProvidersKey); MockRegistryKey userauthorizationProviderKey = new MockRegistryKey(false); userauthorizationProvidersKey.AddSubKey("authorizationProvider1", userauthorizationProviderKey); MockRegistryKey userOtherauthorizationProviderKey = new MockRegistryKey(false); userauthorizationProvidersKey.AddSubKey("authorizationProvider2", userOtherauthorizationProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(authorizationProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machineauthorizationProviderKey, registeredProvider.machineKey); Assert.AreSame(userauthorizationProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineauthorizationProvidersKey, machineauthorizationProviderKey, machineOtherauthorizationProviderKey, userauthorizationProvidersKey, userauthorizationProviderKey, userOtherauthorizationProviderKey)); }
public void RegisteredHashProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary <Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary <Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(HashAlgorithmProviderData), registeredProvider); provider = new CryptographySettingsManageabilityProvider(subProviders); HashAlgorithmProviderData hashProviderData = new HashAlgorithmProviderData("hashProvider1", typeof(Object), false); section.HashProviders.Add(hashProviderData); MockRegistryKey machineHashProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.HashProvidersKeyName, machineHashProvidersKey); MockRegistryKey machineHashProviderKey = new MockRegistryKey(false); machineHashProvidersKey.AddSubKey("hashProvider1", machineHashProviderKey); MockRegistryKey machineOtherhashProviderKey = new MockRegistryKey(false); machineHashProvidersKey.AddSubKey("hashProvider2", machineOtherhashProviderKey); MockRegistryKey userhashProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(CryptographySettingsManageabilityProvider.HashProvidersKeyName, userhashProvidersKey); MockRegistryKey userhashProviderKey = new MockRegistryKey(false); userhashProvidersKey.AddSubKey("hashProvider1", userhashProviderKey); MockRegistryKey userOtherhashProviderKey = new MockRegistryKey(false); userhashProvidersKey.AddSubKey("hashProvider2", userOtherhashProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(hashProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machineHashProviderKey, registeredProvider.machineKey); Assert.AreSame(userhashProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineHashProvidersKey, machineHashProviderKey, machineOtherhashProviderKey, userhashProvidersKey, userhashProviderKey, userOtherhashProviderKey)); }
public void ConnectionStringWithUserPolicyOverrideIsModified() { ConnectionStringSettings connectionString = new ConnectionStringSettings("cs1", "connectionString", "providerName"); section.ConnectionStrings.Add(connectionString); MockRegistryKey overrideKey = new MockRegistryKey(false); overrideKey.AddStringValue(ConnectionStringsManageabilityProvider.ConnectionStringPropertyName, "overridenConnectionString"); overrideKey.AddStringValue(ConnectionStringsManageabilityProvider.ProviderNamePropertyName, "overridenProviderName"); userKey.AddSubKey("cs1", overrideKey); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, false, wmiSettings); Assert.AreEqual("overridenConnectionString", connectionString.ConnectionString); Assert.AreEqual("overridenProviderName", connectionString.ProviderName); Assert.IsTrue(MockRegistryKey.CheckAllClosed(overrideKey)); }
public void ConfigurationObjectIsModifiedIfThereAreMachinePolicyOverrides() { configurationObject.FileName = "file name"; configurationObject.Formatter = "formatter"; configurationObject.RollFileExistsBehavior = RollFileExistsBehavior.Increment; configurationObject.RollInterval = RollInterval.Month; configurationObject.RollSizeKB = 100; configurationObject.TimeStampPattern = "pattern"; configurationObject.TraceOutputOptions = TraceOptions.None; configurationObject.Filter = SourceLevels.Error; configurationObject.Header = "header"; configurationObject.Footer = "footer"; configurationObject.MaxArchivedFiles = 10; machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FileNamePropertyName, "overriden file name"); machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FormatterPropertyName, "overriden formatter"); machineKey.AddEnumValue <RollFileExistsBehavior>(RollingFlatFileTraceListenerDataManageabilityProvider.RollFileExistsBehaviorPropertyName, RollFileExistsBehavior.Overwrite); machineKey.AddEnumValue <RollInterval>(RollingFlatFileTraceListenerDataManageabilityProvider.RollIntervalPropertyName, RollInterval.Day); machineKey.AddIntValue(RollingFlatFileTraceListenerDataManageabilityProvider.RollSizeKBPropertyName, 200); machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.TimeStampPatternPropertyName, "overriden pattern"); machineKey.AddEnumValue <SourceLevels>(RollingFlatFileTraceListenerDataManageabilityProvider.FilterPropertyName, SourceLevels.Critical); machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.HeaderPropertyName, "overriden header"); machineKey.AddStringValue(RollingFlatFileTraceListenerDataManageabilityProvider.FooterPropertyName, "overriden footer"); machineKey.AddIntValue(RollingFlatFileTraceListenerDataManageabilityProvider.MaxArchivedFilesPropertyName, 20); machineKey.AddSubKey(RollingFlatFileTraceListenerDataManageabilityProvider.TraceOutputOptionsPropertyName, machineOptionsKey); machineOptionsKey.AddIntValue(TraceOptions.ProcessId.ToString(), 1); machineOptionsKey.AddIntValue(TraceOptions.ThreadId.ToString(), 1); provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, null); Assert.AreEqual("overriden file name", configurationObject.FileName); Assert.AreEqual("overriden formatter", configurationObject.Formatter); Assert.AreEqual(RollFileExistsBehavior.Overwrite, configurationObject.RollFileExistsBehavior); Assert.AreEqual(RollInterval.Day, configurationObject.RollInterval); Assert.AreEqual(200, configurationObject.RollSizeKB); Assert.AreEqual("overriden pattern", configurationObject.TimeStampPattern); Assert.AreEqual(TraceOptions.ProcessId | TraceOptions.ThreadId, configurationObject.TraceOutputOptions); Assert.AreEqual(SourceLevels.Critical, configurationObject.Filter); Assert.AreEqual("overriden header", configurationObject.Header); Assert.AreEqual("overriden footer", configurationObject.Footer); Assert.AreEqual(20, configurationObject.MaxArchivedFiles); }
public void ConfigurationObjectIsModifiedIfThereAreUserPolicyOverrides() { configurationObject.CategoryFilterMode = CategoryFilterMode.AllowAllExceptDenied; configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat1")); configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat2")); userKey.AddStringValue(CategoryFilterDataManageabilityProvider.CategoryFilterModePropertyName, CategoryFilterMode.DenyAllExceptAllowed.ToString()); MockRegistryKey userCategoriesKey = new MockRegistryKey(false); userKey.AddSubKey(CategoryFilterDataManageabilityProvider.CategoryFiltersKeyName, userCategoriesKey); userCategoriesKey.AddBooleanValue("cat3", true); provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(configurationObject, true, null, userKey, true, wmiSettings); Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, configurationObject.CategoryFilterMode); Assert.AreEqual(1, configurationObject.CategoryFilters.Count); Assert.IsNotNull(configurationObject.CategoryFilters.Get("cat3")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userCategoriesKey)); }
public void HelperWithEmtpyManageabilityProvidersDoesNothing() { TestsConfigurationSection section = new TestsConfigurationSection(originalValue); configurationSource.Add(SectionName, section); MockRegistryKey userKey = new MockRegistryKey(false); currentUser.AddSubKey(ManageabilityHelper.BuildSectionKeyName(ApplicationName, SectionName), userKey); MockRegistryKey machineKey = new MockRegistryKey(false); localMachine.AddSubKey(ManageabilityHelper.BuildSectionKeyName(ApplicationName, SectionName), machineKey); ManageabilityHelper helper = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, ApplicationName); helper.UpdateConfigurationManageability(configurationAccessor); Assert.AreEqual(0, currentUser.GetRequests().Count); Assert.AreEqual(0, localMachine.GetRequests().Count); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userKey, machineKey)); }
public void SecurityCacheProviderWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SecurityCacheProviderData), registeredProvider); provider = new SecuritySettingsManageabilityProvider(subProviders); SecurityCacheProviderData securityCacheProvider1Data = new SecurityCacheProviderData("securityCacheProvider1", typeof(Object)); section.SecurityCacheProviders.Add(securityCacheProvider1Data); SecurityCacheProviderData securityCacheProvider2Data = new SecurityCacheProviderData("securityCacheProvider2", typeof(Object)); section.SecurityCacheProviders.Add(securityCacheProvider2Data); MockRegistryKey machineSecurityCacheProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, machineSecurityCacheProvidersKey); MockRegistryKey machineSecurityCacheProvider2Key = new MockRegistryKey(false); machineSecurityCacheProvidersKey.AddSubKey("securityCacheProvider2", machineSecurityCacheProvider2Key); machineSecurityCacheProvider2Key.AddBooleanValue(SecuritySettingsManageabilityProvider.PolicyValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.SecurityCacheProviders.Count); Assert.IsNotNull(section.SecurityCacheProviders.Get("securityCacheProvider1")); Assert.IsNotNull(section.SecurityCacheProviders.Get("securityCacheProvider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineSecurityCacheProvidersKey, machineSecurityCacheProvider2Key)); }
public void RegisteredSecurityCacheProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(CustomSecurityCacheProviderData), registeredProvider); provider = new SecuritySettingsManageabilityProvider(subProviders); CustomSecurityCacheProviderData securitycacheProviderData = new CustomSecurityCacheProviderData("securitycacheProvider1", typeof(Object)); section.SecurityCacheProviders.Add(securitycacheProviderData); MockRegistryKey machinesecuritycacheProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, machinesecuritycacheProvidersKey); MockRegistryKey machinesecuritycacheProviderKey = new MockRegistryKey(false); machinesecuritycacheProvidersKey.AddSubKey("securitycacheProvider1", machinesecuritycacheProviderKey); MockRegistryKey machineOthersecuritycacheProviderKey = new MockRegistryKey(false); machinesecuritycacheProvidersKey.AddSubKey("securitycacheProvider2", machineOthersecuritycacheProviderKey); MockRegistryKey usersecuritycacheProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(SecuritySettingsManageabilityProvider.SecurityCacheProvidersKeyName, usersecuritycacheProvidersKey); MockRegistryKey usersecuritycacheProviderKey = new MockRegistryKey(false); usersecuritycacheProvidersKey.AddSubKey("securitycacheProvider1", usersecuritycacheProviderKey); MockRegistryKey userOthersecuritycacheProviderKey = new MockRegistryKey(false); usersecuritycacheProvidersKey.AddSubKey("securitycacheProvider2", userOthersecuritycacheProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(securitycacheProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machinesecuritycacheProviderKey, registeredProvider.machineKey); Assert.AreSame(usersecuritycacheProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinesecuritycacheProvidersKey, machinesecuritycacheProviderKey, machineOthersecuritycacheProviderKey, usersecuritycacheProvidersKey, usersecuritycacheProviderKey, userOthersecuritycacheProviderKey)); }
public void TraceSourceDefaultLevelIsOverridenFromUserKey() { TraceSourceData sourceData = new TraceSourceData("source1", SourceLevels.Critical, true); section.TraceSources.Add(sourceData); MockRegistryKey userTraceSourcesKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.CategorySourcesKeyName, userTraceSourcesKey); MockRegistryKey userSource1Key = new MockRegistryKey(false); userTraceSourcesKey.AddSubKey("source1", userSource1Key); userSource1Key.AddStringValue(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.Error.ToString()); userSource1Key.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(SourceLevels.Error, sourceData.DefaultLevel); Assert.AreEqual(false, sourceData.AutoFlush); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userTraceSourcesKey, userSource1Key)); }
public void ProviderMappingWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { DbProviderMapping providerMapping1 = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping1); DbProviderMapping providerMapping2 = new DbProviderMapping("provider2", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping2); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); MockRegistryKey providerMapping1MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMapping1MachineKey); providerMapping1MachineKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); MockRegistryKey providerMapping2MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider2", providerMapping2MachineKey); providerMapping2MachineKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, true); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.ProviderMappings.Count); Assert.IsNotNull(section.ProviderMappings.Get("provider1")); Assert.IsNotNull(section.ProviderMappings.Get("provider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMapping1MachineKey, providerMapping2MachineKey, providerMappingsMachineKey)); }
public void RegisteredSymmetricCryptoProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SymmetricAlgorithmProviderData), registeredProvider); provider = new CryptographySettingsManageabilityProvider(subProviders); SymmetricAlgorithmProviderData symmetricCryptoProviderData = new SymmetricAlgorithmProviderData("symmetricCryptoProvider1", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProviderData); MockRegistryKey machinesymmetricCryptoProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, machinesymmetricCryptoProvidersKey); MockRegistryKey machinesymmetricCryptoProviderKey = new MockRegistryKey(false); machinesymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider1", machinesymmetricCryptoProviderKey); MockRegistryKey machineOthersymmetricCryptoProviderKey = new MockRegistryKey(false); machinesymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", machineOthersymmetricCryptoProviderKey); MockRegistryKey usersymmetricCryptoProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, usersymmetricCryptoProvidersKey); MockRegistryKey usersymmetricCryptoProviderKey = new MockRegistryKey(false); usersymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider1", usersymmetricCryptoProviderKey); MockRegistryKey userOthersymmetricCryptoProviderKey = new MockRegistryKey(false); usersymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", userOthersymmetricCryptoProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(symmetricCryptoProviderData, registeredProvider.LastConfigurationObject); Assert.AreSame(machinesymmetricCryptoProviderKey, registeredProvider.machineKey); Assert.AreSame(usersymmetricCryptoProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machinesymmetricCryptoProvidersKey, machinesymmetricCryptoProviderKey, machineOthersymmetricCryptoProviderKey, usersymmetricCryptoProvidersKey, usersymmetricCryptoProviderKey, userOthersymmetricCryptoProviderKey)); }
public void ExceptionTypeWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType11 = new ExceptionTypeData("type11", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType11); ExceptionTypeData exceptionType12 = new ExceptionTypeData("type12", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType12); ExceptionPolicyData policy2 = new ExceptionPolicyData("policy2"); section.ExceptionPolicies.Add(policy2); ExceptionTypeData exceptionType21 = new ExceptionTypeData("type21", typeof(Exception), PostHandlingAction.None); policy2.ExceptionTypes.Add(exceptionType21); MockRegistryKey userPoliciesKey = new MockRegistryKey(false); userKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, userPoliciesKey); MockRegistryKey userPolicy1Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy1", userPolicy1Key); MockRegistryKey userPolicy1TypesKey = new MockRegistryKey(false); userPolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy1TypesKey); MockRegistryKey userPolicy1Type11Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type11", userPolicy1Type11Key); userPolicy1Type11Key.AddBooleanValue(ExceptionHandlingSettingsManageabilityProvider.PolicyValueName, false); MockRegistryKey userPolicy1Type12Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type12", userPolicy1Type12Key); userPolicy1Type12Key.AddBooleanValue(ExceptionHandlingSettingsManageabilityProvider.PolicyValueName, true); MockRegistryKey userPolicy2Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy2", userPolicy2Key); MockRegistryKey userPolicy2TypesKey = new MockRegistryKey(false); userPolicy2Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy2TypesKey); MockRegistryKey userPolicy2Type21Key = new MockRegistryKey(false); userPolicy2TypesKey.AddSubKey("type21", userPolicy2Type21Key); userPolicy2Type21Key.AddBooleanValue(ExceptionHandlingSettingsManageabilityProvider.PolicyValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.ExceptionPolicies.Count); Assert.IsNotNull(section.ExceptionPolicies.Get("policy1")); Assert.AreEqual(2, section.ExceptionPolicies.Get("policy1").ExceptionTypes.Count); Assert.IsNotNull(section.ExceptionPolicies.Get("policy1").ExceptionTypes.Get("type11")); Assert.IsNotNull(section.ExceptionPolicies.Get("policy1").ExceptionTypes.Get("type12")); Assert.IsNotNull(section.ExceptionPolicies.Get("policy2")); Assert.AreEqual(1, section.ExceptionPolicies.Get("policy2").ExceptionTypes.Count); Assert.IsNotNull(section.ExceptionPolicies.Get("policy2").ExceptionTypes.Get("type21")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userPoliciesKey, userPolicy1Key, userPolicy1TypesKey, userPolicy1Type11Key, userPolicy1Type12Key, userPolicy2Key, userPolicy2TypesKey, userPolicy2Type21Key)); }
public void LogFormatterWithDisabledPolicyIsRemoved() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(FormatterData), registeredProvider); provider = new LoggingSettingsManageabilityProvider(subProviders); FormatterData logFormatter1Data = new FormatterData("logFormatter1", typeof(Object)); section.Formatters.Add(logFormatter1Data); FormatterData logFormatter2Data = new FormatterData("logFormatter2", typeof(Object)); section.Formatters.Add(logFormatter2Data); MockRegistryKey machineLogFormattersKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.LogFormattersKeyName, machineLogFormattersKey); MockRegistryKey machineLogFormatter2Key = new MockRegistryKey(false); machineLogFormattersKey.AddSubKey("logFormatter2", machineLogFormatter2Key); machineLogFormatter2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(1, section.Formatters.Count); Assert.IsNotNull(section.Formatters.Get("logFormatter1")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineLogFormattersKey, machineLogFormatter2Key)); }
public void MachineOverridesTakePrecedenceOverUserOverrides() { section.SpecialTraceSources.AllEventsTraceSource.DefaultLevel = SourceLevels.Critical; section.SpecialTraceSources.ErrorsTraceSource.DefaultLevel = SourceLevels.Critical; section.SpecialTraceSources.NotProcessedTraceSource.DefaultLevel = SourceLevels.Critical; section.SpecialTraceSources.AllEventsTraceSource.AutoFlush = true; section.SpecialTraceSources.ErrorsTraceSource.AutoFlush = true; section.SpecialTraceSources.NotProcessedTraceSource.AutoFlush = true; MockRegistryKey userSpecialSourcesKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesKeyName, userSpecialSourcesKey); MockRegistryKey userAllEventsSourceKey = new MockRegistryKey(false); userSpecialSourcesKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesAllEventsKeyName, userAllEventsSourceKey); userAllEventsSourceKey.AddStringValue(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.Error.ToString()); userAllEventsSourceKey.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); MockRegistryKey userErrorsSourceKey = new MockRegistryKey(false); userSpecialSourcesKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesErrorsKeyName, userErrorsSourceKey); userErrorsSourceKey.AddStringValue(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.Information.ToString()); userErrorsSourceKey.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); MockRegistryKey userNotProcessedSourceKey = new MockRegistryKey(false); userSpecialSourcesKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesNotProcessedKeyName, userNotProcessedSourceKey); userNotProcessedSourceKey.AddStringValue(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.Warning.ToString()); userNotProcessedSourceKey.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(SourceLevels.Error, section.SpecialTraceSources.AllEventsTraceSource.DefaultLevel); Assert.AreEqual(SourceLevels.Information, section.SpecialTraceSources.ErrorsTraceSource.DefaultLevel); Assert.AreEqual(SourceLevels.Warning, section.SpecialTraceSources.NotProcessedTraceSource.DefaultLevel); Assert.AreEqual(false, section.SpecialTraceSources.AllEventsTraceSource.AutoFlush); Assert.AreEqual(false, section.SpecialTraceSources.ErrorsTraceSource.AutoFlush); Assert.AreEqual(false, section.SpecialTraceSources.NotProcessedTraceSource.AutoFlush); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userSpecialSourcesKey, userAllEventsSourceKey, userErrorsSourceKey, userNotProcessedSourceKey)); }
public void TraceSourceWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { TraceSourceData traceSource1Data = new TraceSourceData("traceSource1", SourceLevels.Error); section.TraceSources.Add(traceSource1Data); TraceSourceData traceSource2Data = new TraceSourceData("traceSource2", SourceLevels.Error); section.TraceSources.Add(traceSource2Data); MockRegistryKey machineTraceSourcesKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.CategorySourcesKeyName, machineTraceSourcesKey); MockRegistryKey machineTraceSource2Key = new MockRegistryKey(false); machineTraceSourcesKey.AddSubKey("traceSource2", machineTraceSource2Key); machineTraceSource2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.TraceSources.Count); Assert.IsNotNull(section.TraceSources.Get("traceSource1")); Assert.IsNotNull(section.TraceSources.Get("traceSource2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineTraceSourcesKey, machineTraceSource2Key)); }
public void TraceListenerWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(TraceListenerData), registeredProvider); provider = new LoggingSettingsManageabilityProvider(subProviders); TraceListenerData traceListener1Data = new TraceListenerData(); traceListener1Data.Name = "traceListener1"; section.TraceListeners.Add(traceListener1Data); TraceListenerData traceListener2Data = new TraceListenerData(); traceListener2Data.Name = "traceListener2"; section.TraceListeners.Add(traceListener2Data); MockRegistryKey machineTraceListenersKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.TraceListenersKeyName, machineTraceListenersKey); MockRegistryKey machineTraceListener2Key = new MockRegistryKey(false); machineTraceListenersKey.AddSubKey("traceListener2", machineTraceListener2Key); machineTraceListener2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(2, section.TraceListeners.Count); Assert.IsNotNull(section.TraceListeners.Get("traceListener1")); Assert.IsNotNull(section.TraceListeners.Get("traceListener2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineTraceListenersKey, machineTraceListener2Key)); }
public void SymmetricCryptoProviderWithDisabledPolicyIsRemoved() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(SymmetricAlgorithmProviderData), registeredProvider); provider = new CryptographySettingsManageabilityProvider(subProviders); SymmetricAlgorithmProviderData symmetricCryptoProvider1Data = new SymmetricAlgorithmProviderData("symmetricCryptoProvider1", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProvider1Data); SymmetricAlgorithmProviderData symmetricCryptoProvider2Data = new SymmetricAlgorithmProviderData("symmetricCryptoProvider2", typeof(Object), "key", DataProtectionScope.CurrentUser); section.SymmetricCryptoProviders.Add(symmetricCryptoProvider2Data); MockRegistryKey machineSymmetricCryptoProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CryptographySettingsManageabilityProvider.SymmetricCryptoProvidersKeyName, machineSymmetricCryptoProvidersKey); MockRegistryKey machineSymmetricCryptoProvider2Key = new MockRegistryKey(false); machineSymmetricCryptoProvidersKey.AddSubKey("symmetricCryptoProvider2", machineSymmetricCryptoProvider2Key); machineSymmetricCryptoProvider2Key.AddBooleanValue(CryptographySettingsManageabilityProvider.PolicyValueName, false); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(1, section.SymmetricCryptoProviders.Count); Assert.IsNotNull(section.SymmetricCryptoProviders.Get("symmetricCryptoProvider1")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineSymmetricCryptoProvidersKey, machineSymmetricCryptoProvider2Key)); }
public void OverridesForProviderMappingsAreIndependent() { DbProviderMapping providerMapping1 = new DbProviderMapping("provider1", typeof(OracleDatabase)); DbProviderMapping providerMapping2 = new DbProviderMapping("provider2", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping1); section.ProviderMappings.Add(providerMapping2); MockRegistryKey providerMappingUserKey = new MockRegistryKey(false); providerMappingUserKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(GenericDatabase).AssemblyQualifiedName); MockRegistryKey providerMappingsUserKey = new MockRegistryKey(false); providerMappingsUserKey.AddSubKey("provider1", providerMappingUserKey); userKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsUserKey); MockRegistryKey providerMappingMachineKey = new MockRegistryKey(false); providerMappingMachineKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(OracleDatabase).AssemblyQualifiedName); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider2", providerMappingMachineKey); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreSame(typeof(GenericDatabase), providerMapping1.DatabaseType); Assert.AreSame(typeof(OracleDatabase), providerMapping2.DatabaseType); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMappingUserKey, providerMappingsUserKey, providerMappingMachineKey, providerMappingsMachineKey)); }
public void ProviderMappingWithDisabledPolicyIsRemoved() { DbProviderMapping providerMapping1 = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping1); DbProviderMapping providerMapping2 = new DbProviderMapping("provider2", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping2); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); MockRegistryKey providerMapping1MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMapping1MachineKey); providerMapping1MachineKey.AddBooleanValue(DatabaseSettingsManageabilityProvider.PolicyValueName, false); MockRegistryKey providerMapping2MachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider2", providerMapping2MachineKey); providerMapping2MachineKey.AddBooleanValue(DatabaseSettingsManageabilityProvider.PolicyValueName, true); providerMapping2MachineKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(GenericDatabase).AssemblyQualifiedName); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(1, section.ProviderMappings.Count); Assert.IsNotNull(section.ProviderMappings.Get("provider2")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMapping1MachineKey, providerMapping2MachineKey, providerMappingsMachineKey)); }
public void MachineKeySourceOverrideWithoutListenersSubKeyTakesPrecedenceOverUserKeyOverrides() { TraceSourceData sourceData = new TraceSourceData("source1", SourceLevels.Critical, true); section.TraceSources.Add(sourceData); sourceData.TraceListeners.Add(new TraceListenerReferenceData("listener1")); sourceData.TraceListeners.Add(new TraceListenerReferenceData("listener2")); MockRegistryKey machineTraceSourcesKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.CategorySourcesKeyName, machineTraceSourcesKey); MockRegistryKey machineSource1Key = new MockRegistryKey(false); machineTraceSourcesKey.AddSubKey("source1", machineSource1Key); machineSource1Key.AddEnumValue<SourceLevels>(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.ActivityTracing); machineSource1Key.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); MockRegistryKey userTraceSourcesKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.CategorySourcesKeyName, userTraceSourcesKey); MockRegistryKey userSource1Key = new MockRegistryKey(false); userTraceSourcesKey.AddSubKey("source1", userSource1Key); userSource1Key.AddEnumValue<SourceLevels>(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.ActivityTracing); userSource1Key.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); MockRegistryKey userSource1ListenersKey = new MockRegistryKey(false); userSource1Key.AddSubKey(LoggingSettingsManageabilityProvider.SourceTraceListenersPropertyName, userSource1ListenersKey); userSource1ListenersKey.AddBooleanValue("listener6", true); userSource1ListenersKey.AddBooleanValue("listener7", true); userSource1ListenersKey.AddBooleanValue("listener8", true); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(0, sourceData.TraceListeners.Count); Assert.IsTrue( MockRegistryKey.CheckAllClosed( machineTraceSourcesKey, machineSource1Key, userTraceSourcesKey, userSource1Key, userSource1ListenersKey)); }
public void DatabaseTypeOverrideWithInvalidTypeNameIsIgnored() { DbProviderMapping providerMapping = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping); MockRegistryKey providerMappingsMachineKey = new MockRegistryKey(false); machineKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsMachineKey); MockRegistryKey providerMappingMachineKey = new MockRegistryKey(false); providerMappingsMachineKey.AddSubKey("provider1", providerMappingMachineKey); providerMappingMachineKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, "invalid type name"); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreSame(typeof(SqlDatabase), providerMapping.DatabaseType); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMappingMachineKey, providerMappingsMachineKey)); }
public void TraceSourceTraceListenersAreOverridenIfListenerKeyIsPresentInUserKey() { TraceSourceData sourceData = new TraceSourceData("source1", SourceLevels.Critical, true); section.TraceSources.Add(sourceData); sourceData.TraceListeners.Add(new TraceListenerReferenceData("listener1")); sourceData.TraceListeners.Add(new TraceListenerReferenceData("listener2")); MockRegistryKey userTraceSourcesKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.CategorySourcesKeyName, userTraceSourcesKey); MockRegistryKey userSource1Key = new MockRegistryKey(false); userTraceSourcesKey.AddSubKey("source1", userSource1Key); userSource1Key.AddEnumValue<SourceLevels>(LoggingSettingsManageabilityProvider.SourceDefaultLevelPropertyName, SourceLevels.ActivityTracing); userSource1Key.AddBooleanValue(LoggingSettingsManageabilityProvider.SourceAutoFlushPropertyName, false); MockRegistryKey userSource1ListenersKey = new MockRegistryKey(false); userSource1Key.AddSubKey(LoggingSettingsManageabilityProvider.SourceTraceListenersPropertyName, userSource1ListenersKey); userSource1ListenersKey.AddBooleanValue("listener3", true); userSource1ListenersKey.AddBooleanValue("listener4", true); userSource1ListenersKey.AddBooleanValue("listener5", true); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual(3, sourceData.TraceListeners.Count); Assert.IsNotNull(sourceData.TraceListeners.Get("listener3")); Assert.IsNotNull(sourceData.TraceListeners.Get("listener4")); Assert.IsNotNull(sourceData.TraceListeners.Get("listener5")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(userTraceSourcesKey, userSource1Key, userSource1ListenersKey)); }
public void UserOverridesForMissingPolicyCausesNoProblems() { ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); MockRegistryKey userPoliciesKey = new MockRegistryKey(false); userKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, userPoliciesKey); MockRegistryKey userPolicy1Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy2", userPolicy1Key); MockRegistryKey userPolicy1TypesKey = new MockRegistryKey(false); userPolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy1TypesKey); MockRegistryKey userPolicy1Type1Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type1", userPolicy1Type1Key); userPolicy1Type1Key.AddStringValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.NotifyRethrow.ToString()); provider.OverrideWithGroupPolicies(section, true, null, userKey); Assert.AreEqual(PostHandlingAction.None, exceptionType1.PostHandlingAction); Assert.IsTrue( MockRegistryKey.CheckAllClosed(userPoliciesKey, userPolicy1Key, userPolicy1TypesKey, userPolicy1Type1Key)); }
public void RegisteredListenerDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(FormattedEventLogTraceListenerData), registeredProvider); provider = new LoggingSettingsManageabilityProvider(subProviders); FormattedEventLogTraceListenerData listenerData = new FormattedEventLogTraceListenerData("listener1", "source", "formatter"); section.TraceListeners.Add(listenerData); MockRegistryKey machineListenersKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.TraceListenersKeyName, machineListenersKey); MockRegistryKey machineListenerKey = new MockRegistryKey(false); machineListenersKey.AddSubKey("listener1", machineListenerKey); MockRegistryKey machineOtherListenerKey = new MockRegistryKey(false); machineListenersKey.AddSubKey("listener2", machineOtherListenerKey); MockRegistryKey userListenersKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.TraceListenersKeyName, userListenersKey); MockRegistryKey userListenerKey = new MockRegistryKey(false); userListenersKey.AddSubKey("listener1", userListenerKey); MockRegistryKey userOtherListenerKey = new MockRegistryKey(false); userListenersKey.AddSubKey("listener2", userOtherListenerKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(listenerData, registeredProvider.LastConfigurationObject); Assert.AreSame(machineListenerKey, registeredProvider.machineKey); Assert.AreSame(userListenerKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineListenersKey, machineListenerKey, machineOtherListenerKey, userListenersKey, userListenerKey, userOtherListenerKey)); }
public void RegisteredHandlerDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(ReplaceHandlerData), registeredProvider); provider = new ExceptionHandlingSettingsManageabilityProvider(subProviders); ExceptionPolicyData policy1 = new ExceptionPolicyData("policy1"); section.ExceptionPolicies.Add(policy1); ExceptionTypeData exceptionType1 = new ExceptionTypeData("type1", typeof(Exception), PostHandlingAction.None); policy1.ExceptionTypes.Add(exceptionType1); ExceptionHandlerData handlerData1 = new ReplaceHandlerData("handler1", "msg", typeof(ArgumentException).AssemblyQualifiedName); exceptionType1.ExceptionHandlers.Add(handlerData1); MockRegistryKey machinePoliciesKey = new MockRegistryKey(false); machineKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, machinePoliciesKey); MockRegistryKey machinePolicy1Key = new MockRegistryKey(false); machinePoliciesKey.AddSubKey("policy1", machinePolicy1Key); MockRegistryKey machinePolicy1TypesKey = new MockRegistryKey(false); machinePolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, machinePolicy1TypesKey); MockRegistryKey machinePolicy1Type1Key = new MockRegistryKey(false); machinePolicy1TypesKey.AddSubKey("type1", machinePolicy1Type1Key); MockRegistryKey machineHandlersKey = new MockRegistryKey(false); machinePolicy1Type1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypeHandlersPropertyName, machineHandlersKey); machinePolicy1Type1Key.AddEnumValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.None); MockRegistryKey machineHandlerKey = new MockRegistryKey(false); machineHandlersKey.AddSubKey("handler1", machineHandlerKey); MockRegistryKey userPoliciesKey = new MockRegistryKey(false); userKey.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PoliciesKeyName, userPoliciesKey); MockRegistryKey userPolicy1Key = new MockRegistryKey(false); userPoliciesKey.AddSubKey("policy1", userPolicy1Key); MockRegistryKey userPolicy1TypesKey = new MockRegistryKey(false); userPolicy1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypesPropertyName, userPolicy1TypesKey); MockRegistryKey userPolicy1Type1Key = new MockRegistryKey(false); userPolicy1TypesKey.AddSubKey("type1", userPolicy1Type1Key); MockRegistryKey userHandlersKey = new MockRegistryKey(false); userPolicy1Type1Key.AddSubKey(ExceptionHandlingSettingsManageabilityProvider.PolicyTypeHandlersPropertyName, userHandlersKey); userPolicy1Type1Key.AddEnumValue( ExceptionHandlingSettingsManageabilityProvider.PolicyTypePostHandlingActionPropertyName, PostHandlingAction.None); MockRegistryKey userHandlerKey = new MockRegistryKey(false); userHandlersKey.AddSubKey("handler1", userHandlerKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(handlerData1, registeredProvider.LastConfigurationObject); Assert.AreSame(machineHandlerKey, registeredProvider.machineKey); Assert.AreSame(userHandlerKey, registeredProvider.userKey); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePoliciesKey, machinePolicy1Key, machinePolicy1TypesKey, machinePolicy1Type1Key, machineHandlersKey, machineHandlerKey, userPolicy1Key, userPolicy1TypesKey, userPolicy1Type1Key, userHandlersKey, userHandlerKey)); }
public void CacheManagerIsNotOverridenIfThereArePolicyOverridesForDifferentName() { CacheManagerData data1 = new CacheManagerData(); data1.Name = "cache manager 1"; data1.CacheStorage = "cache storage"; data1.ExpirationPollFrequencyInSeconds = 100; data1.MaximumElementsInCacheBeforeScavenging = 200; data1.NumberToRemoveWhenScavenging = 300; section.CacheManagers.Add(data1); MockRegistryKey machineCacheManagersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.CacheManagersKeyName, machineCacheManagersKey); MockRegistryKey machineCacheManager1Key = new MockRegistryKey(false); machineCacheManagersKey.AddSubKey("cache manager 2", machineCacheManager1Key); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerExpirationPollFrequencyInSecondsPropertyName, 150); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName, 250); machineCacheManager1Key.AddIntValue(CacheManagerSettingsManageabilityProvider.CacheManagerNumberToRemoveWhenScavengingPropertyName, 350); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreEqual("cache storage", data1.CacheStorage); Assert.AreEqual(100, data1.ExpirationPollFrequencyInSeconds); Assert.AreEqual(200, data1.MaximumElementsInCacheBeforeScavenging); Assert.AreEqual(300, data1.NumberToRemoveWhenScavenging); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineCacheManagersKey, machineCacheManager1Key)); }
public void SpecialTraceSourceWithDisabledPolicyIsNotInvalidatedIfGroupPoliciesAreDisabled() { section.SpecialTraceSources.AllEventsTraceSource.TraceListeners.Add(new TraceListenerReferenceData("listener")); MockRegistryKey machineTraceSpecialSourcesKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesKeyName, machineTraceSpecialSourcesKey); MockRegistryKey machineAllEventsTraceSourceKey = new MockRegistryKey(false); machineTraceSpecialSourcesKey.AddSubKey(LoggingSettingsManageabilityProvider.SpecialSourcesAllEventsKeyName, machineAllEventsTraceSourceKey); machineAllEventsTraceSourceKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, false); provider.OverrideWithGroupPolicies(section, false, machineKey, userKey); Assert.AreEqual(1, section.SpecialTraceSources.AllEventsTraceSource.TraceListeners.Count); Assert.IsNotNull(section.SpecialTraceSources.AllEventsTraceSource.TraceListeners.Get("listener")); Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineTraceSpecialSourcesKey, machineAllEventsTraceSourceKey)); }
public void RegisteredEncryptionProviderDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(StorageEncryptionProviderData), registeredProvider); provider = new CacheManagerSettingsManageabilityProvider(subProviders); StorageEncryptionProviderData data = new StorageEncryptionProviderData("encryptionprovider1", typeof(Object)); section.EncryptionProviders.Add(data); MockRegistryKey machineEncryptionProvidersKey = new MockRegistryKey(false); machineKey.AddSubKey(CacheManagerSettingsManageabilityProvider.EncryptionProvidersKeyName, machineEncryptionProvidersKey); MockRegistryKey machineEncryptionProviderKey = new MockRegistryKey(false); machineEncryptionProvidersKey.AddSubKey("encryptionprovider1", machineEncryptionProviderKey); MockRegistryKey machineOtherEncryptionProviderKey = new MockRegistryKey(false); machineEncryptionProvidersKey.AddSubKey("encryptionprovider2", machineOtherEncryptionProviderKey); MockRegistryKey userEncryptionProvidersKey = new MockRegistryKey(false); userKey.AddSubKey(CacheManagerSettingsManageabilityProvider.EncryptionProvidersKeyName, userEncryptionProvidersKey); MockRegistryKey userEncryptionProviderKey = new MockRegistryKey(false); userEncryptionProvidersKey.AddSubKey("encryptionprovider1", userEncryptionProviderKey); MockRegistryKey userOtherEncryptionProviderKey = new MockRegistryKey(false); userEncryptionProvidersKey.AddSubKey("encryptionprovider2", userOtherEncryptionProviderKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(data, registeredProvider.LastConfigurationObject); Assert.AreEqual(machineEncryptionProviderKey, registeredProvider.machineKey); Assert.AreEqual(userEncryptionProviderKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineEncryptionProvidersKey, machineEncryptionProviderKey, machineOtherEncryptionProviderKey, userEncryptionProvidersKey, userEncryptionProviderKey, userOtherEncryptionProviderKey)); }
public void RegisteredLogFilterDataProviderIsCalledWithCorrectOverrides() { MockConfigurationElementManageabilityProvider registeredProvider = new MockConfigurationElementManageabilityProvider(); Dictionary<Type, ConfigurationElementManageabilityProvider> subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>(); subProviders.Add(typeof(PriorityFilterData), registeredProvider); provider = new LoggingSettingsManageabilityProvider(subProviders); PriorityFilterData filterData = new PriorityFilterData("filter1", 10); section.LogFilters.Add(filterData); MockRegistryKey machineFiltersKey = new MockRegistryKey(false); machineKey.AddSubKey(LoggingSettingsManageabilityProvider.LogFiltersKeyName, machineFiltersKey); MockRegistryKey machineFilterKey = new MockRegistryKey(false); machineFiltersKey.AddSubKey("filter1", machineFilterKey); MockRegistryKey machineOtherFilterKey = new MockRegistryKey(false); machineFiltersKey.AddSubKey("filter2", machineOtherFilterKey); MockRegistryKey userFiltersKey = new MockRegistryKey(false); userKey.AddSubKey(LoggingSettingsManageabilityProvider.LogFiltersKeyName, userFiltersKey); MockRegistryKey userFilterKey = new MockRegistryKey(false); userFiltersKey.AddSubKey("filter1", userFilterKey); MockRegistryKey userOtherFilterKey = new MockRegistryKey(false); userFiltersKey.AddSubKey("filter2", userOtherFilterKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.IsTrue(registeredProvider.called); Assert.AreSame(filterData, registeredProvider.LastConfigurationObject); Assert.AreSame(machineFilterKey, registeredProvider.machineKey); Assert.AreSame(userFilterKey, registeredProvider.userKey); Assert.IsTrue( MockRegistryKey.CheckAllClosed(machineFiltersKey, machineFilterKey, machineOtherFilterKey, userFiltersKey, userFilterKey, userOtherFilterKey)); }
public void OverrideForMissingProviderIsIgnored() { DbProviderMapping providerMapping = new DbProviderMapping("provider1", typeof(SqlDatabase)); section.ProviderMappings.Add(providerMapping); MockRegistryKey providerMappingKey = new MockRegistryKey(false); providerMappingKey.AddStringValue(DatabaseSettingsManageabilityProvider.DatabaseTypePropertyName, typeof(OracleDatabase).AssemblyQualifiedName); MockRegistryKey providerMappingsKey = new MockRegistryKey(false); providerMappingsKey.AddSubKey("provider2", providerMappingKey); userKey.AddSubKey(DatabaseSettingsManageabilityProvider.ProviderMappingsKeyName, providerMappingsKey); provider.OverrideWithGroupPolicies(section, true, machineKey, userKey); Assert.AreSame(typeof(SqlDatabase), providerMapping.DatabaseType); Assert.IsTrue(MockRegistryKey.CheckAllClosed(providerMappingKey, providerMappingsKey)); }