示例#1
0
        public void DeploymentManagerTest_ValidateOptionalCertificateIssuerThumbprint()
        {
            string clusterConfigPath   = Path.Combine(BaseDir, JsonConfigX509SecureOptionalIssuerTPOct2017Filename);
            string clusterManifestPath = Path.Combine(Path.GetTempPath(), "cmtest.xml");
            var    clusterResource     = DeploymentManagerInternal.GetClusterResource(clusterConfigPath, System.Guid.NewGuid().ToString());
            var    cm = clusterResource.Current.ExternalState.ClusterManifest;

            Assert.IsNotNull(cm, "Cluster manifest was null.");
            XMLHelper.WriteXmlExclusive <ClusterManifestType>(clusterManifestPath, cm);
            Assert.IsTrue(File.Exists(clusterManifestPath), "Cluster manifest was not written.");

            ClusterManifestType manifest = XMLHelper.ReadClusterManifest(clusterManifestPath);

            Assert.IsNotNull(manifest, "Cluster manifest was null.");
            var fabricSettings             = manifest.FabricSettings;
            var securityAdminClientSetting = fabricSettings.Where <SettingsOverridesTypeSection>(p => p.Name == StringConstants.SectionName.SecurityAdminClientX509Names).First();

            foreach (var param in securityAdminClientSetting.Parameter)
            {
                Assert.IsNotNull(param.Value, param.Name + " Value was null");
            }

            var securityClusterSetting = fabricSettings.Where <SettingsOverridesTypeSection>(p => p.Name == StringConstants.SectionName.SecurityClusterX509Names).First();

            foreach (var param in securityClusterSetting.Parameter)
            {
                Assert.IsNotNull(param.Value, param.Name + " Value was null");
            }

            var securityServerSetting = fabricSettings.Where <SettingsOverridesTypeSection>(p => p.Name == StringConstants.SectionName.SecurityServerX509Names).First();

            foreach (var param in securityServerSetting.Parameter)
            {
                Assert.IsNotNull(param.Value, param.Name + " Value was null");
            }

            var securityClientSetting = fabricSettings.Where <SettingsOverridesTypeSection>(p => p.Name == StringConstants.SectionName.SecurityClientX509Names).First();

            foreach (var param in securityClientSetting.Parameter)
            {
                Assert.IsNotNull(param.Value, param.Name + " Value was null");
            }
        }
示例#2
0
        public void DeploymentManagerTest_ConvertJsonToXml()
        {
            Console.WriteLine("Current directory: {0}", Environment.CurrentDirectory);
            string clusterConfigPath = Path.Combine(BaseDir, JsonConfigUnsecureJan2017Filename);

            Directory.SetCurrentDirectory(BaseDir);
            Console.WriteLine("New current directory changed to: {0}", Environment.CurrentDirectory);
            Assert.IsTrue(File.Exists(clusterConfigPath), string.Format("Config file {0} did not exist.", clusterConfigPath));
            string clusterManifestPath = Path.Combine(Path.GetTempPath(), "cmtest.xml");
            var    clusterResource     = DeploymentManagerInternal.GetClusterResource(clusterConfigPath, System.Guid.NewGuid().ToString());
            var    cm = clusterResource.Current.ExternalState.ClusterManifest;

            Assert.IsNotNull(cm, "Cluster manifest was null.");
            XMLHelper.WriteXmlExclusive <ClusterManifestType>(clusterManifestPath, cm);
            Assert.IsTrue(File.Exists(clusterManifestPath), "Cluster manifest was not written.");
            List <string> machines = StandaloneUtility.GetMachineNamesFromClusterManifest(clusterManifestPath);

            Assert.IsNotNull(machines);
            Assert.IsTrue(machines.Count > 0, "Cluster manifest was not written correctly. Machines missing.");
        }
示例#3
0
        public void DeploymentManagerTest_ValidateJsonConfigIssuerCertStoreOctober2017()
        {
            string clusterConfigPath = Path.Combine(BaseDir, JsonConfigX509SecureIssuerCNOct2017Filename);
            var    configModel       = StandAloneInstallerJsonModelBase.GetJsonConfigFromFile(clusterConfigPath);

            Assert.IsTrue(File.Exists(clusterConfigPath), string.Format("Config file {0} did not exist.", clusterConfigPath));
            Assert.IsNotNull(configModel, "JSON config was invalid.");

            var userConfig = configModel.GetUserConfig();

            Assert.IsTrue(userConfig.Security.CertificateInformation.ClusterCertificateIssuerStores.Count() == 2, "ClusterCertificateIssuerStore count should be 2.");
            Assert.IsTrue(userConfig.Security.CertificateInformation.ServerCertificateIssuerStores.Count() == 1, "ServerCertificateIssuerStore count should be 1.");
            Assert.IsTrue(userConfig.Security.CertificateInformation.ClientCertificateIssuerStores.Count() == 1, "ClientCertificateIssuerStore count should be 1.");

            var clusterResource = DeploymentManagerInternal.GetClusterResource(clusterConfigPath, System.Guid.NewGuid().ToString());
            var cm = clusterResource.Current.ExternalState.ClusterManifest;
            var clusterCertificateIssuerStore = cm.FabricSettings.ToList().Where(section => section.Name == StringConstants.SectionName.SecurityClusterCertificateIssuerStores).ToList();

            Assert.IsTrue(clusterCertificateIssuerStore.Count() == 1, "clusterCertificateIssuerStore count should be 1");
            Assert.IsTrue(clusterCertificateIssuerStore[0].Parameter.ToList().Count == 2, "clusterCertificateIssuerStore parameter count should be 2");
            Assert.AreEqual(clusterCertificateIssuerStore[0].Parameter[0].Name, "");
            Assert.AreEqual(clusterCertificateIssuerStore[0].Parameter[0].Value, "My");
            Assert.AreEqual(clusterCertificateIssuerStore[0].Parameter[1].Name, "ClusterIssuer");
            Assert.AreEqual(clusterCertificateIssuerStore[0].Parameter[1].Value, "My, Root");

            var serverCertificateIssuerStore = cm.FabricSettings.ToList().Where(section => section.Name == StringConstants.SectionName.SecurityServerCertificateIssuerStores).ToList();

            Assert.IsTrue(serverCertificateIssuerStore.Count() == 1, "serverCertificateIssuerStore count should be 1");
            Assert.IsTrue(serverCertificateIssuerStore[0].Parameter.ToList().Count == 1, "serverCertificateIssuerStore parameter count should be 1");
            Assert.AreEqual(serverCertificateIssuerStore[0].Parameter[0].Name, "ServerIssuer");
            Assert.AreEqual(serverCertificateIssuerStore[0].Parameter[0].Value, "My");

            var clientCertificateIssuerStore = cm.FabricSettings.ToList().Where(section => section.Name == StringConstants.SectionName.SecurityClientCertificateIssuerStores).ToList();

            Assert.IsTrue(clientCertificateIssuerStore.Count() == 1, "clientCertificateIssuerStore count should be 1");
            Assert.IsTrue(clientCertificateIssuerStore[0].Parameter.ToList().Count == 1, "clientCertificateIssuerStore parameter count should be 1");
            Assert.AreEqual(clientCertificateIssuerStore[0].Parameter[0].Name, "ClientIssuer");
            Assert.AreEqual(clientCertificateIssuerStore[0].Parameter[0].Value, "My");
        }
示例#4
0
        public void CreateClusterManifest()
        {
            string jsonConfigPath = Path.Combine(Utility.TestDirectory, "ClusterConfig.Unsecure.DevCluster.json");

            Assert.IsTrue(System.IO.File.Exists(jsonConfigPath), string.Format("JSON config file {0} did not exist.", jsonConfigPath));
            var clusterResource = DeploymentManagerInternal.GetClusterResource(jsonConfigPath, System.Guid.NewGuid().ToString());
            var cm = clusterResource.Current.ExternalState.ClusterManifest;

            Assert.IsNotNull(cm, "Cluster manifest was null.");
            var settings = new XmlWriterSettings {
                Indent = true
            };

            using (var fs = new FileStream("ClusterManifest.xml", FileMode.Create))
            {
                using (var writer = XmlWriter.Create(fs, settings))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ClusterManifestType));
                    serializer.Serialize(writer, cm);
                }
                fs.Close(); // Explicit close to reduce races.
            }
        }
示例#5
0
        public static FileInfo GetClusterManifestFromJsonConfig(string clusterConfigPath, string clusterName, string version)
        {
            var clusterResource = DeploymentManagerInternal.GetClusterResource(clusterConfigPath, System.Guid.NewGuid().ToString());

            return(StandaloneUtility.ClusterManifestToFile(clusterResource.Current.ExternalState.ClusterManifest, clusterName, version));
        }
示例#6
0
        internal void ConvertDevJsonToXml_Utility(int expectedReplicaSize, string inputFile, string outputFile, string sectionToChangeWin7, bool isSecure = false, bool testOverride = false)
        {
            Console.WriteLine("Current directory: {0}", Environment.CurrentDirectory);
            string clusterConfigPath = Path.Combine(DevJsonModelTest.BaseDir, inputFile);

            Directory.SetCurrentDirectory(DevJsonModelTest.BaseDir);
            Console.WriteLine("New current directory changed to: {0}", Environment.CurrentDirectory);
            string clusterManifestPath = Path.Combine(Path.GetTempPath(), outputFile);
            var    clusterResource     = DeploymentManagerInternal.GetClusterResource(clusterConfigPath, System.Guid.NewGuid().ToString());
            var    cm = clusterResource.Current.ExternalState.ClusterManifest;

            Assert.IsNotNull(cm, "Cluster manifest was null.");

            File.Delete(clusterManifestPath);
            XMLHelper.WriteXmlExclusive <ClusterManifestType>(clusterManifestPath, cm);
            List <string> machines = StandaloneUtility.GetMachineNamesFromClusterManifest(clusterManifestPath);

            Assert.IsNotNull(machines);

            Assert.AreEqual(expectedReplicaSize, ((WindowsInfrastructureType)cm.Infrastructure.Item).NodeList.ToList().Where(node => node.IsSeedNode).Count());

            if (isSecure)
            {
                Assert.AreEqual(InputEndpointTypeProtocol.https, cm.NodeTypes[0].Endpoints.HttpGatewayEndpoint.Protocol);
                Assert.IsNotNull(cm.NodeTypes[0].Certificates.ClientCertificate, "Client certificate was null.");
            }

            foreach (SettingsOverridesTypeSection setting in cm.FabricSettings)
            {
                Assert.IsTrue(IsSectionAllowed(cm.NodeTypes.Count(), setting.Name));
                if (setting.Name == StringConstants.SectionName.Setup)
                {
                    foreach (SettingsOverridesTypeSectionParameter param in setting.Parameter)
                    {
                        Assert.AreNotEqual(StringConstants.ParameterName.IsDevCluster, param.Name);
                        if (param.Name == StringConstants.ParameterName.FabricDataRoot)
                        {
                            Assert.AreEqual(Environment.ExpandEnvironmentVariables("%systemdrive%\\SfDevCluster\\Data"), param.Value);
                        }
                    }
                }
                if (setting.Name == StringConstants.SectionName.ClusterManager)
                {
                    SettingsOverridesTypeSectionParameter TargetReplicaSetSizeParam = setting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.TargetReplicaSetSize);
                    Assert.IsNotNull(TargetReplicaSetSizeParam, "Cannot find TargetReplicaSetSize for Cluster Manager");
                    Assert.AreEqual(expectedReplicaSize.ToString(), TargetReplicaSetSizeParam.Value);
                }
                if (DevJsonModel.IsWin7() && setting.Name == sectionToChangeWin7)
                {
                    SettingsOverridesTypeSectionParameter isEnabledParam = setting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.IsEnabled);
                    Assert.IsNotNull(isEnabledParam, "Cannot find isEnabled for " + sectionToChangeWin7);
                    Assert.AreEqual("false", isEnabledParam.Value);
                }
                if (setting.Name == StringConstants.SectionName.Diagnostics && testOverride)
                {
                    SettingsOverridesTypeSectionParameter isEnabledTraceSessionParam = setting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.EnableCircularTraceSession);
                    Assert.IsNotNull(isEnabledTraceSessionParam, "Cannot find isEnabled for EnableCircularTraceSession");
                    Assert.AreEqual("false", isEnabledTraceSessionParam.Value);
                }
                if (setting.Name == StringConstants.SectionName.FailoverManager && expectedReplicaSize == 1)
                {
                    SettingsOverridesTypeSectionParameter IsSingletonReplicaMoveAllowedDuringUpgradeParam = setting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.IsSingletonReplicaMoveAllowedDuringUpgrade);
                    Assert.IsNotNull(IsSingletonReplicaMoveAllowedDuringUpgradeParam, "Cannot find isEnabled for EnableCircularTraceSession");
                    Assert.AreEqual("false", IsSingletonReplicaMoveAllowedDuringUpgradeParam.Value);
                }
            }

            //DevCluster should have one distinct IPaddress, i.e. localhost
            Assert.AreEqual(1, machines.Count);
        }