コード例 #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
ファイル: test_ntp.py プロジェクト: sjm-steffann/dhcpkit
    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
ファイル: test_ntp.py プロジェクト: sjm-steffann/dhcpkit
    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')