def test_v6_mac_in_dhcp6_docsis_modem(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.run_command('"mac-sources": [ "docsis-modem" ]') 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('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', None, 'vendor-class') srv_msg.add_vendor_suboption('Client', '36', 'f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'vendor-specific-info') 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.lease_file_contains(',f6:f5:f4:f3:f2:01') srv_msg.log_contains('Hardware addr: f6:f5:f4:f3:f2:01')
def test_v6_mac_in_dhcp6_client_link_addr_1(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"mac-sources": ["client-link-addr-option"]}) 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-link-layer-addr') 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_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') srv_msg.client_does_include('RelayAgent', 'client-link-layer-addr') srv_msg.client_sets_value('RelayAgent', 'peeraddr', '$(CLI_LINK_LOCAL)') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.lease_file_contains(',$(CLI_MAC)') srv_msg.log_contains('Hardware addr: $(CLI_MAC)')
def test_v6_mac_in_dhcp6_docsic_cmts(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"mac-sources": ["docsis-cmts"]}) 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_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') srv_msg.client_sets_value('RelayAgent', 'enterprisenum', '4491') srv_msg.client_does_include('RelayAgent', 'vendor-class') srv_msg.add_vendor_suboption('RelayAgent', 1026, '00:f5:f4:00:f2:01') srv_msg.client_does_include('RelayAgent', 'vendor-specific-info') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.lease_file_contains(',00:f5:f4:00:f2:01') srv_msg.log_contains('Hardware addr: 00:f5:f4:00:f2:01')
def test_v6_mac_in_dhcp6_subscriber_id_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"mac-sources": ["rfc4580"]}) 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_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') srv_msg.client_sets_value('RelayAgent', 'subscriber_id', '0a0027000002') srv_msg.client_does_include('RelayAgent', 'subscriber-id') srv_msg.client_sets_value('RelayAgent', 'peeraddr', 'fe80::800:27ff:fe00:2') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.lease_file_contains(',0a:00:27:00:00:02') srv_msg.log_contains('Hardware addr: 0a:00:27:00:00:02')
def test_v6_mac_in_dhcp6_any(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"mac-sources": ["any"]}) 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_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.lease_file_contains(',f6:f5:f4:f3:f2:01') srv_msg.log_contains('Hardware addr: f6:f5:f4:f3:f2:01')
def test_v6_mac_in_dhcp6_duid_type1(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"mac-sources": ["duid"]}) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:55:2b:fa:0c:08:00:27:58:f1:e8') 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_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:08:00:27:58:f1:e8') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_requests_option(7) 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.lease_file_contains(',08:00:27:58:f1:e8') srv_msg.log_contains('Hardware addr: 08:00:27:58:f1:e8')
def test_v4_loggers_bad_packets_debug(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.configure_loggers('kea-dhcp4.bad-packets', 'DEBUG', '99') 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_requests_option('2') srv_msg.client_requests_option('7') 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') srv_msg.client_requests_option('1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'NAK') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.bad-packets')
def test_user_check_IA_NA_with_registry_unknown_user_logging(): # With a user registry and multiple subnets # an unknown user should get last subnet misc.test_setup() srv_msg.send_file_to_server( 'tests/dhcpv4/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.5') srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') srv_control.add_hooks('libdhcp_user_chk.so') srv_control.configure_loggers('kea-dhcp4.callouts', 'DEBUG', 99) srv_control.configure_loggers('kea-dhcp4.hooks', 'INFO', 'None') 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_sets_value('Client', 'chaddr', '0c:0e:0a:01:ff:01') 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', '10.0.0.5') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv4/kea_only/user_chk/outcome_1.txt') srv_msg.log_contains(r'INFO \[kea-dhcp4.hooks') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.callouts')
def test_v6_mac_in_dhcp6_ipv6_link_local(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.run_command('"mac-sources": [ "ipv6-link-local" ]') 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('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_requests_option('7') 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.lease_file_contains(',$(CLI_MAC)') srv_msg.log_contains('Hardware addr: $(CLI_MAC)')
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_v4_loggers_dhcpsrv_info(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.configure_loggers('kea-dhcp4.dhcpsrv', 'INFO', 'None') 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_requests_option('2') srv_msg.client_requests_option('7') 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option('1') 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.1') 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_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') 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.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcpsrv') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcpsrv')
def test_v6_loggers_all_different_levels_same_file(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.configure_loggers('kea-dhcp6.dhcp6', 'INFO', 'None') srv_control.configure_loggers('kea-dhcp6.dhcpsrv', 'INFO', 'None') srv_control.configure_loggers('kea-dhcp6.options', 'DEBUG', 99) srv_control.configure_loggers('kea-dhcp6.packets', 'DEBUG', 99) srv_control.configure_loggers('kea-dhcp6.leases', 'WARN', 'None') srv_control.configure_loggers('kea-dhcp6.alloc-engine', 'DEBUG', 50) srv_control.configure_loggers('kea-dhcp6.bad-packets', 'DEBUG', 25) srv_control.configure_loggers('kea-dhcp6.options', 'INFO', 'None') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() 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) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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') misc.test_procedure() srv_msg.client_requests_option(7) # message wont contain client-id option srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.send_dont_wait_for_message() srv_msg.log_contains(r'DEBUG \[kea-dhcp6.packets') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp6.leases') srv_msg.log_contains(r'DEBUG \[kea-dhcp6.alloc-engine') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp6.dhcp6') srv_msg.log_contains(r'INFO \[kea-dhcp6.dhcp6') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp6.dhcpsrv') srv_msg.log_contains(r'INFO \[kea-dhcp6.dhcpsrv') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp6.options')
def test_v4_loggers_options_debug(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.configure_loggers('kea-dhcp4.options', 'DEBUG', 99) srv_control.config_srv_opt('time-offset', '50') 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_requests_option(2) srv_msg.client_requests_option(7) 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) 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.1') 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_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') 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.log_contains(r'DEBUG \[kea-dhcp4.options')
def test_v6_loggers_bad_packets_debug(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.configure_loggers('kea-dhcp6.bad-packets', 'DEBUG', 99) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() # message wont contain client-id option srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.send_dont_wait_for_message() srv_msg.log_contains(r'DEBUG \[kea-dhcp6.bad-packets')
def test_v6_host_reservation_conflicts_duplicate_duid_reservations(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.host_reservation_in_subnet( 'ip-address', '3000::1', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') # the same DUID srv_control.host_reservation_in_subnet( 'ip-address', '3000::2', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') # the same DUID srv_control.build_and_send_config_files() srv_control.start_srv_during_process('DHCP', 'configuration') # expected error logs srv_msg.log_contains(r'ERROR \[kea-dhcp6.dhcp6') srv_msg.log_contains(r'failed to add new host using the DUID')
def test_v4_decline_fail_without_requested_ip_address(): # See: https://www.ietf.org/rfc/rfc2131.txt, page 37 misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') 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.1') # send DECLINE without requested IP address - it should be dropped misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_sets_value('Client', 'ciaddr', '0.0.0.0') srv_msg.client_copy_option('server_id') srv_msg.client_send_msg('DECLINE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # if it is dropped by the server then this log should not appear srv_msg.log_doesnt_contain(r'The lease will be unavailable for') # and this one should appear srv_msg.log_contains( r"failed to process packet: Mandatory 'Requested IP address' option missing in DHCPDECLINE" )
def test_v4_decline_fail_different_client_id(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(61, 'value', '00010203040111') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_does_include_with_value('client_id', '00010203040111') 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.1') srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(61, 'value', '00010203040111') # set different client ID (00010203040666) than it was sent in previous packets (00010203040111) misc.test_procedure() srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_does_include_with_value('client_id', '00010203040666') srv_msg.client_sets_value('Client', 'ciaddr', '0.0.0.0') srv_msg.client_copy_option('server_id') srv_msg.client_send_msg('DECLINE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # the server should say that client IDs do not match srv_msg.log_contains( r"Received DHCPDECLINE for addr 192.168.50.1.*but the data doesn't match:" )
def test_v4_host_reservation_conflicts_duplicate_mac_reservations(backend): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') if backend == 'memfile': srv_control.host_reservation_in_subnet( 'ip-address', '192.168.50.10', 0, 'hw-address', 'ff:01:02:03:ff:04') # the same MAC address srv_control.host_reservation_in_subnet( 'ip-address', '192.168.50.12', 0, 'hw-address', 'ff:01:02:03:ff:04') # the same MAC address srv_control.build_and_send_config_files() srv_control.start_srv_during_process('DHCP', 'configuration') # expected error logs srv_msg.log_contains(r'ERROR \[kea-dhcp4.dhcp4') srv_msg.log_contains(r'failed to add new host using the HW address') else: srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.open_control_channel() srv_control.dump_db_reservation(backend) srv_control.new_db_backend_reservation(backend, 'hw-address', 'ff:01:02:03:ff:11') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', backend, 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.2', backend, 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, backend, 1) srv_control.new_db_backend_reservation(backend, 'hw-address', 'ff:01:02:03:ff:11') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', backend, 2) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.3', backend, 2) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, backend, 2) # expect failure due to db constrain on unique hw-address srv_control.upload_db_reservation(backend, exp_failed=True)
def test_v6_loggers_dhcp6_info(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.configure_loggers('kea-dhcp6.dhcp6', 'INFO', 'None') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() 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) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') misc.test_procedure() srv_msg.client_requests_option(7) 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.log_doesnt_contain(r'DEBUG \[kea-dhcp6.dhcp6') srv_msg.log_contains(r'INFO \[kea-dhcp6.dhcp6')
def test_v4_host_reservation_conflicts_duplicate_ip_reservations(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.host_reservation_in_subnet( 'ip-address', '192.168.50.10', # the same IP address 0, 'hw-address', 'aa:aa:aa:aa:aa:aa') srv_control.host_reservation_in_subnet( 'ip-address', '192.168.50.10', # the same IP address 0, 'hw-address', 'bb:bb:bb:bb:bb:bb') srv_control.build_and_send_config_files() srv_control.start_srv_during_process('DHCP', 'configuration') # expected error logs srv_msg.log_contains(r'ERROR \[kea-dhcp4.dhcp4') srv_msg.log_contains(r'failed to add new host using the HW address')
def test_user_check_hook_IA_NA_with_registry_unknown_user_logging(): # With a user registry and multiple subnets # an unknown user should get last subnet misc.test_setup() srv_msg.send_file_to_server( 'tests/dhcpv6/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('3000::/64', '3000::5-3000::5') srv_control.config_srv_another_subnet_no_interface('1000::/64', '1000::5-1000::5') srv_control.add_hooks('libdhcp_user_chk.so') srv_control.configure_loggers('kea-dhcp6.callouts', 'DEBUG', '99') srv_control.configure_loggers('kea-dhcp6.hooks', 'INFO', 'None') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() # Send a query from an unregistered user 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_Address') 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') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '1000::5') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv6/kea_only/user_chk/outcome_1.txt') srv_msg.log_contains(r'INFO \[kea-dhcp6.hooks') srv_msg.log_contains(r'DEBUG \[kea-dhcp6.callouts')
def test_v6_loggers_hosts_debug(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.configure_loggers('kea-dhcp6.hosts', 'DEBUG', '99') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() 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') 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('IA_NA') srv_msg.client_copy_option('server-id') 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') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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.log_contains(r'DEBUG \[kea-dhcp6.hosts')
def test_v6_host_reservation_conflicts_duplicate_ip_reservations(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.host_reservation_in_subnet( 'ip-address', '3000::1', # the same IP address 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet( 'ip-address', '3000::1', # the same IP address 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_control.build_and_send_config_files() srv_control.start_srv_during_process('DHCP', 'configuration') # expected error logs srv_msg.log_contains(r'ERROR \[kea-dhcp6.dhcp6') srv_msg.log_contains( r'failed to add address reservation for host using the HW address') srv_msg.log_contains( r"There's already reservation for this address/prefix")
def test_v6_sanity_check_subnet_id_del(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 666, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') 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_sets_value('Client', 'ia_id', '1234567') 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) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') # lease should be available via lease6-get resp = srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') assert resp['arguments']['subnet-id'] == 666 # it should be in lease file as well srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_some_data('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 999, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep(2, 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks (the lease should have subnet-id 999) and was dropped.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '7654321') 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) 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', '2001:db8::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') # old lease from subnet-id 666 should not be available while new lease from subnet-id 999 should be resp = srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') assert resp['arguments']['subnet-id'] == 999 # explict query for old lease should return error srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"subnet-id":666,"identifier-type":"duid", "identifier": "00:03:00:01:f6:f5:f4:f3:f2:01"}}', exp_result=3) # old lease should not be present in the lease file # bug: #1618, closed as designed srv_msg.lease_file_doesnt_contain( '2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_doesnt_contain( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') # new one should be in the lease file srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.lease_file_contains( '999,3000,0,7654321,128,0,0,,f6:f5:f4:f3:f2:22,0')
def test_v6_sanity_check_subnet_id_warn(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"warn"}') srv_control.open_control_channel() 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_sets_value('Client', 'ia_id', '1234567') 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') 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_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"warn"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep('2', 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:33') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') 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') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2')
def test_v6_sanity_check_subnet_id_del(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"del"}') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') 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_sets_value('Client', 'ia_id', '1234567') 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') 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_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_leases('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"del"}') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep('2', 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks and was dropped.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '7654321') 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') 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', '2001:db8::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') 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, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"subnet-id":666,"identifier-type":"duid", "identifier": "00:03:00:01:f6:f5:f4:f3:f2:01"}}' ) srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01')
def test_v4_loggers_all_different_levels_different_file(): # it will fail, so I will disable this, issue link: # https://gitlab.isc.org/isc-projects/kea/issues/592 misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_srv_opt('log-servers', '199.199.199.1,100.100.100.1') srv_control.configure_loggers('kea-dhcp4.dhcp4', 'INFO', 'None', 'kea.log1') srv_control.configure_loggers('kea-dhcp4.dhcpsrv', 'INFO', 'None', 'kea.log2') srv_control.configure_loggers('kea-dhcp4.options', 'DEBUG', '99', 'kea.log3') srv_control.configure_loggers('kea-dhcp4.packets', 'DEBUG', '99', 'kea.log4') srv_control.configure_loggers('kea-dhcp4.leases', 'WARN', 'None', 'kea.log5') srv_control.configure_loggers('kea-dhcp4.alloc-engine', 'DEBUG', '50', 'kea.log6') srv_control.configure_loggers('kea-dhcp4.bad-packets', 'DEBUG', '25', 'kea.log7') srv_control.configure_loggers('kea-dhcp4.dhcpsrv', 'INFO', 'None', 'kea.log8') 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_requests_option('2') srv_msg.client_requests_option('7') 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option('1') 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.1') 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_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_requests_option('2') srv_msg.client_requests_option('7') 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') srv_msg.client_requests_option('1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'NAK') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.packets', 'kea.log4') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.leases', 'kea.log5') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.alloc-engine', 'kea.log6') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcp4', 'kea.log1') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcp4', 'kea.log1') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcpsrv', 'kea.log2') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcpsrv', 'kea.log8') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcpsrv', 'kea.log8') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcpsrv', 'kea.log2') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.options', 'kea.log3')
def test_v6_hooks_HA_page_size_sync_2(): # HA SERVER 1 misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::ffff') srv_control.open_control_channel() srv_control.agent_control_channel('$(MGMT_ADDRESS)') srv_control.configure_loggers('kea-dhcp6.dhcpsrv', 'DEBUG', '99') srv_control.configure_loggers('kea-dhcp6.ha-hooks', 'DEBUG', '99') srv_control.configure_loggers('kea-ctrl-agent', 'DEBUG', '99', 'kea.log-CTRL') srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.add_ha_hook('libdhcp_ha.so') srv_control.add_parameter_to_ha_hook('this-server-name', '"server1"') srv_control.add_parameter_to_ha_hook('mode', '"hot-standby"') srv_control.add_parameter_to_ha_hook('heartbeat-delay', '1000') srv_control.add_parameter_to_ha_hook('max-response-delay', '1001') srv_control.add_parameter_to_ha_hook('max-unacked-clients', '0') srv_control.add_parameter_to_ha_hook('max-ack-delay', '0') srv_control.add_parameter_to_ha_hook('sync-page-limit', '10') srv_control.add_parameter_to_ha_hook('peers', '{"name":"server1","url":"http://$(MGMT_ADDRESS):8000/","role":"primary","auto-failover":true}') srv_control.add_parameter_to_ha_hook('peers', '{"name":"server2","url":"http://$(MGMT_ADDRESS_2):8000/","role":"standby","auto-failover":true}') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # HA SERVER 2 misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::ffff') srv_control.open_control_channel() srv_control.agent_control_channel('$(MGMT_ADDRESS_2)') srv_control.configure_loggers('kea-dhcp6.dhcpsrv', 'DEBUG', '99') srv_control.configure_loggers('kea-dhcp6.ha-hooks', 'DEBUG', '99') srv_control.configure_loggers('kea-ctrl-agent', 'DEBUG', '99', 'kea.log-CTRL2') srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.add_ha_hook('libdhcp_ha.so') srv_control.add_parameter_to_ha_hook('this-server-name', '"server2"') srv_control.add_parameter_to_ha_hook('mode', '"hot-standby"') srv_control.add_parameter_to_ha_hook('heartbeat-delay', '1000') srv_control.add_parameter_to_ha_hook('max-response-delay', '1001') srv_control.add_parameter_to_ha_hook('max-unacked-clients', '0') srv_control.add_parameter_to_ha_hook('max-ack-delay', '0') srv_control.add_parameter_to_ha_hook('sync-page-limit', '15') srv_control.add_parameter_to_ha_hook('peers', '{"name":"server1","url":"http://$(MGMT_ADDRESS):8000/","role": "primary","auto-failover":true}') srv_control.add_parameter_to_ha_hook('peers', '{"name":"server2","url":"http://$(MGMT_ADDRESS_2):8000/","role": "standby","auto-failover":true}') srv_control.build_and_send_config_files_dest_addr('SSH', 'config-file', '$(MGMT_ADDRESS_2)') misc.test_procedure() srv_msg.forge_sleep('3', 'seconds') # create leases in HA 1 srv_msg.loops('SOLICIT', 'REPLY', '100') srv_control.remote_start_srv('DHCP', 'started', '$(MGMT_ADDRESS_2)') # sync HA 2 with HA 1 srv_msg.forge_sleep('10', 'seconds') misc.pass_criteria() srv_msg.log_contains('DHCPSRV_MEMFILE_GET_PAGE6 obtaining at most 15 IPv6 leases starting from address 2001:db8:1::5') srv_msg.remote_log_includes_line('$(MGMT_ADDRESS_2)', '$(SOFTWARE_INSTALL_DIR)/var/log/kea.log', None, 'HA_LEASES_SYNC_LEASE_PAGE_RECEIVED received 15 leases from server1') srv_msg.remote_log_includes_line('$(MGMT_ADDRESS_2)', '$(SOFTWARE_INSTALL_DIR)/var/log/kea.log', None, 'DHCPSRV_MEMFILE_GET_ADDR6 obtaining IPv6 lease for address 2001:db8:1::65 and lease type IA_NA') srv_msg.remote_log_includes_line('$(MGMT_ADDRESS_2)', '$(SOFTWARE_INSTALL_DIR)/var/log/kea.log', 'NOT ', 'DHCPSRV_MEMFILE_GET_PAGE6 obtaining at most 10 IPv6 leases starting from address 2001:') srv_msg.log_doesnt_contain('HA_LEASES_SYNC_LEASE_PAGE_RECEIVED received 10 leases from') srv_msg.remote_log_includes_line('$(MGMT_ADDRESS_2)', '$(SOFTWARE_INSTALL_DIR)/var/log/kea.log', None, 'HA_SYNC_SUCCESSFUL lease database synchronization with server1 completed successfully') # stop HA ! srv_control.start_srv('DHCP', 'stopped') misc.test_procedure() srv_msg.forge_sleep('3', 'seconds') # create leases in HA 2 srv_msg.loops('SOLICIT', 'REPLY', '100') srv_control.clear_leases('logs') srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep('10', 'seconds') misc.pass_criteria() srv_msg.log_contains('DHCPSRV_MEMFILE_ADD_ADDR6 adding IPv6 lease with address 2001:db8:1::c9')
def test_v4_loggers_all_different_levels_same_file(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.configure_loggers('kea-dhcp4.dhcp4', 'INFO', 'None') srv_control.configure_loggers('kea-dhcp4.dhcpsrv', 'INFO', 'None') srv_control.configure_loggers('kea-dhcp4.options', 'DEBUG', 99) srv_control.configure_loggers('kea-dhcp4.packets', 'DEBUG', 99) srv_control.configure_loggers('kea-dhcp4.leases', 'WARN', 'None') srv_control.configure_loggers('kea-dhcp4.alloc-engine', 'DEBUG', 50) srv_control.configure_loggers('kea-dhcp4.bad-packets', 'DEBUG', 25) srv_control.configure_loggers('kea-dhcp4.options', 'INFO', 'None') 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_requests_option(2) srv_msg.client_requests_option(7) 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) 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.1') 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_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_requests_option(2) srv_msg.client_requests_option(7) 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_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') srv_msg.client_requests_option(1) srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'NAK') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.packets') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.leases') srv_msg.log_contains(r'DEBUG \[kea-dhcp4.alloc-engine') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcp4') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcp4') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.dhcpsrv') srv_msg.log_contains(r'INFO \[kea-dhcp4.dhcpsrv') srv_msg.log_doesnt_contain(r'DEBUG \[kea-dhcp4.options')
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() 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', '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.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) srv_msg.log_contains(r'INFO \[kea-dhcp-ddns.dhcpddns', log_file='kea.log_ddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcpddns', log_file='kea.log_ddns') # srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.libdhcp-ddns', log_file='kea.log_ddns') # TODO: it is not present in the log srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.d2-to-dns', log_file='kea.log_ddns') srv_msg.log_contains(r'DEBUG \[kea-dhcp-ddns.dhcp-to-d2', log_file='kea.log_ddns')