Ejemplo n.º 1
0
        public void UpdateTest()
        {
            List <TestFirewallRule> startRules = TestFirewallManiuplator.GetRules();
            var nodes = GetNodeSettings(3, 0, true, "test.microsoft.com");

            FirewallManager.EnableFirewallSettings(nodes, true, true);
            List <TestFirewallRule> newRules   = GetRules(3, 0, true);
            List <TestFirewallRule> addedRules = TestFirewallManiuplator.GetRules();

            VerifyRulesDiff(startRules, newRules, addedRules);

            //
            // Remove a node and the corresponding firewall rules for that node.
            //
            nodes.RemoveAt(1);
            newRules.RemoveRange(35, 35);

            nodes.AddRange(GetNodeSettings(2, 3, true, "test.microsoft.com"));
            newRules.AddRange(GetRules(2, 3, true));
            FirewallManager.EnableFirewallSettings(nodes, true, true);
            addedRules = TestFirewallManiuplator.GetRules();
            VerifyRulesDiff(startRules, newRules, addedRules);
            FirewallManager.DisableFirewallSettings();
            var finalRules = TestFirewallManiuplator.GetRules();

            VerifyRulesEqual(startRules, finalRules);
        }
Ejemplo n.º 2
0
        List <TestFirewallRule> GetRules(int nodeCount, int start, bool addAppPorts)
        {
            List <TestFirewallRule> rules = new List <TestFirewallRule>();
            int leaseDriverPort           = BaseLeaseDriverPort + start;
            int httpGatewayPort           = BaseHttpGatewayport + start;
            int httpAppGatewayPort        = BaseHttpAppGatewayport + start;
            int appPortStart = BaseAppStartport + start * AppPortRange;
            int appPortEnd   = appPortStart + AppPortRange;
            var fwProfile    = TestFirewallManiuplator.GetCurrentProfile();

            for (int i = 0; i < nodeCount; i++)
            {
                string nodeName = string.Format(NodeNameTemplate, i + start);
                AddRuleForEachProfile(rules, nodeName, httpGatewayPort, httpAppGatewayPort, leaseDriverPort, fwProfile);


                if (addAppPorts)
                {
                    AddApplicationPortsForProfile(rules, nodeName, appPortStart, appPortEnd, fwProfile);
                    appPortStart += AppPortRange;
                    appPortEnd   += AppPortRange;
                }

                leaseDriverPort++;
            }
            return(rules);
        }
Ejemplo n.º 3
0
        public void VerifyNoChangeOnLocalhostScaleMin()
        {
            var startRules = TestFirewallManiuplator.GetRules();
            var nodes      = GetNodeSettings(3, 0, true, "localhost");
            var newRules   = GetRules(3, 0, true);

            FirewallManager.EnableFirewallSettings(nodes, true, true);
            var finalRules = TestFirewallManiuplator.GetRules();

            VerifyRulesEqual(startRules, finalRules);
        }
Ejemplo n.º 4
0
        public void BasicInstallationAndUninstallation()
        {
            List <TestFirewallRule> startRules = TestFirewallManiuplator.GetRules();
            var nodes = GetNodeSettings(3, 0, true, "test.microsoft.com");

            FirewallManager.EnableFirewallSettings(nodes, true, true);
            List <TestFirewallRule> newRules   = GetRules(3, 0, true);
            List <TestFirewallRule> addedRules = TestFirewallManiuplator.GetRules();

            VerifyRulesDiff(startRules, newRules, addedRules);
            FirewallManager.DisableFirewallSettings();
            List <TestFirewallRule> finalRules = TestFirewallManiuplator.GetRules();

            VerifyRulesEqual(finalRules, startRules);
        }
Ejemplo n.º 5
0
        public static void RemoveWinFabRules()
        {
            var NetFWPolicyType = Type.GetTypeFromProgID("HNetCfg.FwPolicy2", false);
            var mgr             = (INetFwPolicy2)Activator.CreateInstance(NetFWPolicyType);

            List <TestFirewallRule> rules = new List <TestFirewallRule>();

            foreach (var rule in mgr.Rules)
            {
                NetFwRule fwRule = (NetFwRule)rule;
                if (!String.IsNullOrEmpty(fwRule.Grouping) && ((NetFwRule)rule).Grouping.Equals("WindowsFabric"))
                {
                    rules.Add(new TestFirewallRule((NetFwRule)rule));
                }
            }
            TestFirewallManiuplator.RemoveRules(rules);
        }
Ejemplo n.º 6
0
        public void V1RuleRemoval()
        {
            List <TestFirewallRule> startRules = TestFirewallManiuplator.GetRules();
            List <TestFirewallRule> v1Rules    = new List <TestFirewallRule>();

            TestFirewallManiuplator.AddRules(v1Rules);
            var nodes    = GetNodeSettings(3, 0, true, "test.microsoft.com");
            var newRules = GetRules(3, 0, true);

            FirewallManager.EnableFirewallSettings(nodes, true, true);
            List <TestFirewallRule> addedRules = TestFirewallManiuplator.GetRules();

            VerifyRulesDiff(startRules, newRules, addedRules);
            FirewallManager.DisableFirewallSettings();
            List <TestFirewallRule> finalRules = TestFirewallManiuplator.GetRules();

            VerifyRulesEqual(finalRules, startRules);
        }
Ejemplo n.º 7
0
 public void Cleanup()
 {
     FirewallManager.DisableFirewallSettings();
     TestFirewallManiuplator.Enable();
 }