def test_v4_hooks_flexid_replace_client_id_renew_2(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'flex-id', '\'docsis3.0\'') srv_control.add_line('"host-reservation-identifiers": ["hw-address", "flex-id" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') srv_control.add_parameter_to_hook('1', 'replace-client-id', 'true') # enable matching client id srv_control.set_conf_parameter_global('match-client-id', 'true') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # server should act normally, mac address should not be replaced misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') # Client adds to the message vendor_class_id with value docsis3.0. 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', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '61') srv_msg.response_check_include_option('Response', None, '54') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases4.csv', 'NOT ', 'ff:01:02:03:ff:04:11:22:33') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases4.csv', None, '192.168.50.10,ff:01:02:03:ff:04,00:64:6f:63:73:69:73:33:2e:30,4000')
def test_v4_hooks_flexid_inside_pool_negative(): 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('hostname', 'reserved-hostname', '0', 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10') srv_control.add_line('"host-reservation-identifiers": [ "flex-id" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() # Client adds to the message vendor_class_id with value docsis3.0. srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.1') 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, 'NAK')
def test_v4_hooks_flexid_inside_pool_negative(): 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('hostname', 'reserved-hostname', 0, 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '192.168.50.10') srv_control.add_line({"host-reservation-identifiers": ["flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'option[60].hex') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') srv_msg.response_check_content('yiaddr', '192.168.50.10') misc.test_procedure() # Client adds to the message vendor_class_id with value docsis3.0. srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.1') 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', 'NAK')
def test_v4_hooks_flexid_replace_client_id_renew_2(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') srv_control.host_reservation_in_subnet('ip-address', '192.168.50.10', 0, 'flex-id', '\'docsis3.0\'') srv_control.add_line( {"host-reservation-identifiers": ["hw-address", "flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'option[60].hex') srv_control.add_parameter_to_hook(1, 'replace-client-id', True) # enable matching client id srv_control.set_conf_parameter_global('match-client-id', True) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') # server should act normally, mac address should not be replaced misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') srv_msg.response_check_content('yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') # Client adds to the message vendor_class_id with value docsis3.0. 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') srv_msg.response_check_content('yiaddr', '192.168.50.10', expected=False) srv_msg.response_check_include_option(61) srv_msg.response_check_include_option(54) srv_msg.lease_file_doesnt_contain('ff:01:02:03:ff:04:11:22:33') srv_msg.lease_file_contains( '192.168.50.10,ff:01:02:03:ff:04,00:64:6f:63:73:69:73:33:2e:30,4000')
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_v6_host_reservation_conflicts_two_entries_for_one_host_different_subnets(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.config_srv_another_subnet_no_interface('3001::/30', '3001::1-3001::10') srv_control.host_reservation_in_subnet('address', '3000::1', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('address', '3000::3', '1', 'hw-address', 'f6:f5:f4:f3:f2:01') 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') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
def test_v4_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_address_2(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.2') srv_control.host_reservation_in_subnet('address', '192.168.50.2', '0', 'hw-address', 'ff:01:02:03:ff:11') 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:11') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:11') 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.2') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.3') srv_control.host_reservation_in_subnet('address', '192.168.50.2', '0', 'hw-address', 'ff:01:02:03:ff:77') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:77') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.2')
def test_v6_hooks_flexid_3(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', 0, 'flex-id', '01:02:03:04:05:06') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '3000::f') srv_control.add_line({"host-reservation-identifiers": ["duid", "flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'vendor[4491].option[1026].hex') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', 'vendor-class') srv_msg.add_vendor_suboption('Client', 1026, '01:02:03:04:05:06') srv_msg.client_does_include('Client', 'vendor-specific-info') 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(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
def test_v4_host_reservation_circuit_id_negative(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'circuit-id', '060106020603') # "host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ] srv_control.add_line('"host-reservation-identifiers": [ "hw-address", "duid", "client-id" ]') 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_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('relay_agent_Information', '16616263') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.10')
def test_v6_host_reservation_duid_hostname_without_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.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, '39') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'reserved-hostname.')
def test_v4_host_reservation_one_address_inside_pool_different_mac(): misc.test_setup() # request address from different mac that has been reserved 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', 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:01') 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.10', expected=False) 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'NAK') srv_msg.response_check_content('yiaddr', '0.0.0.0')
def test_v4_host_reservation_one_address_outside_pool(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.50') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '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_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') 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_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.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v4_host_reservation_conflicts_mysql_reconfigure_server_with_reservation_of_used_address_2(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.2') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:11') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.2', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:11') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:11') 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.2') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.3') srv_control.host_reservation_in_subnet('address', '192.168.50.2', '0', 'hw-address', 'ff:01:02:03:ff:77') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:77') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.2')
def test_v4_host_reservation_circuit_id_negative(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'circuit-id', '060106020603') # "host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ] srv_control.add_line( '"host-reservation-identifiers": [ "hw-address", "duid", "client-id" ]' ) 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_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('relay_agent_Information', '16616263') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.10')
def test_v4_host_reservation_client_id_negative(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.host_reservation_in_subnet('ip-address', '192.168.50.10', 0, 'client-id', 'ff:01:02:03:ff:11:22') # "host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ] srv_control.add_line( {"host-reservation-identifiers": ["circuit-id", "duid", "hw-address"]}) 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_does_include_with_value('client_id', 'ff:01:02:03:ff:04:33:44') 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', 'ff:01:02:03:ff:11') srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:11:22') 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.10', expected=False)
def test_v4_host_reservation_pgsql_one_address_outside_pool_dual_backend_2(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.50') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('next_server', '1.1.1.1', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.host_reservation_in_subnet('address', '192.168.50.11', '0', 'hw-address', 'ff:01:02:03:ff:03') 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_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') 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_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.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') 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_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') 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')
def test_v6_host_reservation_conflicts_two_entries_for_one_host_different_subnets( ): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.config_srv_prefix('2001:db8:1::', '0', '32', '34') srv_control.config_srv_another_subnet_no_interface('3001::/30', '3001::1-3001::10') srv_control.host_reservation_in_subnet('prefix', '2001:db8:1:0:4000::/34', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('address', '3000::3', '1', 'hw-address', 'f6:f5:f4:f3:f2:01') 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, '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') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26')
def test_v4_host_reservation_pgsql_one_address_outside_pool_dual_backend(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.50') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, 'PostgreSQL', 1) srv_control.upload_db_reservation('PostgreSQL') srv_control.host_reservation_in_subnet('ip-address', '192.168.50.11', 0, 'hw-address', 'ff:01:02:03:ff:03') 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') 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_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_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') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') 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.11') 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.11') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') 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')
def test_v6_host_reservation_duid_requesting_reserved_prefix_outside_the_pool( ): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::10') srv_control.host_reservation_in_subnet('prefix', '2001:db8:1::/90', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') 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:66:55:44:33:22:11') srv_msg.client_does_include('Client', 'IA-PD') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_does_include('Client', 'IA-PD') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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(25) srv_msg.response_check_option_content(25, 'sub-option', 13) srv_msg.response_check_suboption_content(13, 25, 'statuscode', 6) srv_msg.response_check_include_option(3, expect_include=False) 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_does_include('Client', 'IA-PD') 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.response_check_include_option(25) srv_msg.response_check_option_content(25, 'sub-option', 26) srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:1::') srv_msg.response_check_include_option(3, expect_include=False)
def test_v6_host_reservation_duid_prefix_not_requested(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::10') srv_control.host_reservation_in_subnet('prefix', '3000::/90', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') 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:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '25', None, 'statuscode', '6') srv_msg.response_check_include_option('Response', 'NOT ', '3') 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_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', 'NOT ', '25') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
def test_v6_host_reservation_mac_requesting_reserved_address_outside_the_pool( ): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::10') srv_control.host_reservation_in_subnet('ip-address', '3000::ff', 0, 'hw-address', 'f6:f5:f4:f3:f2:01') 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:66:55:44:33:22:11') 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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::ff', expect_include=False) 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.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::ff')
def test_v4_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_address_2( ): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.2') srv_control.host_reservation_in_subnet('address', '192.168.50.2', '0', 'hw-address', 'ff:01:02:03:ff:11') 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:11') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:11') 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.2') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.3') srv_control.host_reservation_in_subnet('address', '192.168.50.2', '0', 'hw-address', 'ff:01:02:03:ff:77') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:77') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.2')
def test_v6_host_reservation_mac_requesting_reserved_prefix_outside(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::10') srv_control.host_reservation_in_subnet('prefix', '3011::/90', '0', 'hw-address', 'f6:f5:f4:f3:f2:01') 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:66:55:44:33:22:11') 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_does_include('Client', None, 'IA-PD') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '25', None, 'statuscode', '6') srv_msg.response_check_include_option('Response', 'NOT ', '3') 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_does_include('Client', None, 'IA-PD') 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', 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, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') srv_msg.response_check_suboption_content('Response', '26', '25', None, 'prefix', '3011::') srv_msg.response_check_include_option('Response', 'NOT ', '3')
def test_v4_host_reservation_conflicts_duplicate_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('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet('address', '192.168.50.12', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv_during_process('DHCP', 'configuration')
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_duplicate_reservation(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.host_reservation_in_subnet('address', '3000::1', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('address', '3000::2', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv_during_process('DHCP', 'configuration')
def test_v4_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_address_3(): misc.test_setup() # reconfigure different address for same MAC from outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.9') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') 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', None, 'OFFER') misc.test_procedure() srv_msg.client_copy_option('server_id') 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.10') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.9') srv_control.host_reservation_in_subnet('address', '192.168.50.30', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'reconfigured') 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', None, '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_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.30')
def test_v4_host_reservation_conflicts_duplicate_reservations_different_subnets( ): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.config_srv_another_subnet_no_interface( '192.168.51.0/24', '192.168.51.1-192.168.51.50') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet('address', '192.168.50.12', '1', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'started')
def test_v4_hooks_flexid_replace_mac_addr_inside_pool(): 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('address', '192.168.50.10', '0', 'flex-id', '\'docsis3.0\'') srv_control.add_line('"host-reservation-identifiers": ["hw-address", "flex-id" ]') srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') srv_control.add_parameter_to_hook('1', 'replace-client-id', 'true') srv_control.set_conf_parameter_global('match-client-id', 'false') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # server should act normally, mac address should not be replaced misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.10') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.lease_file_contains('192.168.50.10,ff:01:02:03:ff:04,,4000') srv_msg.lease_file_contains('192.168.50.10,ff:01:02:03:ff:04,,0')
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_conflicts_reconfigure_server_with_reservation_of_used_address_3( ): misc.test_setup() # reconfigure different address for same MAC from outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.9') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') 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', None, 'OFFER') misc.test_procedure() srv_msg.client_copy_option('server_id') 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.10') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.9') srv_control.host_reservation_in_subnet('address', '192.168.50.30', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'reconfigured') 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', None, '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_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.30')
def test_v4_hooks_flexid_reconfigure(): 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('hostname', 'reserved-hostname', 0, 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '192.168.50.10') srv_control.add_line({"host-reservation-identifiers": ["flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'option[60].hex') srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') srv_msg.response_check_content('yiaddr', '192.168.50.10') 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('hostname', 'reserved-hostname', 0, 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '192.168.50.10') srv_control.add_line({"host-reservation-identifiers": ["flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'option[60].hex') srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'reconfigured') srv_msg.wait_for_message_count_in_log(1, 'DHCP4_DYNAMIC_RECONFIGURATION') srv_msg.wait_for_message_count_in_log(2, 'DHCP4_CONFIG_COMPLETE') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') srv_msg.response_check_content('yiaddr', '192.168.50.10')
def test_v6_host_reservation_all_values_mac(): 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.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '3000::100') srv_control.host_reservation_in_subnet_add_value(0, 0, 'prefixes', '3001::/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() 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_control_channel_socket_config_test(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') # To global section of the config add file line: "expired-leases-processing":{"flush-reclaimed-timer-wait-time": 0,"hold-reclaimed-time": 0,"max-reclaim-leases": 100,"max-reclaim-time": 0,"reclaim-timer-wait-time": 0,"unwarned-reclaim-cycles": 5} # To global section of the config add file line: "expired-leases-processing":{"flush-reclaimed-timer-wait-time": 0,"hold-reclaimed-time": 0,"max-reclaim-leases": 100,"max-reclaim-time": 0,"reclaim-timer-wait-time": 0,"unwarned-reclaim-cycles": 5} srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.config_srv_prefix('2001:db8:1::', '0', '90', '96') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', r'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') srv_control.host_reservation_in_subnet('address', '3000::1', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.generate_config_files() # Sleep for 10 seconds. srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "config-test","arguments": $(SERVER_CONFIG) }') # should be ok misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.config_srv_prefix('2001:db8:1::', '0', '90', '96') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', r'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') # WRONG ADDRESS RESERVATION srv_control.host_reservation_in_subnet('address', '192.168.0.5', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.generate_config_files() # srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "config-test","arguments": $(SERVER_CONFIG) }')
def test_v4_host_reservation_one_address_empty_pool(): misc.test_setup() # request address from different mac that has been reserved srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.host_reservation_in_subnet('ip-address', '192.168.50.10', 0, 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message()
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_host_reservation_conflicts_duplicate_reservations_different_subnets(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.config_srv_another_subnet_no_interface('192.168.51.0/24', '192.168.51.1-192.168.51.50') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.host_reservation_in_subnet('address', '192.168.50.12', '1', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'started')
def test_control_channel_socket_config_test(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.open_control_channel() # To global section of the config add file line: "expired-leases-processing":{"flush-reclaimed-timer-wait-time": 0,"hold-reclaimed-time": 0,"max-reclaim-leases": 100,"max-reclaim-time": 0,"reclaim-timer-wait-time": 0,"unwarned-reclaim-cycles": 5} # To global section of the config add file line: "expired-leases-processing":{"flush-reclaimed-timer-wait-time": 0,"hold-reclaimed-time": 0,"max-reclaim-leases": 100,"max-reclaim-time": 0,"reclaim-timer-wait-time": 0,"unwarned-reclaim-cycles": 5} srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.config_srv_prefix('2001:db8:1::', 0, 90, 96) srv_control.open_control_channel('control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', 'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') srv_control.host_reservation_in_subnet('ip-address', '3000::1', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.generate_config_files() # Sleep for 10 seconds. srv_msg.send_ctrl_cmd_via_socket( '{"command": "config-test","arguments": $(DHCP_CONFIG) }') # should be ok misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') srv_control.config_srv_prefix('2001:db8:1::', 0, 90, 96) srv_control.open_control_channel('control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', 'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') # WRONG ADDRESS RESERVATION srv_control.host_reservation_in_subnet('ip-address', '192.168.0.5', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.generate_config_files() # srv_msg.send_ctrl_cmd_via_socket( '{"command": "config-test","arguments": $(DHCP_CONFIG) }', exp_result=1)
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_one_address_empty_pool(): misc.test_setup() # request address from different mac that has been reserved srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'hw-address', 'ff:01:02:03:ff:04') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message()
def test_v6_host_reservation_pgsql_hwaddrr_matching_dual_backend(): 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:11') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.host_reservation_in_subnet('address', '3000::fff', '0', 'hw-address', 'f6:f5:f4:f3:f2:22') 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:11') 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') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') 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_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', '3000::fff')
def test_v4_all_hooks_start(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') # flex id srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', '0', 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10') srv_control.add_line( '"host-reservation-identifiers": [ "flex-id","hw-address" ]') srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') # legal log srv_control.add_hooks('libdhcp_legal_log.so') srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.add_hooks('libdhcp_stat_cmds.so') srv_control.add_hooks('libdhcp_subnet_cmds.so') srv_control.add_hooks('libdhcp_host_cache.so') 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', '"load-balancing"') 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( 'peers', '{"name":"server1","url":"http://$(MGMT_ADDRESS):8080/","role":"primary","auto-failover":true}' ) srv_control.add_parameter_to_ha_hook( 'peers', '{"name":"server2","url":"http://$(MGMT_ADDRESS_2):8080/","role":"secondary","auto-failover":true}' ) srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket( '{"command": "list-commands","arguments": {}}')
def test_v4_host_reservation_duid(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.host_reservation_in_subnet('address', '192.168.50.10', '0', 'duid', '04:33:44') # "host-reservation-identifiers": [ "hw-address", "duid", "circuit-id", "client-id" ] srv_control.add_line('"host-reservation-identifiers": [ "duid" ]') 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_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:33:44') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:33:44') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v4_host_reservation_conflicts_reconfigure_server_switched_mac_in_reservations_out_of_pool(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.30') srv_control.host_reservation_in_subnet('address', '192.168.50.50', '0', 'hw-address', 'ff:01:02:03:ff:04') 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', None, 'OFFER') misc.test_procedure() srv_msg.client_copy_option('server_id') 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.50') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.30') srv_control.host_reservation_in_subnet('address', '192.168.50.50', '0', 'hw-address', 'ff:01:02:03:ff:01') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.50')
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_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_v6_host_reservation_conflicts_two_entries_for_one_host_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.config_srv_prefix('2001:db8:1::', '0', '32', '34') srv_control.host_reservation_in_subnet('prefix', '2001:db8:1:0:4000::/34', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('hostname', 'xyz', '0', 'hw-address', 'f6:f5:f4:f3:f2:01') 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, '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_dont_wait_for_message() # We could check logs for: "more than one reservation found for the host belonging" misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:33:22:11') 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') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26')
def test_v4_all_hooks_start(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') # flex id srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', '0', 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10') srv_control.add_line('"host-reservation-identifiers": [ "flex-id","hw-address" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') # legal log srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_legal_log.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_stat_cmds.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cache.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_lease_cmds.so') srv_control.add_ha_hook('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_ha.so') srv_control.add_parameter_to_ha_hook('this-server-name', '"server1"') srv_control.add_parameter_to_ha_hook('mode', '"load-balancing"') 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('peers', '{"name":"server1","url":"http://$(MGMT_ADDRESS):8080/","role":"primary","auto-failover":true}') srv_control.add_parameter_to_ha_hook('peers', '{"name":"server2","url":"http://$(MGMT_ADDRESS_2):8080/","role":"secondary","auto-failover":true}') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "list-commands","arguments": {}}')
def test_v4_hooks_flexid_libreload(): 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('hostname', 'reserved-hostname', '0', 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10') srv_control.add_line('"host-reservation-identifiers": [ "flex-id" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') srv_control.open_control_channel('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_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "libreload","arguments": {}}') # if reload works - classification should work without changes misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')
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_v6_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_address_renew_before_expire(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') 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:66:55:44:33:22:11') 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', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') 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', 'DUID', '00:03:00:01:66:55:44:33:22:22') 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') # SAVE VALUES srv_msg.client_save_option('IA_NA') 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') 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') # bigger prefix pool + reservation misc.test_setup() srv_control.set_time('renew-timer', '105') srv_control.set_time('rebind-timer', '106') srv_control.set_time('valid-lifetime', '107') srv_control.set_time('preferred-lifetime', '108') srv_control.config_srv_subnet('3000::/30', '3000::1-3000::3') srv_control.host_reservation_in_subnet('address', '3000::2', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_add_saved_option('DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('RENEW') 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, 'validlft', '0') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::2') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'validlft', '107') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::3') 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_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::2')
def test_v4_all_hooks_test_cooperation(): srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.10') # flex id srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname', '0', 'flex-id', '\'docsis3.0\'') srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10') srv_control.add_line('"host-reservation-identifiers": [ "flex-id","hw-address" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') # legal log srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_legal_log.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_lease_cmds.so') # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so. # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_stat_cmds.so. # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so. # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cache.so. # # Add High-Availability hook library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_ha.so. # To HA hook configuration add this-server-name with value: "server1" # To HA hook configuration add mode with value: "load-balancing" # To HA hook configuration add heartbeat-delay with value: 1000 # To HA hook configuration add max-response-delay with value: 1001 # To HA hook configuration add max-unacked-clients with value: 0 # To HA hook configuration add max-ack-delay with value: 0 # # To HA hook configuration add peers with value: {"name":"server1","url":"http://$(MGMT_ADDRESS):8080/","role":"primary","auto-failover":true} # To HA hook configuration add peers with value: {"name":"server2","url":"http://$(MGMT_ADDRESS_2):8080/","role":"secondary","auto-failover":true} srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.agent_control_channel('$(MGMT_ADDRESS)', '8080', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # Using UNIX socket on server in path $(SOFTWARE_INSTALL_DIR)/var/kea/control_socket send {"command": "list-commands","arguments": {}} # JSON response in arguments MUST include value: build-report # JSON response in arguments MUST include value: cache-clear # JSON response in arguments MUST include value: cache-flush # JSON response in arguments MUST include value: cache-get # JSON response in arguments MUST include value: cache-insert # JSON response in arguments MUST include value: cache-load # JSON response in arguments MUST include value: cache-remove # JSON response in arguments MUST include value: cache-write # JSON response in arguments MUST include value: config-get # JSON response in arguments MUST include value: config-reload # JSON response in arguments MUST include value: config-set # JSON response in arguments MUST include value: config-test # JSON response in arguments MUST include value: config-write # JSON response in arguments MUST include value: dhcp-disable # JSON response in arguments MUST include value: dhcp-enable # JSON response in arguments MUST include value: ha-continue # JSON response in arguments MUST include value: ha-heartbeat # JSON response in arguments MUST include value: ha-scopes # JSON response in arguments MUST include value: ha-sync # JSON response in arguments MUST include value: lease4-add # JSON response in arguments MUST include value: lease4-del # JSON response in arguments MUST include value: lease4-get # JSON response in arguments MUST include value: lease4-get-all # JSON response in arguments MUST include value: lease4-get-page # JSON response in arguments MUST include value: lease4-update # JSON response in arguments MUST include value: lease4-wipe # JSON response in arguments MUST include value: lease6-add # JSON response in arguments MUST include value: lease6-del # JSON response in arguments MUST include value: lease6-get # JSON response in arguments MUST include value: lease6-get-all # JSON response in arguments MUST include value: lease6-get-page # JSON response in arguments MUST include value: lease6-update # JSON response in arguments MUST include value: lease6-wipe # JSON response in arguments MUST include value: leases-reclaim # JSON response in arguments MUST include value: libreload # JSON response in arguments MUST include value: list-commands # JSON response in arguments MUST include value: network4-add # JSON response in arguments MUST include value: network4-del # JSON response in arguments MUST include value: network4-get # JSON response in arguments MUST include value: network4-list # JSON response in arguments MUST include value: network4-subnet-add # JSON response in arguments MUST include value: network4-subnet-del # JSON response in arguments MUST include value: network6-add # JSON response in arguments MUST include value: network6-del # JSON response in arguments MUST include value: network6-get # JSON response in arguments MUST include value: network6-list # JSON response in arguments MUST include value: network6-subnet-add # JSON response in arguments MUST include value: network6-subnet-del # JSON response in arguments MUST include value: reservation-add # JSON response in arguments MUST include value: reservation-del # JSON response in arguments MUST include value: reservation-get # JSON response in arguments MUST include value: shutdown # JSON response in arguments MUST include value: stat-lease4-get # JSON response in arguments MUST include value: stat-lease6-get # JSON response in arguments MUST include value: statistic-get # JSON response in arguments MUST include value: statistic-get-all # JSON response in arguments MUST include value: statistic-remove # JSON response in arguments MUST include value: statistic-remove-all # JSON response in arguments MUST include value: statistic-reset # JSON response in arguments MUST include value: statistic-reset-all # JSON response in arguments MUST include value: subnet4-add # JSON response in arguments MUST include value: subnet4-del # JSON response in arguments MUST include value: subnet4-get # JSON response in arguments MUST include value: subnet4-list # JSON response in arguments MUST include value: subnet6-add # JSON response in arguments MUST include value: subnet6-del # JSON response in arguments MUST include value: subnet6-get # JSON response in arguments MUST include value: subnet6-list # JSON response in arguments MUST include value: version-get # ha command # Using existing HTTP $(MGMT_ADDRESS):8080 connection send: {"command": "ha-heartbeat","service":["dhcp4"],"arguments": {} } # JSON response in arguments MUST include value: "state": "partner-down" # flex-id misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') # legal log misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('client_id', '00010203040506') 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_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '54') srv_msg.response_check_include_option('Response', None, '61') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') 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_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '54') srv_msg.response_check_include_option('Response', None, '61') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506') srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt', None, 'Address: 192.168.50.1 has been assigned for 1 hrs 6 mins 40') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt', None, 'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client-id: 00:01:02:03:04:05:06') # lease commands srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"lease4-add","arguments":{"ip-address": "192.168.50.10","hostname": "newhostname.example.org","hw-address": "1a:1b:1c:1d:1e:1f","subnet-id":1,"valid-lft":500000}}') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt', None, 'Administrator added a lease of address: 192.168.50.10 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 5 days 18 hrs 53 mins 20 secs') # # Test Procedure: # Client sets chaddr value to 1a:1b:1c:1d:1e:1f. # Client sets ciaddr value to 192.168.50.10. # Client copies server_id option from received message. # Client sends REQUEST message. # # Pass Criteria: # Server MUST respond with ACK message. # Response MUST contain yiaddr 192.168.50.10. # Response MUST include option 54. # Response option 54 MUST contain value $(SRV4_ADDR). srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
def test_v6_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_address(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') 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:66:55:44:33:22:11') 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:66:55:44:33:22:11') 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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') 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:66:55:44:33:22:22') 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') # bigger prefix pool + reservation misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.host_reservation_in_subnet('address', '3000::1', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') 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_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::1')
def test_control_channel_keashell_test_config(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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, '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', '3000::1') misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.config_srv_prefix('2001:db8:1::', '0', '90', '96') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', r'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') srv_control.host_reservation_in_subnet('address', '3000::1', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') 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 dhcp6 config-test <<<\'$(SERVER_CONFIG)\'') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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, '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', '3000::1') misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.config_srv_prefix('2001:db8:1::', '0', '90', '96') srv_control.agent_control_channel('$(SRV4_ADDR)', '8000', 'unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket_ANOTHER_ONE') srv_control.config_srv_id('LLT', '00:01:00:02:52:7b:a8:f0:08:00:27:58:f1:e8') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('new-posix-timezone', r'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00') # WRONG ADDRESS RESERVATION srv_control.host_reservation_in_subnet('address', '192.168.0.5', '0', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') 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 dhcp6 config-test <<<\'$(SERVER_CONFIG)\'') srv_msg.forge_sleep('5', 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') 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, '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', '3000::1')