Esempio n. 1
0
 def test_iscsi_portal_parsing_ip(self):
     with self.assertRaisesRegexp(ValueError, 'Invalid IPv6 address'):
         iscsi.assert_valid_iscsi_portal(
             '[1200::AB00:1234::2552:7777:1313]:9999')
     # cannot distinguish between bad IP and bad hostname
     host, port = iscsi.assert_valid_iscsi_portal('192.168:9000')
     self.assertEquals(host, '192.168')
     self.assertEquals(port, 9000)
Esempio n. 2
0
 def test_iscsi_portal_parsing_valid_ip(self):
     # IP must be in [] for IPv6, if not we misparse
     host, port = iscsi.assert_valid_iscsi_portal(
         'fe80::a634:d9ff:fe40:768a:9999')
     self.assertEquals(host, 'fe80::a634:d9ff:fe40:768a')
     self.assertEquals(port, 9999)
     # IP must not be in [] if port is specified for IPv4
     with self.assertRaisesRegexp(ValueError, 'Invalid IPv6 address'):
         iscsi.assert_valid_iscsi_portal('[192.168.1.12]:9000')
     with self.assertRaisesRegexp(ValueError, 'Invalid IPv6 address'):
         iscsi.assert_valid_iscsi_portal('[test.example.com]:8000')
Esempio n. 3
0
    def test_iscsi_portal_parsing_good_portals(self):
        host, port = iscsi.assert_valid_iscsi_portal('192.168.1.12:9000')
        self.assertEquals(host, '192.168.1.12')
        self.assertEquals(port, 9000)

        host, port = iscsi.assert_valid_iscsi_portal(
            '[fe80::a634:d9ff:fe40:768a]:9999')
        self.assertEquals(host, 'fe80::a634:d9ff:fe40:768a')
        self.assertEquals(port, 9999)

        host, port = iscsi.assert_valid_iscsi_portal('test.example.com:8000')
        self.assertEquals(host, 'test.example.com')
        self.assertEquals(port, 8000)
Esempio n. 4
0
 def test_iscsi_portal_parsing_no_port(self):
     # port must be specified
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('192.168.1.12')
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('fe80::a634:d9ff:fe40:768a')
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('192.168.1.12:')
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('test.example.com:')
Esempio n. 5
0
 def test_iscsi_portal_parsing_port(self):
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('192.168.1.12:ABCD')
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('[fe80::a634:d9ff:fe40:768a]:ABCD')
     with self.assertRaisesRegexp(ValueError, 'not in the format'):
         iscsi.assert_valid_iscsi_portal('test.example.com:ABCD')
Esempio n. 6
0
 def test_iscsi_portal_parsing_string(self):
     with self.assertRaisesRegexp(ValueError, 'not a string'):
         iscsi.assert_valid_iscsi_portal(1234)