public void SetUp()
 {
     provider = new FaultContractExceptionHandlerDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new FaultContractExceptionHandlerData();
 }
 public void SetUp()
 {
     provider = new IsolatedStorageCacheStorageDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new IsolatedStorageCacheStorageData();
 }
Exemplo n.º 3
0
 public void SetUp()
 {
     provider   = new DatabaseSettingsManageabilityProvider(new Dictionary <Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey    = new MockRegistryKey(true);
     section    = new DatabaseSettings();
 }
Exemplo n.º 4
0
 public void SetUp()
 {
     provider            = new AuthorizationRuleProviderDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new AuthorizationRuleProviderData();
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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.InvokeOverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            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 SetUp()
 {
     provider = new KeyedHashAlgorithmProviderDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new KeyedHashAlgorithmProviderData();
 }
 public void SetUp()
 {
     provider = new CustomHandlerDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new CustomHandlerData();
 }
 public void SetUp()
 {
     provider = new AuthorizationRuleProviderDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new AuthorizationRuleProviderData();
 }
Exemplo n.º 10
0
        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 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));
        }
Exemplo n.º 12
0
 public void SetUp()
 {
     provider            = new DataCacheStorageDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new DataCacheStorageData();
 }
 public void SetUp()
 {
     provider = new InstrumentationConfigurationSectionManageabilityProvider(new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new InstrumentationConfigurationSection();
 }
Exemplo n.º 14
0
 public void SetUp()
 {
     provider            = new FaultContractExceptionHandlerDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new FaultContractExceptionHandlerData();
 }
        public void ConfigurationObjectIsNotModifiedIfThereArePolicyOverridesButGroupPoliciesAreDisabled()
        {
            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("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, 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 WmiSettingsAreGeneratedWithPolicyOverridesIfWmiIsEnabled()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();

            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            MockRegistryKey machinePackageKey = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(1, wmiSettings.Count);
            Assert.AreSame(typeof(OracleConnectionSetting), wmiSettings[0].GetType());

            Dictionary <String, String> packagesDictionary = new Dictionary <string, string>();

            foreach (String entry in ((OracleConnectionSetting)wmiSettings[0]).Packages)
            {
                KeyValuePairParsingTestHelper.ExtractKeyValueEntries(entry, packagesDictionary);
            }
            Assert.AreEqual(3, packagesDictionary.Count);
            Assert.AreEqual("prefix13", packagesDictionary["package13"]);
            Assert.AreEqual("prefix14", packagesDictionary["package14"]);
            Assert.AreEqual("prefix15", packagesDictionary["package15"]);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackageKey));
        }
        public void LogFormatterWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled()
        {
            ConnectionStringSettings connectionString1 = new ConnectionStringSettings("cs1", "connectionString", "providerName");

            section.ConnectionStrings.Add(connectionString1);
            ConnectionStringSettings connectionString2 = new ConnectionStringSettings("cs2", "connectionString", "providerName");

            section.ConnectionStrings.Add(connectionString2);

            MockRegistryKey machineConnectionString1Key = new MockRegistryKey(false);

            machineKey.AddSubKey("cs1", machineConnectionString1Key);
            machineConnectionString1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false);
            MockRegistryKey machineConnectionString2Key = new MockRegistryKey(false);

            machineKey.AddSubKey("cs2", machineConnectionString2Key);
            machineConnectionString2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, true);

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(2, section.ConnectionStrings.Count);
            Assert.IsNotNull(section.ConnectionStrings["cs1"]);
            Assert.IsNotNull(section.ConnectionStrings["cs2"]);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineConnectionString1Key, machineConnectionString2Key));
        }
Exemplo n.º 18
0
        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 SetUp()
 {
     provider = new DpapiSymmetricCryptoProviderDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new DpapiSymmetricCryptoProviderData();
 }
Exemplo n.º 20
0
        public void HelperWillNotSendRegistryKeysIfNotAvailable()
        {
            TestsConfigurationSection section = new TestsConfigurationSection(originalValue);

            configurationSource.Add(SectionName, section);

            MockRegistryKey machineKey = new MockRegistryKey(false);

            localMachine.AddSubKey(ManageabilityHelper.BuildSectionKeyName(ApplicationName, SectionName), machineKey);

            MockConfigurationSectionManageabilityProvider manageabilityProvider = new MockConfigurationSectionManageabilityProvider(subProviders);

            manageabilityProviders.Add(SectionName, manageabilityProvider);

            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, ApplicationName);

            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsTrue(manageabilityProvider.called);
            Assert.IsTrue(manageabilityProvider.readGroupPolicies);
            Assert.AreEqual(1, currentUser.GetRequests().Count);
            Assert.IsNull(manageabilityProvider.userKey);
            Assert.AreEqual(1, localMachine.GetRequests().Count);
            Assert.AreSame(machineKey, manageabilityProvider.machineKey);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineKey));
        }
Exemplo n.º 21
0
 public void SetUp()
 {
     provider            = new LogEnabledFilterDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new LogEnabledFilterData();
 }
        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 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 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.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, true, machineKey, null, false, wmiSettings);

            Assert.AreEqual(PostHandlingAction.NotifyRethrow, exceptionType1.PostHandlingAction);

            Assert.IsTrue(
                MockRegistryKey.CheckAllClosed(machinePoliciesKey, machinePolicy1Key, machinePolicy1TypesKey, machinePolicy1Type1Key));
        }
 public void SetUp()
 {
     provider   = new InstrumentationConfigurationSectionManageabilityProvider(new Dictionary <Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey    = new MockRegistryKey(true);
     section    = new InstrumentationConfigurationSection();
 }
Exemplo n.º 27
0
 public void SetUp()
 {
     provider            = new HashAlgorithmProviderDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new HashAlgorithmProviderData();
 }
Exemplo n.º 28
0
        public void HelperWithManageabilityProviderForMissingSectionDoesNothing()
        {
            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);

            MockConfigurationSectionManageabilityProvider manageabilityProvider = new MockConfigurationSectionManageabilityProvider(subProviders);

            manageabilityProviders.Add(AltSectionName, manageabilityProvider);

            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, ApplicationName);

            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsFalse(manageabilityProvider.called);
            Assert.AreEqual(0, currentUser.GetRequests().Count);
            Assert.AreEqual(0, localMachine.GetRequests().Count);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(userKey, machineKey));
        }
Exemplo n.º 29
0
 public void SetUp()
 {
     provider            = new CustomFormatterDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new CustomFormatterData();
 }
Exemplo n.º 30
0
 public void SetUp()
 {
     provider            = new ReplaceHandlerDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new ReplaceHandlerData();
 }
Exemplo n.º 31
0
        public void HelperWithManageabilityProviderForExistingSectionDoesInvokeWithApproriateParameters()
        {
            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);

            MockConfigurationSectionManageabilityProvider manageabilityProvider = new MockConfigurationSectionManageabilityProvider(subProviders);

            manageabilityProviders.Add(SectionName, manageabilityProvider);

            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, true, wmiPublisher, ApplicationName);

            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsTrue(manageabilityProvider.called);
            Assert.AreEqual(1, wmiPublisher.GetPublishedInstances().Count);
            Assert.AreEqual(1, currentUser.GetRequests().Count);
            Assert.AreSame(userKey, manageabilityProvider.userKey);
            Assert.AreEqual(1, localMachine.GetRequests().Count);
            Assert.AreSame(machineKey, manageabilityProvider.machineKey);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(userKey, machineKey));
        }
 public void SetUp()
 {
     provider = new LogEnabledFilterDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     configurationObject = new LogEnabledFilterData();
 }
        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));
        }
Exemplo n.º 34
0
 public void SetUp()
 {
     provider            = new SymmetricStorageEncryptionProviderDataManageabilityProvider();
     machineKey          = new MockRegistryKey(true);
     userKey             = new MockRegistryKey(true);
     configurationObject = new SymmetricStorageEncryptionProviderData();
 }
        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 OracleConnectionWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled()
        {
            OracleConnectionData connectionData1 = new OracleConnectionData();

            connectionData1.Name = "data1";
            section.OracleConnectionsData.Add(connectionData1);
            OracleConnectionData connectionData2 = new OracleConnectionData();

            connectionData2.Name = "data2";
            section.OracleConnectionsData.Add(connectionData2);

            MockRegistryKey machinePackage1Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data1", machinePackage1Key);
            machinePackage1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false);
            MockRegistryKey machinePackage2Key = new MockRegistryKey(false);

            machineKey.AddSubKey("data2", machinePackage2Key);
            machinePackage2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, true);
            machinePackage2Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package24=prefix24");

            provider.OverrideWithGroupPoliciesAndGenerateWmiObjects(section, false, machineKey, userKey, true, wmiSettings);

            Assert.AreEqual(2, section.OracleConnectionsData.Count);
            Assert.IsNotNull(section.OracleConnectionsData.Get("data1"));
            Assert.IsNotNull(section.OracleConnectionsData.Get("data2"));

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackage1Key, machinePackage2Key));
        }
Exemplo n.º 37
0
        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));
        }
Exemplo n.º 38
0
        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 SetUp()
 {
     provider = new OracleConnectionSettingsManageabilityProvider(new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new OracleConnectionSettings();
 }
Exemplo n.º 40
0
        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 SetUp()
 {
     provider = new LoggingSettingsManageabilityProvider(new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new LoggingSettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add(LoggingSettings.SectionName, section);
 }
 public void SetUp()
 {
     provider = new CryptographySettingsManageabilityProvider(new Dictionary<Type, ConfigurationElementManageabilityProvider>(0));
     machineKey = new MockRegistryKey(true);
     userKey = new MockRegistryKey(true);
     section = new CryptographySettings();
     configurationSource = new DictionaryConfigurationSource();
     configurationSource.Add("securityCryptographyConfiguration", section);
 }
 public void SetUp()
 {
     provider = new EmailTraceListenerDataManageabilityProvider();
     machineKey = new MockRegistryKey(true);
     machineOptionsKey = new MockRegistryKey(false);
     userKey = new MockRegistryKey(true);
     userOptionsKey = new MockRegistryKey(false);
     configurationObject = new EmailTraceListenerData();
 }
        public void SetUp()
        {
            configurationSource = new DictionaryConfigurationSource();
            configurationAccessor = new DictionaryConfigurationSourceConfigurationAccessor(configurationSource);
            currentUser = new MockRegistryKey(true);
            localMachine = new MockRegistryKey(true);
            registryAccessor = new MockRegistryAccessor(currentUser, localMachine);

            manageabilityProviders = new Dictionary<string, ConfigurationSectionManageabilityProvider>();
            subProviders = new Dictionary<Type, ConfigurationElementManageabilityProvider>();
        }
        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 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 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 SetUp()
 {
     registryKey = new MockRegistryKey(true);
 }
        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 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 MachineKeyOverridesTakePrecedenceOverUserKeyOverrides()
        {
            configurationObject.CategoryFilterMode = CategoryFilterMode.AllowAllExceptDenied;
            configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat1"));
            configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat2"));

            machineKey.AddStringValue(CategoryFilterDataManageabilityProvider.CategoryFilterModePropertyName, CategoryFilterMode.DenyAllExceptAllowed.ToString());
            userKey.AddStringValue(CategoryFilterDataManageabilityProvider.CategoryFilterModePropertyName, CategoryFilterMode.AllowAllExceptDenied.ToString());
            MockRegistryKey userCategoriesKey = new MockRegistryKey(false);
            userKey.AddSubKey(CategoryFilterDataManageabilityProvider.CategoryFiltersKeyName, userCategoriesKey);
            userCategoriesKey.AddBooleanValue("cat3", true);

            provider.OverrideWithGroupPolicies(configurationObject, true, machineKey, userKey);

            Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, configurationObject.CategoryFilterMode);
            Assert.AreEqual(0, configurationObject.CategoryFilters.Count);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(userCategoriesKey));
        }
        public void ConfigurationObjectIsNotModifiedIfThereArePolicyOverridesButGroupPoliciesAreDisabled()
        {
            configurationObject.CategoryFilterMode = CategoryFilterMode.AllowAllExceptDenied;
            configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat1"));
            configurationObject.CategoryFilters.Add(new CategoryFilterEntry("cat2"));

            machineKey.AddStringValue(CategoryFilterDataManageabilityProvider.CategoryFilterModePropertyName, CategoryFilterMode.DenyAllExceptAllowed.ToString());
            MockRegistryKey machineCategoriesKey = new MockRegistryKey(false);
            machineKey.AddSubKey(CategoryFilterDataManageabilityProvider.CategoryFiltersKeyName, machineCategoriesKey);
            machineCategoriesKey.AddBooleanValue("cat3", true);

            provider.OverrideWithGroupPolicies(configurationObject, false, machineKey, userKey);

            Assert.AreEqual(CategoryFilterMode.AllowAllExceptDenied, configurationObject.CategoryFilterMode);
            Assert.AreEqual(2, configurationObject.CategoryFilters.Count);
            Assert.IsNotNull(configurationObject.CategoryFilters.Get("cat1"));
            Assert.IsNotNull(configurationObject.CategoryFilters.Get("cat2"));

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineCategoriesKey));
        }
        public void MultipleConfigurationObjectsAreModifiedIfThereArePolicyOverrides()
        {
            OracleConnectionData connection1Data = new OracleConnectionData();
            connection1Data.Name = "data1";
            connection1Data.Packages.Add(new OraclePackageData("package11", "prefix11"));
            connection1Data.Packages.Add(new OraclePackageData("package12", "prefix12"));
            section.OracleConnectionsData.Add(connection1Data);

            OracleConnectionData connection2Data = new OracleConnectionData();
            connection2Data.Name = "data2";
            connection2Data.Packages.Add(new OraclePackageData("package21", "prefix21"));
            connection2Data.Packages.Add(new OraclePackageData("package22", "prefix22"));
            connection2Data.Packages.Add(new OraclePackageData("package23", "prefix23"));
            section.OracleConnectionsData.Add(connection2Data);

            OracleConnectionData connection3Data = new OracleConnectionData();
            connection3Data.Name = "data3";
            connection3Data.Packages.Add(new OraclePackageData("package31", "prefix31"));
            section.OracleConnectionsData.Add(connection3Data);

            MockRegistryKey machinePackage1Key = new MockRegistryKey(false);
            machineKey.AddSubKey("data1", machinePackage1Key);
            machinePackage1Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package13=prefix13; package14=prefix14; package15=prefix15");
            MockRegistryKey machinePackage2Key = new MockRegistryKey(false);
            machineKey.AddSubKey("data2", machinePackage2Key);
            machinePackage2Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package24=prefix24");

            provider.OverrideWithGroupPolicies(section, true, machineKey, userKey);

            Assert.AreEqual(3, connection1Data.Packages.Count);
            Assert.IsNotNull(connection1Data.Packages.Get("package13"));
            Assert.AreEqual("prefix13", connection1Data.Packages.Get("package13").Prefix);
            Assert.IsNotNull(connection1Data.Packages.Get("package14"));
            Assert.AreEqual("prefix14", connection1Data.Packages.Get("package14").Prefix);
            Assert.IsNotNull(connection1Data.Packages.Get("package15"));
            Assert.AreEqual("prefix15", connection1Data.Packages.Get("package15").Prefix);

            Assert.AreEqual(1, connection2Data.Packages.Count);
            Assert.IsNotNull(connection2Data.Packages.Get("package24"));
            Assert.AreEqual("prefix24", connection2Data.Packages.Get("package24").Prefix);

            Assert.AreEqual(1, connection3Data.Packages.Count);
            Assert.IsNotNull(connection3Data.Packages.Get("package31"));
            Assert.AreEqual("prefix31", connection3Data.Packages.Get("package31").Prefix);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackage1Key, machinePackage2Key));
        }
        public void ConfigurationObjectIsNotModifiedIfThereArePolicyOverridesButGroupPoliciesAreDisabled()
        {
            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("data1", machinePackageKey);
            machinePackageKey.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                             "package13=prefix13; package14=prefix14; package15=prefix15");

            provider.OverrideWithGroupPolicies(section, false, machineKey, userKey);

            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 OracleConnectionWithDisabledPolicyIsNotRemovedIfGroupPoliciesAreDisabled()
        {
            OracleConnectionData connectionData1 = new OracleConnectionData();
            connectionData1.Name = "data1";
            section.OracleConnectionsData.Add(connectionData1);
            OracleConnectionData connectionData2 = new OracleConnectionData();
            connectionData2.Name = "data2";
            section.OracleConnectionsData.Add(connectionData2);

            MockRegistryKey machinePackage1Key = new MockRegistryKey(false);
            machineKey.AddSubKey("data1", machinePackage1Key);
            machinePackage1Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, false);
            MockRegistryKey machinePackage2Key = new MockRegistryKey(false);
            machineKey.AddSubKey("data2", machinePackage2Key);
            machinePackage2Key.AddBooleanValue(AdmContentBuilder.AvailableValueName, true);
            machinePackage2Key.AddStringValue(OracleConnectionSettingsManageabilityProvider.PackagesPropertyName,
                                              "package24=prefix24");

            provider.OverrideWithGroupPolicies(section, false, machineKey, userKey);

            Assert.AreEqual(2, section.OracleConnectionsData.Count);
            Assert.IsNotNull(section.OracleConnectionsData.Get("data1"));
            Assert.IsNotNull(section.OracleConnectionsData.Get("data2"));

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machinePackage1Key, machinePackage2Key));
        }
        public void HelperWillNotSendRegistryKeysIfNotAvailable()
        {
            TestsConfigurationSection section = new TestsConfigurationSection(originalValue);
            configurationSource.Add(SectionName, section);

            MockRegistryKey machineKey = new MockRegistryKey(false);
            localMachine.AddSubKey(ManageabilityHelper.BuildSectionKeyName(ApplicationName, SectionName), machineKey);

            MockConfigurationSectionManageabilityProvider manageabilityProvider = new MockConfigurationSectionManageabilityProvider(subProviders);
            manageabilityProviders.Add(SectionName, manageabilityProvider);

            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, ApplicationName);
            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsTrue(manageabilityProvider.called);
            Assert.IsTrue(manageabilityProvider.readGroupPolicies);
            Assert.AreEqual(1, currentUser.GetRequests().Count);
            Assert.IsNull(manageabilityProvider.userKey);
            Assert.AreEqual(1, localMachine.GetRequests().Count);
            Assert.AreSame(machineKey, manageabilityProvider.machineKey);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(machineKey));
        }
        public void WillNotRemoveRegisteredSectionWithDisabledPolicyIfPolicyOverridesAreDisabled()
        {
            TestsConfigurationSection section = new TestsConfigurationSection(originalValue);
            configurationSource.Add(SectionName, section);

            MockRegistryKey machineKey = new MockRegistryKey(false);
            localMachine.AddSubKey(ManageabilityHelper.BuildSectionKeyName(ApplicationName, SectionName), machineKey);
            machineKey.AddBooleanValue(AdmContentBuilder.AvailableValueName, false);

            MockConfigurationSectionManageabilityProvider manageabilityProvider
                = new MockConfigurationSectionManageabilityProvider(subProviders);
            manageabilityProviders.Add(SectionName, manageabilityProvider);
            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, false, registryAccessor, ApplicationName);

            Assert.IsTrue(configurationSource.Contains(SectionName));

            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsTrue(configurationSource.Contains(SectionName));
        }
        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 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 HelperWithManageabilityProviderForExistingSectionDoesInvokeWithApproriateParameters()
        {
            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);

            MockConfigurationSectionManageabilityProvider manageabilityProvider = new MockConfigurationSectionManageabilityProvider(subProviders);
            manageabilityProviders.Add(SectionName, manageabilityProvider);

            ManageabilityHelper helper
                = new ManageabilityHelper(manageabilityProviders, true, registryAccessor, ApplicationName);
            helper.UpdateConfigurationManageability(configurationAccessor);

            Assert.IsTrue(manageabilityProvider.called);
            Assert.AreEqual(1, currentUser.GetRequests().Count);
            Assert.AreSame(userKey, manageabilityProvider.userKey);
            Assert.AreEqual(1, localMachine.GetRequests().Count);
            Assert.AreSame(machineKey, manageabilityProvider.machineKey);

            Assert.IsTrue(MockRegistryKey.CheckAllClosed(userKey, machineKey));
        }