public void TestBitmapPortNoChange()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system        = new MockIpsetBinaryAdapter(systemFactory);
            var iptables      = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List <String>()
            {
                "create test bitmap:port range 1-65535",
                "add test 80",
                "add test 81"
            }, iptables);

            rulesOriginal.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetAndEntries;


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List <String>()
            {
                "create test bitmap:port bitmap:port range 1-65535",
                "add test 81",
                "add test 80"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetAndEntries;

            systemFactory.TestSync(rulesNew, new List <string>
            {
            });
        }
        public void TestBitmapPort()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system        = new MockIpsetBinaryAdapter(systemFactory);
            var iptables      = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List <String>()
            {
                "create test bitmap:port family inet",
                "add test 80"
            }, iptables);


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List <String>()
            {
                "create test bitmap:port"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetOnly;

            systemFactory.TestSync(rulesNew, new List <string>
            {
            });
        }
        public void TestSyncEntryNotValues()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system        = new MockIpsetBinaryAdapter(systemFactory);
            var iptables      = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List <String>()
            {
                "create test hash:ip family inet hashsize 1024 maxelem 65536",
                "add test 8.8.8.8"
            }, iptables);


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List <String>()
            {
                "create test hash:ip"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetOnly;

            systemFactory.TestSync(rulesNew, new List <string>
            {
            });
        }
        public void TestSyncDelete()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system = new MockIpsetBinaryAdapter(systemFactory);
            var iptables = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List<String>()
            {
                "create test hash:ip",
                "add test 8.8.8.8"
            }, iptables);

            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List<String>()
            {
            }, iptables);

            systemFactory.TestSync(rulesNew, new List<string>
            {
                "destroy test"
            });
        }
        public void TestSyncDelete()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system        = new MockIpsetBinaryAdapter(systemFactory);
            var iptables      = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List <String>()
            {
                "create test hash:ip",
                "add test 8.8.8.8"
            }, iptables);

            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List <String>()
            {
            }, iptables);

            systemFactory.TestSync(rulesNew, new List <string>
            {
                "destroy test"
            });
        }
        public void TestSyncCreateNet()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system        = new MockIpsetBinaryAdapter(systemFactory);
            var iptables      = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List <String>()
            {
            }, iptables);

            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List <String>()
            {
                "create test hash:net",
                "add test 8.8.8.8/32"
            }, iptables);

            systemFactory.TestSync(rulesNew, new List <string>
            {
                "create test hash:net family inet hashsize 1024 maxelem 65536",
                "add test 8.8.8.8"
            });
        }
        public void TestSyncCreateNet()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system = new MockIpsetBinaryAdapter(systemFactory);
            var iptables = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List<String>()
            {
            }, iptables);

            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List<String>()
            {
                "create test hash:net",
                "add test 8.8.8.8/32"
            }, iptables);

            systemFactory.TestSync(rulesNew, new List<string>
            {
                "create test hash:net family inet hashsize 1024 maxelem 65536",
                "add test 8.8.8.8"
            });
        }
        public void TestBitmapPortNoChange()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system = new MockIpsetBinaryAdapter(systemFactory);
            var iptables = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List<String>()
            {
                "create test bitmap:port range 1-65535",
                "add test 80",
                "add test 81"
            }, iptables);

            rulesOriginal.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetAndEntries;


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List<String>()
            {
                "create test bitmap:port bitmap:port range 1-65535",
                "add test 81",
                "add test 80"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetAndEntries;

            systemFactory.TestSync(rulesNew, new List<string>
            {
            });
        }
        public void TestBitmapPort()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system = new MockIpsetBinaryAdapter(systemFactory);
            var iptables = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List<String>()
            {
                "create test bitmap:port family inet",
                "add test 80"
            }, iptables);


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List<String>()
            {
                "create test bitmap:port"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetOnly;

            systemFactory.TestSync(rulesNew, new List<string>
            {
            });
        }
Beispiel #10
0
        public void TestSyncEntryNotValues()
        {
            var systemFactory = new MockIpsetSystemFactory();
            var system = new MockIpsetBinaryAdapter(systemFactory);
            var iptables = new IpTablesSystem(systemFactory, null, system);

            IpSetSets rulesOriginal = new IpSetSets(new List<String>()
            {
                "create test hash:ip family inet hashsize 1024 maxelem 65536",
                "add test 8.8.8.8"
            }, iptables);


            system.SetSets(rulesOriginal);

            IpSetSets rulesNew = new IpSetSets(new List<String>()
            {
                "create test hash:ip"
            }, iptables);

            rulesNew.Sets.FirstOrDefault().SyncMode = IpSetSyncMode.SetOnly;

            systemFactory.TestSync(rulesNew, new List<string>
            {
            });
        }