Example #1
0
 def testNotSpecTypePorts(self):
     """ Test port list without specific type. """
     tports, uports = ports_as_list('51-60')
     self.assertFalse(tports is None)
     self.assertEqual(len(uports), 0)
     self.assertEqual(len(tports), 10)
     for i in range(51, 60):
         self.assertTrue(i in tports)
Example #2
0
 def testUdpPorts(self):
     """ Test only udp ports."""
     tports, uports = ports_as_list('U:1-10')
     self.assertFalse(uports is None)
     self.assertEqual(len(tports), 0)
     self.assertEqual(len(uports), 10)
     for i in range(1, 10):
         self.assertTrue(i in uports)
Example #3
0
 def testTcpPorts(self):
     """ Test only tcp ports."""
     tports, uports = ports_as_list('T:1-10,30,31')
     self.assertFalse(tports is None)
     self.assertEqual(len(uports), 0)
     self.assertEqual(len(tports), 12)
     for i in range(1, 10):
         self.assertTrue(i in tports)
     self.assertTrue(30 in tports)
     self.assertTrue(31 in tports)
Example #4
0
 def testBothPortsUdpfirst(self):
     """ Test tcp und udp ports, but udp listed first."""
     tports, uports = ports_as_list('U:20-30, T:1-10')
     self.assertFalse(tports is None)
     self.assertFalse(uports is None)
     self.assertEqual(len(tports), 10)
     self.assertEqual(len(uports), 11)
     for i in range(1, 10):
         self.assertTrue(i in tports)
     for i in range(20, 30):
         self.assertTrue(i in uports)
Example #5
0
 def testBothPorts(self):
     """ Test tcp und udp ports."""
     tports, uports = ports_as_list('T:1-10, U:1-10')
     self.assertFalse(tports is None)
     self.assertFalse(uports is None)
     self.assertEqual(len(tports), 10)
     self.assertEqual(len(uports), 10)
     for i in range(1, 10):
         self.assertTrue(i in tports)
         self.assertTrue(i in uports)
     self.assertFalse(0 in uports)
Example #6
0
    def testMalformedPortStr(self):
        """ Test different malformed port list. """
        tports, uports = ports_as_list('TU:1-2')
        self.assertTrue(tports is None)
        self.assertTrue(uports is None)

        tports, uports = ports_as_list('U1-2')
        self.assertTrue(tports is None)
        self.assertTrue(uports is None)

        tports, uports = ports_as_list('U:1-2t:22')
        self.assertTrue(tports is None)
        self.assertTrue(uports is None)

        tports, uports = ports_as_list('U1-2,T22')
        self.assertTrue(tports is None)
        self.assertTrue(uports is None)

        tports, uports = ports_as_list('U:1-2,U:22')
        self.assertTrue(tports is None)
        self.assertTrue(uports is None)
Example #7
0
 def testEmptyPort(self):
     """ Test an empty port list. """
     tports, uports = ports_as_list('')
     self.assertTrue(tports is None)
     self.assertTrue(uports is None)
Example #8
0
 def testInvalidCharPort(self):
     """ Test list with a false char. """
     tports, uports = ports_as_list('R:51-60')
     self.assertTrue(tports is None)
     self.assertTrue(uports is None)