def test_bad_ipv6_prefix_length(self): S46V4V6BindingOption.parse(bytes.fromhex('005c001d010203048020010db8000000000000000000000000ffff0000fffe0000')) with self.assertRaisesRegex(ValueError, 'range from 0 to 128'): S46V4V6BindingOption.parse( bytes.fromhex('005c001f010203048120010db80000000000000000000000000000ffff0000fffe0000') )
def test_bad_option_length(self): with self.assertRaisesRegex(ValueError, 'shorter than the minimum length'): S46V4V6BindingOption.parse( bytes.fromhex('005c0001010203042020010db8ffff0000fffe0000')) with self.assertRaisesRegex(ValueError, 'length does not match'): S46V4V6BindingOption.parse( bytes.fromhex('005c0010010203042020010db8ffff0000fffe0000'))
def test_bad_ipv6_prefix_length(self): S46V4V6BindingOption.parse( bytes.fromhex( '005c001d010203048020010db8000000000000000000000000ffff0000fffe0000' )) with self.assertRaisesRegex(ValueError, 'range from 0 to 128'): S46V4V6BindingOption.parse( bytes.fromhex( '005c001f010203048120010db80000000000000000000000000000ffff0000fffe0000' ))
'0006' # option_length '21' # prefix_len '20010db800') # 2001:db8::1 s46_dmr_option_object = S46DMROption(dmr_prefix=IPv6Network('2001:db8::/33')) # S46V4V6BindingOption s46_v4_v6_binding_option_bytes = ( bytes.fromhex('005c' # option_type: OPTION_S46_V4V6BIND '0012' # option_length '01020304' # ipv4_address '22' # ipv6_prefix_len '20010db800') # ipv6_prefix + s46_port_parameters_option_bytes) s46_v4_v6_binding_option_object = S46V4V6BindingOption( ipv4_address=IPv4Address('1.2.3.4'), ipv6_prefix=IPv6Network('2001:db8::/34'), options=[s46_port_parameters_option_object]) class S46RuleOptionTestCase(test_option.OptionTestCase): def setUp(self): self.option_bytes = s46_rule_option_bytes self.option_object = s46_rule_option_object self.parse_option() def test_flags(self): self.option.flags = 0 self.assertFalse(self.option.fmr) self.assertEqual(self.option.flags, 0) self.option.fmr = True
def test_bad_option_length(self): with self.assertRaisesRegex(ValueError, 'shorter than the minimum length'): S46V4V6BindingOption.parse(bytes.fromhex('005c0001010203042020010db8ffff0000fffe0000')) with self.assertRaisesRegex(ValueError, 'length does not match'): S46V4V6BindingOption.parse(bytes.fromhex('005c0010010203042020010db8ffff0000fffe0000'))