def test_v6_sanity_check_subnet_id_fix_del_able(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix-del"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix-del"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured')
def test_v4_echo_client_id_enabled(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.set_conf_parameter_global('echo-client-id', True) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(61, 'value', '00010203040506') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(61, 'value', '00010203040506')
def test_v6_options_rsoo_custom_option_list_default_option_65(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.set_conf_parameter_subnet('interface-id', 'abc', 0) srv_control.set_conf_parameter_global('relay-supplied-options', ["12"]) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc') srv_msg.client_sets_value('RelayAgent', 'erpdomain', 'relay-supplied.domain.com') srv_msg.client_does_include('Relay-Supplied-Option', 'erp-local-domain-name') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.client_does_include('RelayAgent', 'rsoo') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.response_check_option_content(9, 'Relayed', 'Message') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_include_option(65) srv_msg.response_check_option_content(65, 'erpdomain', 'relay-supplied.domain.com.') references.references_check('RFC642')
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_echo_client_id_enabled(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.set_conf_parameter_global('echo-client-id', 'true') 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_does_include_with_value('client_id', '00010203040506') 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_include_option('Response', None, '61') 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_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, '61') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')
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_decline_success_short_decline_period(): # address in decline period misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.set_conf_parameter_global('decline-probation-period', 2) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:22') srv_msg.client_does_include_with_value('client_id', '00010203040122') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:22') srv_msg.client_does_include_with_value('client_id', '00010203040122') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:22') srv_msg.client_does_include_with_value('client_id', '00010203040122') srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '0.0.0.0') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_send_msg('DECLINE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.forge_sleep(3, 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:44') srv_msg.client_does_include_with_value('client_id', '00010203040144') 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')
def test_v4_relay_decline_success(): # check if DECLINE works when sent over relay misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.set_conf_parameter_global('decline-probation-period', 2) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() # this is setting for every message in this test srv_msg.network_variable('source_port', 67) srv_msg.network_variable('source_address', '$(GIADDR4)') srv_msg.network_variable('destination_address', '$(SRV4_ADDR)') srv_msg.client_sets_value('Client', 'giaddr', '$(GIADDR4)') srv_msg.client_sets_value('Client', 'hops', 1) 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', 'giaddr', '$(GIADDR4)') srv_msg.client_sets_value('Client', 'hops', 1) srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') misc.test_procedure() srv_msg.client_sets_value('Client', 'giaddr', '$(GIADDR4)') srv_msg.client_sets_value('Client', 'hops', 1) srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '0.0.0.0') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_send_msg('DECLINE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # wait probation period srv_msg.forge_sleep(2, 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'giaddr', '$(GIADDR4)') srv_msg.client_sets_value('Client', 'hops', 1) srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:11') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.1')
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_hooks_flexid_pgsql_1(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') 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.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'flex-id', '646f63736973332e30') 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.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') # Pause the Test. 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() 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')
def test_v4_hooks_flexid_mysql_1(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') 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.enable_db_backend_reservation('MySQL') # 646f63736973332e30 = docsis3.0 srv_control.new_db_backend_reservation('MySQL', 'flex-id', '646f63736973332e30') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # Pause the Test. 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_copy_option('server_id') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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_allowed_duplicate_mac_reservations_command_control( backend): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.set_conf_parameter_global('ip-reservations-unique', False) srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.open_control_channel() srv_control.agent_control_channel(world.f_cfg.mgmt_address) srv_control.enable_db_backend_reservation(backend) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') assert _add_reservation({ "hw-address": "ff:01:02:03:ff:77", "ip-address": "192.168.50.2" })["text"] == "Host added." assert _add_reservation({ "hw-address": "ff:01:02:03:ff:66", "ip-address": "192.168.50.2" })["text"] == "Host added."
def test_v6_options_rsoo_custom_option_list_default_option_65(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0') srv_control.set_conf_parameter_global('relay-supplied-options', '["12"]') 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') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc') srv_msg.client_sets_value('RelayAgent', 'erpdomain', 'relay-supplied.domain.com') srv_msg.client_does_include('Relay-Supplied-Option', None, 'erp-local-domain-name') srv_msg.client_does_include('RelayAgent', None, 'interface-id') srv_msg.client_does_include('RelayAgent', None, 'rsoo') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY') srv_msg.response_check_include_option('Response', None, '18') srv_msg.response_check_include_option('Response', None, '9') srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message') srv_msg.response_check_include_option('Relayed Message', None, '1') srv_msg.response_check_include_option('Relayed Message', None, '2') srv_msg.response_check_include_option('Relayed Message', None, '3') srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5') srv_msg.response_check_include_option('Relayed Message', None, '65') srv_msg.response_check_option_content('Relayed Message', '65', None, 'erpdomain', 'relay-supplied.domain.com.') references.references_check('RFC642')
def test_v6_options_rsoo_custom_option_list_server_has_option_configured_also(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0') srv_control.set_conf_parameter_global('relay-supplied-options', '["12"]') srv_control.config_srv_opt('unicast', '3000::1') 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_requests_option('12') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc') srv_msg.client_sets_value('RelayAgent', 'srvaddr', '2000::1') srv_msg.client_does_include('Relay-Supplied-Option', None, 'server-unicast') srv_msg.client_does_include('RelayAgent', None, 'interface-id') srv_msg.client_does_include('RelayAgent', None, 'rsoo') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY') srv_msg.response_check_include_option('Response', None, '18') srv_msg.response_check_include_option('Response', None, '9') srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message') srv_msg.response_check_include_option('Relayed Message', None, '1') srv_msg.response_check_include_option('Relayed Message', None, '2') srv_msg.response_check_include_option('Relayed Message', None, '3') srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5') srv_msg.response_check_include_option('Relayed Message', None, '12') srv_msg.response_check_option_content('Relayed Message', '12', 'NOT ', 'srvaddr', '2000::1') srv_msg.response_check_option_content('Relayed Message', '12', None, 'srvaddr', '3000::1') references.references_check('RFC642')
def test_v6_host_reservation_duplicate_ip_reservations_allowed(): the_same_ip_address = '3000::5' misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') # allow non-unique IP address in multiple reservations srv_control.set_conf_parameter_global('ip-reservations-unique', False) srv_control.host_reservation_in_subnet( 'ip-address', the_same_ip_address, # the same IP 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet( 'ip-address', the_same_ip_address, # the same IP 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') # these error logs should not appear srv_msg.log_doesnt_contain(r'ERROR \[kea-dhcp6.dhcp6') srv_msg.log_doesnt_contain( r"There's already reservation for this address/prefix") # first request address by 00:03:00:01:f6:f5:f4:f3:f2:01 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('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', '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', the_same_ip_address) # release taken IP address misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') # and now request address by 00:03:00:01:f6:f5:f4:f3:f2:02 again, the IP should be the same ie. 3000::5 misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') 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:f6:f5:f4:f3:f2:02') 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', the_same_ip_address) # try to request address by 00:03:00:01:f6:f5:f4:f3:f2:01 again, the IP address should be just # from the pool (ie. 3000::1) as 3000::5 is already taken by 00:03:00:01:f6:f5:f4:f3:f2:02 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('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', '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::1')
def test_v6_rapid_commit_as_global_parameter(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.set_conf_parameter_global('rapid-commit', 'true') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv_during_process('DHCP', 'configuration')
def test_v4_host_reservation_duplicate_ip_reservations_allowed(backend): the_same_ip_address = '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.add_hooks('libdhcp_host_cmds.so') srv_control.open_control_channel() srv_control.agent_control_channel(world.f_cfg.mgmt_address) srv_control.enable_db_backend_reservation(backend) # allow non-unique IP address in multiple reservations srv_control.set_conf_parameter_global('ip-reservations-unique', False) if backend == 'memfile': srv_control.host_reservation_in_subnet( 'ip-address', the_same_ip_address, # the same IP 0, 'hw-address', 'aa:aa:aa:aa:aa:aa') srv_control.host_reservation_in_subnet( 'ip-address', the_same_ip_address, # the same IP 0, 'hw-address', 'bb:bb:bb:bb:bb:bb') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') if backend != "memfile": assert _add_reservation({ "hw-address": "aa:aa:aa:aa:aa:aa", "ip-address": the_same_ip_address })["text"] == "Host added." assert _add_reservation({ "hw-address": "bb:bb:bb:bb:bb:bb", "ip-address": the_same_ip_address })["text"] == "Host added." # these error logs should not appear srv_msg.log_doesnt_contain(r'ERROR \[kea-dhcp4.dhcp4') srv_msg.log_doesnt_contain(r'failed to add new host using the HW address') # first request address by aa:aa:aa:aa:aa:aa misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', the_same_ip_address) misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', the_same_ip_address) srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', the_same_ip_address) srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.check_leases(srv_msg.get_all_leases(), ) # release taken IP address misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', the_same_ip_address) srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # and now request address by bb:bb:bb:bb:bb:bb again, the IP should be the same ie. 192.168.50.10 misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'bb:bb:bb:bb:bb:bb') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', the_same_ip_address) misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', the_same_ip_address) srv_msg.client_sets_value('Client', 'chaddr', 'bb:bb:bb:bb:bb:bb') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', the_same_ip_address) srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.check_leases(srv_msg.get_all_leases(), ) # try to request address by aa:aa:aa:aa:aa:aa again, the IP address should be just # from the pool (ie. 192.168.50.1) as 192.168.50.10 is already taken by bb:bb:bb:bb:bb:bb misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') 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_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.check_leases( srv_msg.get_all_leases()) # backend for leases is still memfile
def test_v6_sanity_check_subnet_id_del_renew(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 666, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_some_data('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 999, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep(2, 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks (the lease should have subnet-id 999) and was dropped.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('RENEW') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 13) srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2) srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '999,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_msg.lease_file_doesnt_contain( '2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.lease_file_doesnt_contain( '999,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:22')
def test_v6_sanity_check_subnet_id_del(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 666, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') # lease should be available via lease6-get resp = srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') assert resp['arguments']['subnet-id'] == 666 # it should be in lease file as well srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_some_data('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 999, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "del"}) srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep(2, 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks (the lease should have subnet-id 999) and was dropped.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '7654321') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') # old lease from subnet-id 666 should not be available while new lease from subnet-id 999 should be resp = srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') assert resp['arguments']['subnet-id'] == 999 # explict query for old lease should return error srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"subnet-id":666,"identifier-type":"duid", "identifier": "00:03:00:01:f6:f5:f4:f3:f2:01"}}', exp_result=3) # old lease should not be present in the lease file # bug: #1618, closed as designed srv_msg.lease_file_doesnt_contain( '2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_doesnt_contain( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') # new one should be in the lease file srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.lease_file_contains( '999,3000,0,7654321,128,0,0,,f6:f5:f4:f3:f2:22,0')
def test_v6_sanity_check_subnet_id(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix"}') 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": "config-get","arguments": {} }') srv_msg.send_ctrl_cmd_via_socket( '{"command": "list-commands","arguments": {} }') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::2') srv_control.set_conf_parameter_subnet('id', '888', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix-del"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep('12', 'seconds') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::2') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix-del"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep('12', 'seconds') # Using UNIX socket on server in path control_socket send {"command": "config-get","arguments": {} } misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::2') srv_msg.forge_sleep('10', 'seconds') # Using UNIX socket on server in path control_socket send {"command": "config-get","arguments": {} } misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:33') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2')
def test_v6_sanity_check_subnet_id_none(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 666, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "none"}) srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', 999, 0) srv_control.set_conf_parameter_global('sanity-checks', {"lease-checks": "none"}) srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep(2, 'seconds') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01')
def test_v6_sanity_check_shared_subnet_id(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.config_srv_another_subnet_no_interface( '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1') srv_control.set_conf_parameter_subnet('id', '777', '1') srv_control.shared_subnet('0', '0') srv_control.shared_subnet('1', '0') srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0') srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix-del"}') 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": "config-get","arguments": {} }') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') # Response sub-option 5 from option 3 MUST contain address 2001:db8:a::1. misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.client_sets_value('Client', 'ia_id', '7654321') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.lease_file_contains('2001:db8:a::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains('2001:db8:b::1,00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.lease_file_contains( '777,3000,0,7654321,128,0,0,,f6:f5:f4:f3:f2:02') misc.test_setup() srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1') srv_control.set_conf_parameter_subnet('id', '888', '0') srv_control.config_srv_another_subnet_no_interface( '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1') srv_control.set_conf_parameter_subnet('id', '999', '1') srv_control.shared_subnet('0', '0') srv_control.shared_subnet('1', '0') srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0') srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep('10', 'seconds')
def test_v6_sanity_check_subnet_id_fix_able_double_restart(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_leases('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FIXED The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks, but was corrected to subnet-id 999.' ) srv_msg.forge_sleep('13', 'seconds') srv_control.start_srv('DHCP', 'stopped') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"fix"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '987654321') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1')
def test_v6_sanity_check_subnet_id_del(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '666', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"del"}') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '1234567') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01') srv_control.start_srv('DHCP', 'stopped') srv_control.clear_leases('logs') misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '2001:db8::1-2001:db8::1') srv_control.set_conf_parameter_subnet('id', '999', '0') srv_control.set_conf_parameter_global('sanity-checks', '{"lease-checks":"del"}') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.forge_sleep('2', 'seconds') srv_msg.log_contains( 'DHCPSRV_LEASE_SANITY_FAIL_DISCARD The lease 2001:db8::1 with subnet-id 666 failed subnet-id checks and was dropped.' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_sets_value('Client', 'ia_id', '7654321') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '2001:db8::1') srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"ip-address": "2001:db8::1"}}') srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease6-get","arguments":{"subnet-id":666,"identifier-type":"duid", "identifier": "00:03:00:01:f6:f5:f4:f3:f2:01"}}' ) srv_msg.lease_file_contains('2001:db8::1,00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.lease_file_contains( '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01')
def test_v4_hosts_cmds_duplicate_ip_reservations_allowed(hosts_db): the_same_ip_address = '192.168.50.10' misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') # allow non-unique IP address in multiple reservations srv_control.set_conf_parameter_global('ip-reservations-unique', False) srv_control.open_control_channel() srv_control.enable_db_backend_reservation(hosts_db) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "aa:aa:aa:aa:aa:aa", "ip-address": the_same_ip_address}}}) srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "bb:bb:bb:bb:bb:bb", "ip-address": the_same_ip_address}}}) # first request address by aa:aa:aa:aa:aa:aa misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', the_same_ip_address) misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', the_same_ip_address) srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', the_same_ip_address) srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') # release taken IP address misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', the_same_ip_address) srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # and now request address by bb:bb:bb:bb:bb:bb again, the IP should be the same ie. 192.168.50.10 misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'bb:bb:bb:bb:bb:bb') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', the_same_ip_address) misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', the_same_ip_address) srv_msg.client_sets_value('Client', 'chaddr', 'bb:bb:bb:bb:bb:bb') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', the_same_ip_address) srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') # try to request address by aa:aa:aa:aa:aa:aa again, the IP address should be just # from the pool (ie. 192.168.50.1) as 192.168.50.10 is already taken by bb:bb:bb:bb:bb:bb misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') 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_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_sets_value('Client', 'chaddr', 'aa:aa:aa:aa:aa:aa') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0')