def test_ddns6_logging_all_types_debug(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'abc.com') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.configure_loggers('kea-dhcp-ddns', 'DEBUG', '99') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count('1', 'IA_NA') srv_msg.client_save_option_count('1', 'server-id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'flags', 'S') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'sth6.six.example.com.') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.log_contains(r'INFO \[kea-dhcp-ddns.dhcpddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcpddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.libdhcp-ddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.d2-to-dns') srv_msg.log_contains(r'ERROR \[kea-dhcp-ddns.d2-to-dns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcp-to-d2')
def test_v4_host_reservation_hostname_hostname_option(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.30') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.30') srv_msg.client_does_include_with_value('hostname', 'some-name') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_include_option(12) srv_msg.response_check_option_content(12, 'value', 'reserved-name.my.domain.com')
def test_ddns6_subnet(): misc.test_setup() # simple case, ddns configuration in subnet - get and addres and dns entry srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True, "ddns-generated-prefix": "abc", "ddns-qualifying-suffix": "example.com"}) srv_control.shared_subnet('2001:db8:a::/64', 0) srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0) srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0) srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.start_srv('DNS', 'started', config_set=31) _get_address_and_update_ddns(duid='00:03:00:01:ff:ff:ff:ff:ff:01', fqdn='sth6.six.example.com.', address='2001:db8:a::1', arpa='1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.')
def test_ddns4_logging_all_types_debug(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'abc.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.configure_loggers('kea-dhcp-ddns', 'DEBUG', 99) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count(1, 'server_id') srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.log_contains(r'INFO \[kea-dhcp-ddns.dhcpddns', 'kea.log_ddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcpddns', 'kea.log_ddns') # srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.libdhcp-ddns', 'kea.log_ddns') # TODO: it is not present in the log srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.d2-to-dns', 'kea.log_ddns') srv_msg.log_contains(r'ERROR \[kea-dhcp-ddns.d2-to-dns', 'kea.log_ddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcp-to-d2', 'kea.log_ddns')
def test_ddns6_notsig_forw_and_rev_release_fqdn_sanitization_replace_2(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_ddns_server_options('hostname-char-set', '[^A-Za-z]') srv_control.add_ddns_server_options('hostname-char-replacement', 'x') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count('1', 'IA_NA') srv_msg.client_save_option_count('1', 'server-id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', '*a$(WHITE_SPACE).8723()+.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'flags', 'S') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'xax.xxxxxxx.') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'FQDN_domain_name', '*a$(WHITE_SPACE).8723()+.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2')
def test_v6_host_reservation_all_values_duid_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.config_srv_prefix('2001:db8:1::', '0', '32', '33') srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '3000::100') srv_control.host_reservation_in_subnet_add_value('0', '0', 'prefix', '2001:db8:1::/40') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', 'NOT ', 'addr', '3000::100') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') srv_msg.response_check_suboption_content('Response', '26', '25', 'NOT ', 'prefix', '2001:db8:1::') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', 'NOT ', 'fqdn', 'reserved-hostname.my.domain.com.')
def test_v6_host_reservation_mysql_all_values_duid(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_prefix_db_backend_reservation('3001::', 40, '$(EMPTY)', 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'IA-PD') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::100') srv_msg.response_check_include_option(25) srv_msg.response_check_option_content(25, 'sub-option', 26) srv_msg.response_check_suboption_content(26, 25, 'prefix', '3001::') srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_v6_host_reservation_mysql_all_values_duid_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.config_srv_prefix('3001::', '0', '32', '33') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'MySQL', '1') srv_control.ipv6_prefix_db_backend_reservation('3001::', '40', '$(EMPTY)', 'MySQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') srv_msg.response_check_suboption_content('Response', '26', '25', None, 'prefix', '3001::') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_ddns6_all_levels_resend_without_ddns(): misc.test_setup() srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1') world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True, "ddns-generated-prefix": "six", "ddns-qualifying-suffix": "example.com"}) srv_control.shared_subnet('2001:db8:a::/64', 0) srv_control.shared_subnet('2001:db8:b::/64', 0) srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0) srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0) srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.start_srv('DNS', 'started', config_set=31) _get_address_and_update_ddns(duid='00:03:00:01:ff:ff:ff:ff:ff:01', fqdn='sth6.six.example.com.', address='2001:db8:a::1', arpa='1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.') _get_address(duid='00:03:00:01:ff:ff:ff:ff:ff:02', fqdn=None) _check_fqdn_record("some.abc.example.com.", expect='empty') # stop bind, remove data files, start bind with empty zones srv_control.start_srv('DNS', 'stopped') srv_control.clear_some_data('all', service='DNS') srv_control.start_srv('DNS', 'started', config_set=31) # check is all records were removed _check_fqdn_record("sth6.six.example.com.", expect='empty') _check_fqdn_record("some.abc.example.com.", expect='empty') _check_fqdn_record("record.xyz.example.com.", expect='empty') response = _resend_ddns('2001:db8:b::1', exp_result=1) assert response["text"] == 'Lease for: 2001:db8:b::1, has no hostname, nothing to update' response = _resend_ddns('2001:db8:a::1', exp_result=0) assert response["text"] == "NCR generated for: 2001:db8:a::1, hostname: sth6.six.example.com." _check_fqdn_record("sth6.six.example.com.", address='2001:db8:a::1') _check_address_record("sth6.six.example.com.", '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.') _check_fqdn_record("some.abc.example.com.", expect='empty')
def test_v4_host_reservation_hostname_duplicated_entries(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.30') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet('hostname', 'resderved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv_during_process('DHCP', 'configuration')
def test_v4_host_reservation_hostname_fqdn_option(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.30') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'reserved-name.my.domain.com.') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.30') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'reserved-name.my.domain.com.')
def test_v4_host_reservation_hostname_multiple_entries(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.30') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet('hostname', 'resderved-name', 0, 'hw-address', 'ff:01:02:03:ff:44') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started')
def test_v6_host_reservation_mac_hostname_with_ddns(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', '0', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_v4_host_reservation_hostname_hostname_option_and_address_3(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.30') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.5') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep('2', 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') # Client adds to the message hostname with value some-name. srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.5') srv_msg.client_does_include_with_value('hostname', 'some-name') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.5') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'value', 'reserved-name.my.domain.com')
def test_ddns6_global(): misc.test_setup() # simple case, global ddns configuration - get and addres and dns entry srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') world.dhcp_cfg.update({"ddns-send-updates": True, "ddns-generated-prefix": "six", "ddns-qualifying-suffix": "example.com"}) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.start_srv('DNS', 'started', config_set=31) _get_address_and_update_ddns(duid='00:03:00:01:ff:ff:ff:ff:ff:01', fqdn='sth6.six.example.com.', address='2001:db8:a::1', arpa='1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.')
def test_ddns6_control_channel_config_write(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.ddns_open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict( command='config-write', arguments={"filename": world.f_cfg.data_join("new_kea_config_file")}) _send_through_ddns_socket(cmd) srv_msg.copy_remote(world.f_cfg.data_join("new_kea_config_file")) # let's load json from downloaded file and check if it is the same what we configured kea with with open(os.path.join(world.cfg["test_result_dir"], 'downloaded_file'), 'r') as f: downloaded_config = json.load(f) del downloaded_config["DhcpDdns"]["loggers"] del world.ddns_cfg["DhcpDdns"]["loggers"] assert downloaded_config == world.ddns_cfg
def test_v6_host_reservation_duid_hostname_with_ddns(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_ddns4_logging_all_types_debug(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'abc.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.configure_loggers('kea-dhcp-ddns', 'DEBUG', '99', 'kea.log') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count('1', 'server_id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'flags', '1') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'INFO \[kea-dhcp-ddns.dhcpddns') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'DEBUG \[kea-dhcp-ddns.dhcpddns') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'DEBUG \[kea-dhcp-ddns.libdhcp-ddns') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'DEBUG \[kea-dhcp-ddns.d2-to-dns') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'ERROR \[kea-dhcp-ddns.d2-to-dns') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, r'DEBUG \[kea-dhcp-ddns.dhcp-to-d2')
def test_ddns6_control_channel_config_reload(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') # minimal ddns srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.ddns_open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict(command='config-get', arguments={}) cfg = _send_through_ddns_socket(cmd) del cfg["arguments"]["DhcpDdns"]["loggers"] del world.ddns_cfg["DhcpDdns"]["loggers"] assert cfg["arguments"] == world.ddns_cfg misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.ddns_open_control_channel() srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() cmd = dict(command='config-reload', arguments={}) _send_through_ddns_socket(cmd) cmd = dict(command='config-get', arguments={}) cfg = _send_through_ddns_socket(cmd) del cfg["arguments"]["DhcpDdns"]["loggers"] del world.ddns_cfg["DhcpDdns"]["loggers"] assert cfg["arguments"] == world.ddns_cfg srv_control.use_dns_set_number(3) srv_control.start_srv('DNS', 'started') _check_if_ddns_is_working_correctly()
def test_ddns6_control_channel_config_test(): # let's check minimal configuration misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') # minimal ddns srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.ddns_open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict(command='config-get', arguments={}) response = _send_through_ddns_socket(cmd) cfg = response["arguments"] cmd = dict(command='config-test', arguments=cfg) _send_through_ddns_socket(cmd) srv_control.start_srv('DHCP', 'stopped') # let's check if returned configuration is correct misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.ddns_open_control_channel() srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict(command='config-get', arguments={}) response = _send_through_ddns_socket(cmd) cfg = response["arguments"] cmd = dict(command='config-test', arguments=cfg) _send_through_ddns_socket(cmd) # and now let's make couple incorrect configs cfg = { "DhcpDdns": { "dns-server-timeout": 100, "forward-ddns": { "ddns-domains": [{ "dns-servers": [{ "hostname": "", "ip-address": "2001:db8:1::1000", "port": "an" }], "key-name": "forge.sha1.key", "name": "six.example.com." }] }, "ip-address": "127.0.0.1", "ncr-format": "JSON", "ncr-protocol": "UDP", "port": 53001, "reverse-ddns": { "ddns-domains": [{ "dns-servers": [{ "hostname": "", "ip-address": "2001:db8:1::1000", "port": 53 }], "key-name": "forge.sha1.key", "name": "1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa." }] }, "tsig-keys": [{ "algorithm": "HMAC-SHA1", "digest-bits": 0, "name": "forge.sha1.key", "secret": "PN4xKZ/jDobCMlo4rpr70w==" }] } } cmd = dict(command='config-test', arguments=cfg) _send_through_ddns_socket(cmd, exp_result=1) cfg = { "DhcpDdns": { "dns-server-timeout": 100, "forward-ddns": { "ddns-domains": [{ "dns-servers": [], "key-name": "forge.sha1.key", "name": "six.example.com." }] }, "ip-address": "127.0.0.1", "ncr-protocol": "UDP", "port": 53001, } } cmd = dict(command='config-test', arguments=cfg) _send_through_ddns_socket(cmd, exp_result=1) cfg = { "DhcpDdns": { "dns-server-timeout": 100, "forward-ddns": {}, "ip-address": "127.0.0.1", "ncr-format": "ABC", "ncr-protocol": "UDP", "port": 53001, "reverse-ddns": {} } } cmd = dict(command='config-test', arguments=cfg) _send_through_ddns_socket(cmd, exp_result=1) # and now check if all those tests didn't change kea running configuration srv_control.use_dns_set_number(3) srv_control.start_srv('DNS', 'started') _check_if_ddns_is_working_correctly()
def test_ddns6_notsig_expired_fqdn_sanitization(): misc.test_setup() srv_control.set_time('renew-timer', '1') srv_control.set_time('rebind-timer', '2') srv_control.set_time('preferred-lifetime', '3') srv_control.set_time('valid-lifetime', '4') srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_ddns_server_options('hostname-char-set', '[^A-Za-z.-]') srv_control.add_ddns_server_options('hostname-char-replacement', '$(EMPTY)') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('1') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'flags', 'S') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'sth.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '2001:db8:1::50') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'sth.six.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.') srv_msg.forge_sleep('15', 'seconds') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_control_channel_lease4_get_by(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.6') srv_control.config_srv_another_subnet_no_interface( '192.168.51.0/24', '192.168.51.10-192.168.51.11') world.dhcp_cfg.update({"ddns-send-updates": False}) world.dhcp_cfg["subnet4"][1].update({"ddns-send-updates": False}) world.dhcp_cfg["subnet4"][0].update({ "ddns-send-updates": True, "ddns-generated-prefix": "four", "ddns-qualifying-suffix": "example.com" }) srv_control.shared_subnet('192.168.50.0/24', 0) srv_control.shared_subnet('192.168.51.0/24', 0) srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0) srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0) srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.open_control_channel() srv_control.add_ddns_server('127.0.0.1', 53001) srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') _get_address("08:08:08:08:08:08", "192.168.50.5", cli_id="00010203040506", fqdn="four.hostname.com.") _get_address("09:09:09:09:09:09", "192.168.50.6", cli_id="00010203040507") _get_address("10:10:10:10:10:10", "192.168.51.10") _get_address("11:11:11:11:11:11", "192.168.51.11", fqdn="xyz.com.") # let's get 08:08:08:08:08:08 for in a different ways by_id_1 = _send_cmd("lease4-get-by-client-id", extra_param={"client-id": "00010203040506"}) del by_id_1["arguments"]["leases"][0]["cltt"] assert by_id_1["arguments"]["leases"][0] == { "fqdn-fwd": True, "fqdn-rev": True, "client-id": "00:01:02:03:04:05:06", "hostname": "four.hostname.com.", "hw-address": "08:08:08:08:08:08", "ip-address": "192.168.50.5", "state": 0, "subnet-id": 1, "valid-lft": 4000 } by_host_1 = _send_cmd("lease4-get-by-hostname", extra_param={"hostname": "four.hostname.com."}) del by_host_1["arguments"]["leases"][0]["cltt"] assert by_host_1["arguments"]["leases"][0] == { "fqdn-fwd": True, "fqdn-rev": True, "client-id": "00:01:02:03:04:05:06", "hostname": "four.hostname.com.", "hw-address": "08:08:08:08:08:08", "ip-address": "192.168.50.5", "state": 0, "subnet-id": 1, "valid-lft": 4000 } by_hw_1 = _send_cmd("lease4-get-by-hw-address", extra_param={"hw-address": "08:08:08:08:08:08"}) del by_hw_1["arguments"]["leases"][0]["cltt"] assert by_hw_1["arguments"]["leases"][0] == { "fqdn-fwd": True, "fqdn-rev": True, "client-id": "00:01:02:03:04:05:06", "hostname": "four.hostname.com.", "hw-address": "08:08:08:08:08:08", "ip-address": "192.168.50.5", "state": 0, "subnet-id": 1, "valid-lft": 4000 } # let's get 09:09:09:09:09:09 for in a different ways by_id_1 = _send_cmd("lease4-get-by-client-id", extra_param={"client-id": "00010203040507"}) del by_id_1["arguments"]["leases"][0]["cltt"] assert by_id_1["arguments"]["leases"][0] == { "fqdn-fwd": False, "fqdn-rev": False, "client-id": "00:01:02:03:04:05:07", "hw-address": "09:09:09:09:09:09", "ip-address": "192.168.50.6", "hostname": "", "state": 0, "subnet-id": 1, "valid-lft": 4000 } by_hw_1 = _send_cmd("lease4-get-by-hw-address", extra_param={"hw-address": "09:09:09:09:09:09"}) del by_hw_1["arguments"]["leases"][0]["cltt"] assert by_hw_1["arguments"]["leases"][0] == { "fqdn-fwd": False, "fqdn-rev": False, "client-id": "00:01:02:03:04:05:07", "hw-address": "09:09:09:09:09:09", "ip-address": "192.168.50.6", "hostname": "", "state": 0, "subnet-id": 1, "valid-lft": 4000 } # let's get 11:11:11:11:11:11 for in a different ways # THOSE TWO ARE FAILING by_host_1 = _send_cmd("lease4-get-by-hostname", extra_param={"hostname": "xyz.com."}) del by_host_1["arguments"]["leases"][0]["cltt"] assert by_host_1["arguments"]["leases"][0] == { "fqdn-fwd": False, "fqdn-rev": False, # "client-id": "", #TODO I think it should be added "hostname": "xyz.com.", "hw-address": "11:11:11:11:11:11", "ip-address": "192.168.51.11", "state": 0, "subnet-id": 2, "valid-lft": 4000 } by_hw_1 = _send_cmd("lease4-get-by-hw-address", extra_param={"hw-address": "11:11:11:11:11:11"}) del by_hw_1["arguments"]["leases"][0]["cltt"] assert by_hw_1["arguments"]["leases"][0] == { "fqdn-fwd": False, "fqdn-rev": False, # "client-id": "", #TODO I think it should be added "hostname": "xyz.com.", "hw-address": "11:11:11:11:11:11", "ip-address": "192.168.51.11", "state": 0, "subnet-id": 2, "valid-lft": 4000 } by_hw_1 = _send_cmd("lease4-get-by-hw-address", extra_param={"hw-address": "10:10:10:10:10:10"}) del by_hw_1["arguments"]["leases"][0]["cltt"] assert by_hw_1["arguments"]["leases"][0] == { "fqdn-fwd": False, "fqdn-rev": False, # "client-id": "", #TODO I think it should be added "hw-address": "10:10:10:10:10:10", "ip-address": "192.168.51.10", "hostname": "", "state": 0, "subnet-id": 2, "valid-lft": 4000 } _send_cmd("lease4-get-by-hw-address", extra_param={"hw-address": "11:11:12:12:13:13"}, exp_result=3) _send_cmd("lease4-get-by-hostname", extra_param={"hostname": "abc.com."}, exp_result=3) _send_cmd("lease4-get-by-client-id", extra_param={"client-id": "111111111111"}, exp_result=3) _send_cmd("lease4-get-by-hw-address", exp_result=1) _send_cmd("lease4-get-by-hostname", exp_result=1) _send_cmd("lease4-get-by-client-id", exp_result=1)
def test_control_channel_keashell_test_config(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.agent_control_channel('127.0.0.1', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.5') srv_control.generate_config_files() srv_msg.execute_shell_with_args('python', '$(SOFTWARE_INSTALL_DIR)/sbin/kea-shell', '--host 127.0.0.1 --port 8000 --service dhcp4 config-test <<<\'$(SERVER_CONFIG)\'') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '3000::1') srv_control.generate_config_files() srv_msg.execute_shell_with_args('python', '$(SOFTWARE_INSTALL_DIR)/sbin/kea-shell', '--host 127.0.0.1 --port 8000 --service dhcp4 config-set <<<\'$(SERVER_CONFIG)\'') srv_msg.forge_sleep('$(SLEEP_TIME_2)', 'seconds') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_ddns4_notsig_forw_and_rev_dhci_conflicts_Sflag(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.11') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(20) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'client1.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'client1.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'client1.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'client1.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') # Client 2 add misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.11') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'client2.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.11') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'client2.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.11') srv_msg.dns_option_content('ANSWER', 'rrname', 'client2.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'client2.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '11.50.168.192.in-addr.arpa.') # Client 2 try to update client's 1 domain misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.11') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'client1.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.11') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'client1.four.example.com.') # address and domain name should not be changed! misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'client1.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'client1.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False)
def test_control_channel_keashell_test_config(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.open_control_channel() srv_control.agent_control_channel('127.0.0.1') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '192.168.50.5') srv_control.generate_config_files() srv_msg.execute_kea_shell('--host 127.0.0.1 --port 8000 --service dhcp4 config-test <<<\'$(DHCP_CONFIG)\'') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '3000::1') srv_control.generate_config_files() srv_msg.execute_kea_shell('--host 127.0.0.1 --port 8000 --service dhcp4 config-set <<<\'$(DHCP_CONFIG)\'') srv_msg.forge_sleep('$(SLEEP_TIME_2)', 'seconds') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
def test_ddns4_tsig_multi_key_forw_and_rev(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.md5.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha512.key') srv_control.add_keys('forge.sha512.key', 'HMAC-SHA512', 'jBng5D6QL4f8cfLUUwE7OQ==') srv_control.add_keys('forge.md5.key', 'HMAC-MD5', 'bX3Hs+fG/tThidQPuhK1mA==') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('27') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'flags', '1') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.')
def test_ddns4_all_levels_lease4_del_with_dns(): misc.test_setup() srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.config_srv_another_subnet_no_interface('192.168.51.0/24', '192.168.51.10-192.168.51.10') srv_control.config_srv_another_subnet_no_interface('192.168.52.0/24', '192.168.52.10-192.168.52.10') # let's get 3 different ddns settings, global, shared-network and subnet. world.dhcp_cfg.update({"ddns-send-updates": True, "ddns-generated-prefix": "six", "ddns-qualifying-suffix": "example.com"}) world.dhcp_cfg["subnet4"][1].update({"ddns-send-updates": True, "ddns-generated-prefix": "abc", "ddns-qualifying-suffix": "example.com"}) srv_control.shared_subnet('192.168.50.0/24', 0) srv_control.shared_subnet('192.168.51.0/24', 0) srv_control.shared_subnet('192.168.52.0/24', 0) srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0) srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0) world.dhcp_cfg["shared-networks"][0].update({"ddns-send-updates": True, "ddns-generated-prefix": "xyz", "ddns-qualifying-suffix": "example.com"}) # kea-ddns config srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_forward_ddns('five.example.com.', 'EMPTY_KEY') srv_control.add_forward_ddns('three.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.add_reverse_ddns('51.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.add_reverse_ddns('52.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.start_srv('DNS', 'started', config_set=32) # let's get 3 different leases with DNS record _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:01', fqdn='sth4.four.example.com.', address='192.168.50.10', arpa='10.50.168.192.in-addr.arpa.') _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:02', fqdn='some.five.example.com.', address='192.168.51.10', arpa='10.51.168.192.in-addr.arpa.') _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:03', fqdn='record.three.example.com.', address='192.168.52.10', arpa='10.52.168.192.in-addr.arpa.') # remove all leases using lease4-del with removing ddns entry resp = _delete_lease(extra_param={"ip-address": "192.168.50.10", "update-ddns": True}, exp_result=0) assert resp["text"] == "IPv4 lease deleted." resp = _delete_lease(extra_param={"ip-address": "192.168.51.10", "update-ddns": True}, exp_result=0) assert resp["text"] == "IPv4 lease deleted." resp = _delete_lease(extra_param={"ip-address": "192.168.52.10", "update-ddns": True}, exp_result=0) assert resp["text"] == "IPv4 lease deleted." # check if DNS record was indeed removed _check_fqdn_record("sth4.four.example.com.", expect='empty') _check_fqdn_record("some.five.example.com.", expect='empty') _check_fqdn_record("record.three.example.com.", expect='empty') _check_address_record("sth4.four.example.com.", expect='empty') _check_address_record("some.five.example.com.", expect='empty') _check_address_record("record.three.example.com.", expect='empty') # try to add back by resending ddns, all should fail _resend_ddns('192.168.51.10', exp_result=3) _resend_ddns('192.168.50.10', exp_result=3) _resend_ddns('192.168.52.10', exp_result=3) _check_fqdn_record("sth4.four.example.com.", expect='empty') _check_fqdn_record("some.five.example.com.", expect='empty') _check_fqdn_record("record.three.example.com.", expect='empty') _check_address_record("sth4.four.example.com.", expect='empty') _check_address_record("some.five.example.com.", expect='empty') _check_address_record("record.three.example.com.", expect='empty')
def test_ddns6_notsig_forw_and_rev_release(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(1) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count(1, 'IA_NA') srv_msg.client_save_option_count(1, 'server-id') srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'flags', 'S') srv_msg.response_check_option_content(39, 'fqdn', 'sth6.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '2001:db8:1::50') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'sth6.six.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False)
def test_v6_host_reservation_pgsql_all_values_mac(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_prefix_db_backend_reservation('3001::', '40', '$(EMPTY)', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::101', '$(EMPTY)', 'PostgreSQL', '1') srv_control.option_db_record_reservation('32', '10', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '666') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_requests_option('32') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') srv_msg.response_check_suboption_content('Response', '26', '25', None, 'prefix', '3001::') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'reserved-hostname.my.domain.com.') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '777') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_requests_option('32') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', 'NOT ', 'addr', '3000::100')
def test_ddns4_notsig_rev_withoutflag_notenabled(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', False) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(20) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) # Response option 81 MUST contain flags 0. #later make it 's' 'n' and 'o' should be 10 srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False)
def test_ddns4_notsig_forw_and_rev_add_fail_hostname(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('20') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_does_include_with_value('hostname', 'aa.four.exae.com') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'value', 'aa.four.exae.com') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_ddns6_tsig_sha1_rev_release(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('3') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count('1', 'IA_NA') srv_msg.client_save_option_count('1', 'server-id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'S') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'N') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'O') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'sth6.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'sth6.six.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_ddns4_notsig_rev_Nflag_override_no_update(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('override-no-update', 'true') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('20') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'FQDN_flags', 'N') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'flags', '3') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com.', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'aa.four.example.com.')
def test_ddns4_tsig_sha224_forw_and_rev(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha224.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha224.key') srv_control.add_keys('forge.sha224.key', 'HMAC-SHA224', 'TxAiO5TRKkFyHSCa4erQZQ==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(22) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_include_option(81) srv_msg.response_check_option_content(81, 'flags', 1) srv_msg.response_check_option_content(81, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', 'rrname', '10.50.168.192.in-addr.arpa.')
def test_ddns4_tsig_sha1_rev_release(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('21') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_save_option_count('1', 'server_id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.client_save_option('server_id') srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_ddns4_notsig_forw_and_rev_dhci_conflicts_hostname(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.11') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('20') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_does_include_with_value('hostname', 'client1.four.example.com') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'value', 'client1.four.example.com') misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'client1.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'client1.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.') # Client 2 add misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_requests_option('1') srv_msg.client_does_include_with_value('hostname', 'client2.four.example.com') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'value', 'client2.four.example.com') misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.11') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'client2.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'client2.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '11.50.168.192.in-addr.arpa.') # Client 2 try to update client's 1 domain misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:12') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_does_include_with_value('hostname', 'client1.four.example.com') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'value', 'client1.four.example.com') # address and domain name should not be changed! misc.test_procedure() srv_msg.dns_question_record('client1.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'client1.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'client1.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.') misc.test_procedure() srv_msg.dns_question_record('client2.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record('11.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_ddns6_tsig_multi_key_forw_and_rev(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'forge.md5.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha512.key') srv_control.add_keys('forge.sha512.key', 'HMAC-SHA512', 'jBng5D6QL4f8cfLUUwE7OQ==') srv_control.add_keys('forge.md5.key', 'HMAC-MD5', 'bX3Hs+fG/tThidQPuhK1mA==') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(9) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'flags', 'S') srv_msg.response_check_option_content(39, 'fqdn', 'sth6.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '2001:db8:1::50') misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'sth6.six.example.com.') srv_msg.dns_option_content( 'ANSWER', 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.' )
def test_control_channel_http_test_config(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.open_control_channel() srv_control.agent_control_channel('$(SRV4_ADDR)') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '192.168.50.5') srv_control.generate_config_files() response = srv_msg.send_ctrl_cmd_via_http('{"command": "config-test","service": ["dhcp4"],' ' "arguments": $(DHCP_CONFIG) }', '$(SRV4_ADDR)', exp_result=1) assert "specified reservation '192.168.50.5' is not within the IPv4 subnet '192.168.51.0/24'" in response[0]['text'] misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '3000::1') srv_control.generate_config_files() response = srv_msg.send_ctrl_cmd_via_http('{"command": "config-test","service": ["dhcp4"],' ' "arguments": $(DHCP_CONFIG) }', '$(SRV4_ADDR)', exp_result=1) assert "address '3000::1' is not a valid IPv4 address" in response[0]['text'] misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
def test_ddns6_tsig_sha1_rev_release(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('3') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count('1', 'IA_NA') srv_msg.client_save_option_count('1', 'server-id') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'S') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'N') srv_msg.response_check_option_content('Response', '39', "NOT", 'flags', 'O') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'sth6.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'sth6.six.example.com.') srv_msg.dns_option_content( 'ANSWER', None, 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count('1', 'DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') misc.test_procedure() srv_msg.dns_question_record('sth6.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER')
def test_ddns6_control_channel_config_set_all_values(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('six.example.com.', 'forge.sha1.key') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'forge.sha1.key') srv_control.add_keys('forge.sha1.key', 'HMAC-SHA1', 'PN4xKZ/jDobCMlo4rpr70w==') srv_control.ddns_open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict(command='config-get', arguments={}) response = _send_through_ddns_socket(cmd) cfg = response["arguments"] tmp_cfg = world.ddns_cfg # let's ignore logging, it's added in Dhcp part and for now common, # that will have to be fixed in 1.7 del cfg["DhcpDdns"]["loggers"] del world.ddns_cfg["DhcpDdns"]["loggers"] assert cfg == world.ddns_cfg # now let's try to set configuration we received # first let's stop everything and start empty DDNS server with just control channel: # (DHCP and DDNS are combined for now) srv_control.start_srv('DHCP', 'stopped') misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') # new socket name srv_control.ddns_open_control_channel( socket_name="different_ddns_control_socket") srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') cmd = dict(command='config-set', arguments=cfg) # send to the new socket, config will change this socket to ddns_control_socket _send_through_ddns_socket(cmd, socket_name="different_ddns_control_socket") srv_control.use_dns_set_number(3) srv_control.start_srv('DNS', 'started') _check_if_ddns_is_working_correctly() # send to old socket, it should fail: cmd = dict(command='config-get', arguments={}) _send_through_ddns_socket(cmd, socket_name="different_ddns_control_socket", exp_failed=True) # send to the new socket, should work, and it should be the same configuration as previously # previously we removed logging from config, so new ddns configuration is without logging seciotn cmd = dict(command='config-get', arguments={}) response = _send_through_ddns_socket(cmd) cfg = response["arguments"] assert cfg == tmp_cfg
def test_control_channel_lease6_get_by(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::5-2001:db8:a::6') srv_control.config_srv_prefix('2000::', 0, 90, 96) srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64', '2001:db8:b::10-2001:db8:b::11') srv_control.config_srv_prefix('2001::', 1, 90, 96) world.dhcp_cfg.update({"ddns-send-updates": False}) world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True, "ddns-generated-prefix": "six", "ddns-qualifying-suffix": "example.com"}) world.dhcp_cfg["subnet6"][1].update({"ddns-send-updates": False}) srv_control.shared_subnet('2001:db8:a::/64', 0) srv_control.shared_subnet('2001:db8:b::/64', 0) srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0) srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0) srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.open_control_channel() srv_control.add_ddns_server('127.0.0.1', 53001) srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') _get_address("00:03:00:01:08:08:08:08:08:08", "2001:db8:a::5", ia_id=5, fqdn="six.hostname.com.") _get_address("00:03:00:01:09:09:09:09:09:09", "2001:db8:a::6", ia_pd=1, ia_id=6) _get_address("00:03:00:01:10:10:10:10:10:10", "2001:db8:b::10", ia_id=10) _get_address("00:03:00:01:11:11:11:11:11:11", "2001:db8:b::11", fqdn="xyz.com.", ia_id=11, expected_flag='ON') by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:08:08:08:08:08:08"}) del by_id_1["arguments"]["leases"][0]["cltt"] assert by_id_1["arguments"]["leases"][0] == {"fqdn-fwd": True, "fqdn-rev": True, "hw-address": "08:08:08:08:08:08", "hostname": "six.hostname.com.", "duid": "00:03:00:01:08:08:08:08:08:08", "ip-address": "2001:db8:a::5", "iaid": 5, "preferred-lft": 3000, "type": "IA_NA", "state": 0, "subnet-id": 1, "valid-lft": 4000} by_host_1 = _send_cmd("lease6-get-by-hostname", extra_param={"hostname": "six.hostname.com."}) del by_host_1["arguments"]["leases"][0]["cltt"] assert by_host_1["arguments"]["leases"][0] == {"fqdn-fwd": True, "fqdn-rev": True, "hw-address": "08:08:08:08:08:08", "hostname": "six.hostname.com.", "duid": "00:03:00:01:08:08:08:08:08:08", "ip-address": "2001:db8:a::5", "iaid": 5, "preferred-lft": 3000, "type": "IA_NA", "state": 0, "subnet-id": 1, "valid-lft": 4000} by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:09:09:09:09:09:09"}) assert len(by_id_1["arguments"]["leases"]) == 2 for lease in by_id_1["arguments"]["leases"]: del lease["cltt"] for lease in by_id_1["arguments"]["leases"]: if lease["ip-address"] == "2001:db8:a::6": assert lease == {"fqdn-fwd": False, "fqdn-rev": False, "duid": "00:03:00:01:09:09:09:09:09:09", "ip-address": "2001:db8:a::6", "hostname": "", "hw-address": "09:09:09:09:09:09", "state": 0, "subnet-id": 1, "iaid": 6, "preferred-lft": 3000, "type": "IA_NA", "valid-lft": 4000} elif lease["ip-address"] == "2000::": assert lease == {"duid": "00:03:00:01:09:09:09:09:09:09", "fqdn-fwd": False, "fqdn-rev": False, "hostname": "", "hw-address": "09:09:09:09:09:09", "iaid": 1, "ip-address": "2000::", "preferred-lft": 3000, "prefix-len": 96, "state": 0, "subnet-id": 1, "type": "IA_PD", "valid-lft": 4000} by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:11:11:11:11:11:11"}) del by_id_1["arguments"]["leases"][0]["cltt"] assert by_id_1["arguments"]["leases"][0] == {"fqdn-fwd": False, "fqdn-rev": False, "hw-address": "11:11:11:11:11:11", "hostname": "xyz.com.", "duid": "00:03:00:01:11:11:11:11:11:11", "ip-address": "2001:db8:b::11", "iaid": 11, "preferred-lft": 3000, "type": "IA_NA", "state": 0, "subnet-id": 2, "valid-lft": 4000} _send_cmd("lease6-get-by-hostname", extra_param={"hostname": "abc.com."}, exp_result=3) _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:12:12:12:11:11:11"}, exp_result=3) _send_cmd("lease6-get-by-hostname", exp_result=1) _send_cmd("lease6-get-by-duid", exp_result=1)
def test_control_channel_http_test_config(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.5') srv_control.generate_config_files() srv_msg.send_through_http('$(SRV4_ADDR)', '8000', '{"command": "config-test","service": ["dhcp4"], "arguments": $(SERVER_CONFIG) }') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.host_reservation_in_subnet('hostname', 'reserved-name', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '3000::1') srv_control.generate_config_files() srv_msg.send_through_http('$(SRV4_ADDR)', '8000', '{"command": "config-test","service": ["dhcp4"], "arguments": $(SERVER_CONFIG) }') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')