def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError,
                                    'must end with a 0-length label'):
            SIPServersDomainNameListOption.parse(
                bytes.fromhex('0015000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'exceeds available buffer'):
            SIPServersDomainNameListOption.parse(
                bytes.fromhex('0015000e') + b'\x08steffann\x02nl\x00\x01')
Beispiel #2
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError,
                                    'must end with a 0-length label'):
            SIPServersDomainNameListOption.parse(
                bytes.fromhex('0040000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'does not match the length'):
            SIPServersDomainNameListOption.parse(
                bytes.fromhex('0040000e') + b'\x08steffann\x02nl\x00\x01')
Beispiel #3
0
    def combine(
        self, existing_options: Iterable[SIPServersDomainNameListOption]
    ) -> SIPServersDomainNameListOption:
        """
        Combine multiple options into one.

        :param existing_options: The existing options to include NTP servers from
        :return: The combined option
        """
        domain_names = []

        # Add from existing options first
        for option in existing_options:
            for domain_name in option.domain_names:
                if domain_name not in domain_names:
                    domain_names.append(domain_name)

        # Then add our own
        for domain_name in self.option.domain_names:
            if domain_name not in domain_names:
                domain_names.append(domain_name)

        # And return a new option with the combined addresses
        return SIPServersDomainNameListOption(domain_names=domain_names)
Beispiel #4
0
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'must end with a 0-length label'):
            SIPServersDomainNameListOption.parse(bytes.fromhex('0040000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'does not match the length'):
            SIPServersDomainNameListOption.parse(bytes.fromhex('0040000e') + b'\x08steffann\x02nl\x00\x01')
    def test_bad_option_length(self):
        with self.assertRaisesRegex(ValueError, 'must end with a 0-length label'):
            SIPServersDomainNameListOption.parse(bytes.fromhex('0015000c') + b'\x08steffann\x02nl\x00')

        with self.assertRaisesRegex(ValueError, 'exceeds available buffer'):
            SIPServersDomainNameListOption.parse(bytes.fromhex('0015000e') + b'\x08steffann\x02nl\x00\x01')
Beispiel #6
0
 def setUp(self):
     self.option_bytes = bytes.fromhex('0015000d') + b'\x08steffann\x02nl\x00'
     self.option_object = SIPServersDomainNameListOption(domain_names=['steffann.nl'])
     self.parse_option()
Beispiel #7
0
    def __init__(self, domain_names: Iterable[str], always_send: bool = False):
        option = SIPServersDomainNameListOption(domain_names=domain_names)
        option.validate()

        super().__init__(option, always_send=always_send)
Beispiel #8
0
    def __init__(self, domain_names: [str]):
        option = SIPServersDomainNameListOption(domain_names=domain_names)
        option.validate()

        super().__init__(option)
Beispiel #9
0
    def __init__(self, domain_names: Iterable[str], always_send: bool = False):
        option = SIPServersDomainNameListOption(domain_names=domain_names)
        option.validate()

        super().__init__(option, always_send=always_send)