Пример #1
0
 def setUp(self):
     self.option_bytes = bytes.fromhex('0038004b'
                                       '0001001020010db8000000000000000000000001'
                                       '00020010ff12000000000000000000000000abcd'
                                       '00030011') + b'\x03ntp\x08steffann\x02nl\x00' + \
                         bytes.fromhex('ffff000a') + b'RandomData'
     self.option_object = NTPServersOption(options=[
         NTPServerAddressSubOption(IPv6Address('2001:db8::1')),
         NTPMulticastAddressSubOption(IPv6Address('ff12::abcd')),
         NTPServerFQDNSubOption('ntp.steffann.nl.'),
         UnknownNTPSubOption(65535, b'RandomData'),
     ])
     self.parse_option()
Пример #2
0
    def test_config_datatype(self):
        value = NTPServerFQDNSubOption.config_datatype('ntp.steffann.nl')
        self.assertEqual(value, 'ntp.steffann.nl')

        with self.assertRaisesRegex(ValueError, 'letters, digits and hyphens'):
            NTPServerFQDNSubOption.config_datatype('something that is not a domain name')

        with self.assertRaisesRegex(ValueError, '1 to 63 characters long'):
            NTPServerFQDNSubOption.config_datatype('something..bad')

        with self.assertRaisesRegex(ValueError, '1 to 63 characters long'):
            NTPServerFQDNSubOption.config_datatype('steffann-steffann-steffann-steffann-'
                                                   'steffann-steffann-steffann-steffann.bad')
Пример #3
0
    def test_config_datatype(self):
        value = NTPServerFQDNSubOption.config_datatype('ntp.steffann.nl')
        self.assertEqual(value, 'ntp.steffann.nl')

        with self.assertRaisesRegex(ValueError, 'letters, digits and hyphens'):
            NTPServerFQDNSubOption.config_datatype('something that is not a domain name')

        with self.assertRaisesRegex(ValueError, '1 to 63 characters long'):
            NTPServerFQDNSubOption.config_datatype('something..bad')

        with self.assertRaisesRegex(ValueError, '1 to 63 characters long'):
            NTPServerFQDNSubOption.config_datatype('steffann-steffann-steffann-steffann-'
                                                   'steffann-steffann-steffann-steffann.bad')
Пример #4
0
    def test_config_datatype(self):
        value = NTPServerFQDNSubOption.config_datatype('ntp.steffann.nl')
        self.assertEqual(value, 'ntp.steffann.nl')

        with self.assertRaisesRegex(ValueError, 'Invalid label'):
            NTPServerFQDNSubOption.config_datatype('something that is not a domain name')

        with self.assertRaisesRegex(ValueError, 'Invalid label'):
            NTPServerFQDNSubOption.config_datatype('something..bad')

        with self.assertRaisesRegex(ValueError, 'Label too long'):
            NTPServerFQDNSubOption.config_datatype('steffann-steffann-steffann-steffann-'
                                                   'steffann-steffann-steffann-steffann.bad')
Пример #5
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'must end with a 0-length label'):
            NTPServerFQDNSubOption.parse(bytes.fromhex('0003000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'length does not match'):
            NTPServerFQDNSubOption.parse(bytes.fromhex('0003000e') + b'\x08steffann\x02nl\x00\x01')
Пример #6
0
 def setUp(self):
     self.option_bytes = bytes.fromhex('00030011') + b'\x03ntp\x08steffann\x02nl\x00'
     self.option_object = NTPServerFQDNSubOption('ntp.steffann.nl.')
     self.parse_option()
Пример #7
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'must end with a 0-length label'):
            NTPServerFQDNSubOption.parse(bytes.fromhex('0003000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'length does not match'):
            NTPServerFQDNSubOption.parse(bytes.fromhex('0003000e') + b'\x08steffann\x02nl\x00\x01')