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); }
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); }
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); }
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); }
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); }
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); }
public void Cleanup() { FirewallManager.DisableFirewallSettings(); TestFirewallManiuplator.Enable(); }