Example #1
0
 def test_03_mangle_table(self):
     """
     Tables 03: mangle INPUT entry
     """
     tables = Tables("")
     line = "ip6tables -t mangle -A INPUT"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     tables.put_into_tables(line)
     expect = ['-A INPUT -p tcp --dport 80 -j ACCEPT ']
     self.assertEquals(expect, tables.data["mangle"]["INPUT"])
Example #2
0
 def test_04_raw_table(self):
     """
     Tables 04: raw OUTPUT entry
     """
     tables = Tables("")
     line = "ip6tables -t raw -A OUTPUT"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     tables.put_into_tables(line)
     expect = ['-A OUTPUT -p tcp --dport 80 -j ACCEPT ']
     self.assertEquals(expect, tables.data["raw"]["OUTPUT"])
Example #3
0
 def test_04_raw_table(self):
     """
     Tables 04: raw OUTPUT entry
     """
     tables = Tables("")
     line = "ip6tables -t raw -A OUTPUT"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     tables.put_into_tables(line)
     expect = ['-A OUTPUT -p tcp --dport 80 -j ACCEPT ']
     self.assertEquals(expect, tables.data["raw"]["OUTPUT"])
Example #4
0
 def test_03_mangle_table(self):
     """
     Tables 03: mangle INPUT entry
     """
     tables = Tables("")
     line = "ip6tables -t mangle -A INPUT"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     tables.put_into_tables(line)
     expect = ['-A INPUT -p tcp --dport 80 -j ACCEPT ']
     self.assertEquals(expect, tables.data["mangle"]["INPUT"])
Example #5
0
 def test_02_nat_prerouting(self):
     """
     Tables 02: nat PREROUTING entry
     """
     tables = Tables("")
     line = "ip6tables -t nat -A PREROUTING -s 10.0.0.0/21"
     line = line + " -p tcp --dport   80 -j SNAT --to-source 192.168.1.15"
     tables.put_into_tables(line)
     expect = ['-A PREROUTING -s 10.0.0.0/21 -p tcp --dport 80 -j SNAT --to-source 192.168.1.15 ']
     self.assertEquals(expect, tables.data["nat"]["PREROUTING"])
Example #6
0
 def test_02_nat_prerouting(self):
     """
     Tables 02: nat PREROUTING entry
     """
     tables = Tables("")
     line = "ip6tables -t nat -A PREROUTING -s 10.0.0.0/21"
     line = line + " -p tcp --dport   80 -j SNAT --to-source 192.168.1.15"
     tables.put_into_tables(line)
     expect = [
         '-A PREROUTING -s 10.0.0.0/21 -p tcp --dport 80 -j SNAT --to-source 192.168.1.15 '
     ]
     self.assertEquals(expect, tables.data["nat"]["PREROUTING"])
Example #7
0
 def test_05_not_existing_chain(self):
     """
     Tables 05: INPUT to not existing chain
     """
     tables = Tables("")
     line = "ip6tables -t raw -A NONEXIST"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     happend = False
     try:
         self.assertRaises(ValueError, tables, tables.put_into_tables(line))
     except:
         happend = True
     self.assertEquals(happend, True)
Example #8
0
 def test_05_not_existing_chain(self):
     """
     Tables 05: INPUT to not existing chain
     """
     tables = Tables("")
     line = "ip6tables -t raw -A NONEXIST"
     line = line + " -p tcp --dport   80 -j ACCEPT"
     happend = False
     try:
         self.assertRaises(ValueError, tables, tables.put_into_tables(line))
     except:
         happend = True
     self.assertEquals(happend, True)