def test_v4_stateless_with_subnet_empty_pool(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '$(EMPTY)') srv_control.config_srv_opt('subnet-mask', '255.255.255.0') srv_control.config_srv_opt('time-offset', '50') srv_control.config_srv_opt('routers', '100.100.100.10,50.50.50.5') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_requests_option('2') srv_msg.client_requests_option('3') srv_msg.client_sets_value('Client', 'ciaddr', '$(CIADDR)') srv_msg.client_send_msg('INFORM') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '0.0.0.0') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_option_content('Response', '2', None, 'value', '50') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'value', '100.100.100.10') srv_msg.response_check_option_content('Response', '3', None, 'value', '50.50.50.5')
def test_v4_message_fields_ciaddr_incorrect_nak(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.build_and_send_config_files('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') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option('1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') 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', '00:00:00:00:00:00') srv_msg.client_sets_value('Client', 'ciaddr', '255.255.255.255') srv_msg.client_requests_option('1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'NAK') srv_msg.response_check_content('Response', None, 'ciaddr', '0.0.0.0') srv_msg.response_check_content('Response', 'NOT ', 'ciaddr', '255.255.255.255')
def test_v4_hosts_cmds_get_reservation_pgsql_2(): misc.test_setup() srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') 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('ipv4_address', '192.168.50.100', '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('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.100') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
def test_v6_mac_in_dhcp6_any(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.run_command('"mac-sources": [ "any" ]') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', '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.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv', None, ',f6:f5:f4:f3:f2:01') srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log', None, 'Hardware addr: f6:f5:f4:f3:f2:01')
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.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') 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.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', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', '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:01') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'NAK') srv_msg.response_check_content('Response', None, 'yiaddr', '0.0.0.0')
def test_v6_IPXE_2(): misc.test_setup() srv_control.config_srv_subnet('2001:db8::/64', '$(EMPTY)') srv_control.create_new_class('a-ipxe') srv_control.add_test_to_class('1', 'test', 'option[61].hex == 0x0007') srv_control.add_option_to_defined_class('1', 'bootfile-url', 'http://[2001:db8::1]/ipxe.efi') # Server is configured with client-classification option in subnet 0 with name a-ipxe. 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', 'archtypes', '7') srv_msg.client_does_include('Client', None, 'client-arch-type') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_requests_option('59') 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, '59') srv_msg.response_check_option_content('Response', '59', None, 'optdata', 'http://[2001:db8::1]/ipxe.efi') 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_hook_v4_lease_cmds_add_valid(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.5') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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_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.5') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "lease4-add","arguments": {"subnet-id": 1,"ip-address": "192.168.50.5","hw-address": "1a:1b:1c:1d:1e:1f"}}') misc.test_procedure() srv_msg.client_requests_option('1') 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_dont_wait_for_message()
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_client_classification_one_class_two_subnets_different_class_id_included(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_client_classification('0', 'VENDOR_CLASS_my-own-class') srv_control.config_srv_another_subnet_no_interface('192.168.51.0/24', '192.168.51.100-192.168.51.100') 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', '00:00:00:00:00:00') srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_does_include_with_value('vendor_class_id', 'my-other-class') 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.51.100') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')
def test_v6_relay_relayaddress_within_subnet(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::10') srv_control.add_line_to_subnet('0', ',"relay": {"ip-address": "3000::2005"}') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::100') srv_msg.client_does_include('RelayAgent', None, 'interface-id') 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_suboption_content('Relayed Message', '5', '3', None, 'addr', '2001:db8:1::1')
def test_user_check_hook_IA_NA_with_registry_known_user(): # With a user registry and multiple subnets # an known user should get first subnet misc.test_setup() srv_msg.send_file_to_server('tests/dhcpv6/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('3000::/64', '3000::5-3000::5') srv_control.config_srv_another_subnet_no_interface('1000::/64', '1000::5-1000::5') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_user_chk.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() # Send a query from a registered user srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:11:02:03:04:05:06') 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::5') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv6/kea_only/user_chk/outcome_2.txt')
def test_v6_relay_interface_one_subnet_not_matching_id(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::10') srv_control.set_conf_parameter_subnet('interface-id', '"xyz"', '0') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc') srv_msg.client_does_include('RelayAgent', None, 'interface-id') 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', '13') srv_msg.response_check_suboption_content('Relayed Message', '13', '3', None, 'statuscode', '2') references.references_check('Kea')
def test_hook_v4_subnet_cmds_del_global_options(): misc.test_setup() srv_control.config_srv_subnet('192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.config_srv_opt('domain-name-servers', '199.199.199.1,100.100.100.1') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_requests_option('6') 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_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.51.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "subnet4-del","arguments":{"id":1}}') misc.test_procedure() srv_msg.client_requests_option('1') 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_dont_wait_for_message()
def test_v4_client_classification_one_class_eRouter1_global_next_server(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_client_classification('0', 'VENDOR_CLASS_eRouter1.0') srv_control.config_srv_another_subnet_no_interface('192.168.50.0/24', '192.168.50.100-192.168.50.100') srv_control.config_srv('boot-file-name', '0', 'somefilename') srv_control.global_add_siaddr('192.0.2.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', 'chaddr', '00:00:00:00:00:00') srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_does_include_with_value('vendor_class_id', 'eRouter1.0') 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', 'NOT ', 'file', 'somefilename') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_content('Response', None, 'siaddr', '0.0.0.0') srv_msg.response_check_content('Response', 'NOT ', 'siaddr', '192.0.2.2') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')
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_user_check_IA_NA_with_registry_known_user(): # With a user registry and multiple subnets # an known user should get first subnet misc.test_setup() srv_msg.send_file_to_server('tests/dhcpv4/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.5') srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_user_chk.so') 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_sets_value('Client', 'chaddr', '0c:0e:0a:01:ff:04') 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.5') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv4/kea_only/user_chk/outcome_2.txt')
def test_v4_options_vendor_encapsulated_space(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.config_srv_custom_opt_space('vendor-encapsulated-options-space', 'foo', '1', 'uint16', '66') srv_control.config_srv_opt('vendor-encapsulated-options', '$(EMPTY)') 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_requests_option('43') 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.50') srv_msg.response_check_include_option('Response', None, '43') # option 43 should have suboption code: 1 length: 2 with value 66 (hex:42) srv_msg.response_check_option_content('Response', '43', None, 'value', 'HEX:01020042')
def test_v6_client_classification_onesubnet_eRouter1_0_request_fail(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1') srv_control.config_client_classification('0', 'VENDOR_CLASS_eRouter1.0') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('7') srv_msg.client_sets_value('Client', 'vendor_class_data', 'eRouter1.0') srv_msg.client_does_include('Client', None, 'vendor-class') 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::1') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') 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_v4_host_reservation_mysql_one_address_inside_pool(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') 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') 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') 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_v6_client_classification_onesubnet_request_success(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1') # Server is configured with client-classification option in subnet 0 with name VENDOR_CLASS_firstclass. srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() # Client sets vendor_class_data value to firstclass. # Client does include vendor-class. 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::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'vendor_class_data', 'firstclass') srv_msg.client_does_include('Client', None, 'vendor-class') 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, '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')
def test_v4_host_reservation_mysql_multiple_address_reservation_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.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') 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.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:03') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '2') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.11', 'MySQL', '2') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '2') srv_control.upload_db_reservation('MySQL') 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: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(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('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.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, '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: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') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100')
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_release_fail_with_different_chaddr_client_id(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:1F:D0:00:00:11') srv_msg.client_does_include_with_value('client_id', '00001FD0040111') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00001FD0040111') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:1f:d0:00:00:11') srv_msg.client_does_include_with_value('client_id', '00001FD0040111') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00001FD0040111') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:1f:d0:11:22:33') srv_msg.client_does_include_with_value('client_id', '00001FD0112233') srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') # address not released 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:00') srv_msg.client_does_include_with_value('client_id', '00010203040111') srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message()
def test_v4_host_reservation_one_address_inside_pool_client_id(): misc.test_setup() # outside of the pool 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', 'client-id', 'ff:01:02:03:ff:04:11: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', '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.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_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22') 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_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_hook_v4_subnet_cmds_add(): misc.test_setup() srv_control.config_srv_subnet('$(EMPTY)', '$(EMPTY)') srv_control.config_srv_opt('domain-name-servers', '199.199.199.1,100.100.100.1') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so') 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_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message() # Using UNIX socket on server in path $(SOFTWARE_INSTALL_DIR)/var/kea/control_socket send {"command":"subnet4-list","arguments":{}} srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"subnet4-add","arguments":{"subnet4":[{"subnet":"192.168.50.0/24","interface":"$(SERVER_IFACE)","id":234,"pools":[{"pool":"192.168.50.1-192.168.50.1"}]}]}}') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"subnet4-get","arguments":{"id": 234}}') 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_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_user_check_IA_NA_with_registry_unknown_user_logging_2(): # With a user registry and multiple subnets # an unknown user should get last subnet misc.test_setup() srv_msg.send_file_to_server('tests/dhcpv4/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.5') srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_user_chk.so') # Server logging system is configured with logger type kea-dhcp4.callouts, severity DEBUG, severity level 99 and log file kea.log. # Server logging system is configured with logger type kea-dhcp4.hooks, severity INFO, severity level None and log file kea.log. srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', '0c:0e:0a:01:ff:01') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '10.0.0.5') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv4/kea_only/user_chk/outcome_1.txt') # File stored in $(SOFTWARE_INSTALL_DIR)/var/kea/kea.log MUST contain line or phrase: INFO \[kea-dhcp4.hooks # File stored in $(SOFTWARE_INSTALL_DIR)/var/kea/kea.log MUST contain line or phrase: DEBUG \[kea-dhcp4.callouts misc.test_setup() srv_msg.send_file_to_server('tests/dhcpv4/kea_only/user_chk/registry_1.txt', '/tmp/user_chk_registry.txt') srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.5-192.168.50.5') srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_user_chk.so') # Server logging system is configured with logger type kea-dhcp4.callouts, severity DEBUG, severity level 99 and log file kea.log. # Server logging system is configured with logger type kea-dhcp4.hooks, severity INFO, severity level None and log file kea.log. srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', '0c:0e:0a:01:ff:01') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '10.0.0.5') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') # Check the outcome file for correct content srv_msg.copy_remote('/tmp/user_chk_outcome.txt') srv_msg.compare_file('tests/dhcpv4/kea_only/user_chk/outcome_1.txt')
def rebind_with_ack_answer(ciaddr): misc.test_procedure() srv_msg.client_sets_value('Client', 'ciaddr', ciaddr) srv_msg.client_send_msg('REQUEST') srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_include_option('Response', None, '54') srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)')
def test_v6_options_vendor_multiple(): # Testing server ability to configure it with vendor-specific options # and share it with user. # In this case: for vendor id vendor-4491 set option time-offset with value -18000 # and for vendor id vendor-4491 set option tftp-servers with value: 2001:558:ff18:16:10:253:175:76 # and for vendor id vendor-4491 set option config-file with value normal_erouter_v6.cm # and for vendor id vendor-4491 set option syslog-servers with address 2001:558:ff18:10:10:253:124:101 # and for vendor id vendor-4491 set option time-servers option with value 2001:558:ff18:16:10:253:175:76 # and for vendor id vendor-4491 set option time-offset with value -10000 # Send vendor class and vendor specific information option (with option request). # Vendor tests are beta version. # with client via Advertise message. # Client Server # vendor-class # specific-info-req (all codes)SOLICIT --> # vendor-spec-info <-- ADVERTISE # Pass Criteria: # REPLY/ADVERTISE MUST include option: # vendor specific information (code 17) with suboption # TFTP Server address (code 32) # Configuration file name (code 33) # sys log servers (code 34) # time offset (code 38) # time protocol servers (code 37) misc.test_setup() srv_control.config_srv_subnet('3000::/32', '3000::1-3000::2') srv_control.config_srv_opt_space('vendor-4491', 'tftp-servers', '2001:558:ff18:16:10:253:175:76') srv_control.config_srv_opt_space('vendor-4491', 'config-file', 'normal_erouter_v6.cm') srv_control.config_srv_opt_space('vendor-4491', 'syslog-servers', '2001:558:ff18:10:10:253:124:101') srv_control.config_srv_opt_space('vendor-4491', 'time-servers', '2001:558:ff18:16:10:253:175:76') srv_control.config_srv_opt_space('vendor-4491', 'time-offset', '-10000') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.client_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', 'vendor-class') srv_msg.add_vendor_suboption('Client', 1, 32) srv_msg.add_vendor_suboption('Client', 1, 33) srv_msg.add_vendor_suboption('Client', 1, 34) srv_msg.add_vendor_suboption('Client', 1, 37) srv_msg.add_vendor_suboption('Client', 1, 38) 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(17) srv_msg.response_check_option_content(17, 'sub-option', 32) srv_msg.response_check_option_content(17, 'sub-option', 33) srv_msg.response_check_option_content(17, 'sub-option', 34) srv_msg.response_check_option_content(17, 'sub-option', 37) srv_msg.response_check_option_content(17, 'sub-option', 38) references.references_check('RFC3315')
def test_v4_client_classification_multiple_classes_three_subnets_docsis_erouter( ): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_client_classification(0, 'VENDOR_CLASS_eRouter1.0') srv_control.subnet_add_siaddr(0, '192.0.50.1') srv_control.config_srv('boot-file-name', 0, 'filename') srv_control.config_srv_another_subnet_no_interface( '192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.config_client_classification(1, 'VENDOR_CLASS_docsis3.0') srv_control.subnet_add_siaddr(1, '192.0.50.50') srv_control.config_srv('boot-file-name', 1, 'somefilename') srv_control.config_srv_another_subnet_no_interface( '192.168.50.0/24', '192.168.50.100-192.168.50.100') srv_control.global_add_siaddr('192.0.50.100') 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:00') srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_does_include_with_value('vendor_class_id', 'eRouter1.0') srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('siaddr', '192.0.50.1', expected=False) srv_msg.response_check_content('siaddr', '192.0.50.50', expected=False) srv_msg.response_check_content('siaddr', '192.0.50.100', expected=False) srv_msg.response_check_content('file', 'somefilename', expected=False) srv_msg.response_check_content('file', 'filename', expected=False) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_content('siaddr', '0.0.0.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:00') srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('siaddr', '192.0.50.1', expected=False) srv_msg.response_check_content('siaddr', '192.0.50.100', expected=False) srv_msg.response_check_content('siaddr', '0.0.0.0', expected=False) srv_msg.response_check_content('file', 'filename', expected=False) srv_msg.response_check_content('siaddr', '192.0.50.50') srv_msg.response_check_content('file', 'somefilename') srv_msg.response_check_content('yiaddr', '192.168.50.50') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(54) srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_option_content(54, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content(61, 'value', '00010203040506') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:00') 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', 'OFFER') srv_msg.response_check_content('siaddr', '192.0.50.1', expected=False) srv_msg.response_check_content('siaddr', '192.0.50.50', expected=False) srv_msg.response_check_content('siaddr', '0.0.0.0', expected=False) srv_msg.response_check_content('file', 'filename', expected=False) srv_msg.response_check_content('file', 'somefilename', expected=False) srv_msg.response_check_content('yiaddr', '192.168.50.100') srv_msg.response_check_content('siaddr', '192.0.50.100') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(54) srv_msg.response_check_include_option(61) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.response_check_option_content(54, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content(61, 'value', '00010203040506')
def test_v4_hooks_flexid_replace_client_id_release_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('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:33') 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_does_include_with_value('vendor_class_id', 'docsis3.0') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() misc.test_procedure() srv_msg.client_does_include_with_value('client_id', 'ff:01:02:03:ff:04:11:22:33:44:55') 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.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') 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,0')
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_fix_del_unable(): 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() 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": "fix-del"}) srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started')
def test_prefix(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::3') srv_control.config_srv_prefix('3001::', '0', '90', '96') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include('Client', 'NOT ', 'IA-NA') srv_msg.client_does_include('Client', None, 'IA-PD') 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, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') 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', 'NOT ', 'IA-NA') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') 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') misc.test_procedure() srv_msg.client_does_include('Client', 'NOT ', 'IA-NA') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') 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, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') 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', 'NOT ', 'IA-NA') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') 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')
def test_v6_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_prefix_renew_before_expire( ): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.config_srv_prefix('2001:db8:1::', 0, 32, 33) 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_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_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') 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', '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_does_include('Client', 'IA-PD') 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', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') # SAVE VALUES srv_msg.client_save_option('IA_PD') 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') 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.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) 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', 'client-id') srv_msg.client_send_msg('RENEW') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.config_srv_prefix('2001:db8:1::', 0, 32, 35) srv_control.host_reservation_in_subnet('prefix', '2001:db8:1:0:8000::/33', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('prefix', '2001:db8:1::/33', 0, 'hw-address', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_control.build_and_send_config_files() 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', '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') 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.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::', expect_include=False) srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:1:0:8000::') # Sleep for 17 seconds. 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_add_saved_option('DONT ') 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(25) srv_msg.response_check_option_content(25, 'sub-option', 26) srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:1::', expect_include=False) srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:1:0:8000::', expect_include=False) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5)
def test_v6_hooks_flexid_libreload(): 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', '\'port1234\'') 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', 'substring(relay6[0].option[18].hex,0,8)') 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('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'port1234') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.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) # Relayed Message sub-option 5 from option 3 MUST contain address 2001:db8:1::1. srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f') srv_msg.send_ctrl_cmd_via_socket('{"command": "libreload","arguments": {}}') # if reload works - classification should work without changes misc.test_procedure() srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'port1234') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.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) # Relayed Message sub-option 5 from option 3 MUST contain address 2001:db8:1::1. srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
def test_hook_v4_lease_cmds_legal_logging_del_using_hw_address(): misc.test_procedure() srv_msg.remove_file_from_server(world.f_cfg.data_join('kea-legal*.txt')) misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_legal_log.so') 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_requests_option(1) 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_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) srv_msg.client_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.1') 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_requests_option(1) srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.send_ctrl_cmd_via_socket( '{"command": "lease4-del","arguments": {"identifier": "ff:01:02:03:ff:04","identifier-type":"hw-address","subnet-id":1}}' ) misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt')) srv_msg.file_contains_line( world.f_cfg.data_join('kea-legal*.txt'), None, 'Administrator deleted a lease for a device identified by: hw-address of ff:01:02:03:ff:04' )
def test_v6_hooks_flexid_replace_duid_release_mysql(): 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.add_parameter_to_hook(1, 'replace-client-id', True) srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'flex-id', '01:02:03:04:05:06') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::f', '$(EMPTY)', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') 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_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', 'vendor-class') srv_msg.add_vendor_suboption('Client', 1026, '11:22:33:44:55:66') 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', 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_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') 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_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_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', '3000::f') # Client with different duid try to release misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') 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_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 13) srv_msg.response_check_suboption_content(13, 3, 'statuscode', 0)
def test_v6_hooks_flexid_replace_duid_renew_failed(): 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.add_parameter_to_hook(1, 'replace-client-id', True) 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_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') 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_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_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', '3000::f') # Client with the same DUID and different flex-id try to renew 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_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', 'vendor-class') srv_msg.add_vendor_suboption('Client', 1026, '01:02:03:44:55:66') srv_msg.client_does_include('Client', 'vendor-specific-info') 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', '3000::f') srv_msg.response_check_suboption_content(5, 3, 'validlft', 0)
def test_ddns4_tsig_md5_forw_and_rev(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('generated-prefix', 'four') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_forward_ddns('four.example.com.', 'forge.md5.key') srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'forge.md5.key') srv_control.add_keys('forge.md5.key', 'HMAC-MD5', 'bX3Hs+fG/tThidQPuhK1mA==') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number('26') srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option(None, 'ANSWER') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'aa.four.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_include_option('Response', None, '81') srv_msg.response_check_option_content('Response', '81', None, 'flags', '1') srv_msg.response_check_option_content('Response', '81', None, 'fqdn', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('aa.four.example.com', 'A', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', '192.168.50.10') srv_msg.dns_option_content('ANSWER', None, 'rrname', 'aa.four.example.com.') misc.test_procedure() srv_msg.dns_question_record('10.50.168.192.in-addr.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST', None) srv_msg.dns_option('NOT ', 'ANSWER') srv_msg.dns_option_content('ANSWER', None, 'rdata', 'aa.four.example.com.') srv_msg.dns_option_content('ANSWER', None, 'rrname', '10.50.168.192.in-addr.arpa.')
def test_stats_basic(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.10') srv_control.open_control_channel() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') stats = StatsState4() stats.s['subnet[1].total-addresses'] = 10 misc.test_procedure() result = srv_msg.send_ctrl_cmd_via_socket( '{"command": "list-commands","arguments": {}}') stat_cmds = [ 'statistic-get', 'statistic-get-all', 'statistic-remove', 'statistic-remove-all', 'statistic-reset', 'statistic-reset-all', 'statistic-sample-age-set', 'statistic-sample-age-set-all', 'statistic-sample-count-set', 'statistic-sample-count-set-all' ] for c in stat_cmds: assert c in result['arguments'] cnt = 0 for c in result['arguments']: if c.startswith('statistic-'): cnt += 1 assert len(stat_cmds) == cnt srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') stats.s['pkt4-offer-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-discover-received'] += 1 stats.compare() misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') stats.s['pkt4-ack-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-request-received'] += 1 stats.s['subnet[1].assigned-addresses'] += 1 stats.compare() misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() stats.s['pkt4-release-received'] += 1 stats.s['pkt4-received'] += 1 stats.s['subnet[1].assigned-addresses'] -= 1 stats.compare() misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') stats.s['pkt4-offer-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-discover-received'] += 1 stats.compare() misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option(1) srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') stats.s['pkt4-ack-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-request-received'] += 1 stats.s['subnet[1].assigned-addresses'] += 1 stats.compare() misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.1') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_dont_wait_for_message() stats.s['pkt4-release-received'] += 1 stats.s['pkt4-received'] += 1 stats.s['subnet[1].assigned-addresses'] -= 1 stats.compare() misc.test_procedure() 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') stats.s['pkt4-offer-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-discover-received'] += 1 stats.compare() 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_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') srv_msg.response_check_content('yiaddr', '192.168.50.1') stats.s['pkt4-ack-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-request-received'] += 1 stats.s['subnet[1].assigned-addresses'] += 1 stats.compare() misc.test_procedure() 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() stats.s['pkt4-decline-received'] += 1 stats.s['pkt4-received'] += 1 stats.s['subnet[1].declined-addresses'] += 1 stats.s['declined-addresses'] += 1 stats.compare() misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_sets_value('Client', 'ciaddr', '$(CIADDR)') srv_msg.client_send_msg('INFORM') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ACK') stats.s['pkt4-ack-sent'] += 1 stats.s['pkt4-sent'] += 1 stats.s['pkt4-received'] += 1 stats.s['pkt4-inform-received'] += 1 stats.compare() assert get_stat("declined-addresses") == [1, 0] assert get_stat("pkt4-ack-received") == [0] assert get_stat("pkt4-ack-sent") == [4, 3, 2, 1, 0] assert get_stat("pkt4-decline-received") == [1, 0] assert get_stat("pkt4-discover-received") == [3, 2, 1, 0] assert get_stat("pkt4-inform-received") == [1, 0] assert get_stat("pkt4-nak-received") == [0] assert get_stat("pkt4-nak-sent") == [0] assert get_stat("pkt4-offer-received") == [0] assert get_stat("pkt4-offer-sent") == [3, 2, 1, 0] assert get_stat("pkt4-parse-failed") == [0] assert get_stat("pkt4-receive-drop") == [0] assert get_stat("pkt4-received") == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] assert get_stat("pkt4-request-received") == [3, 2, 1, 0] assert get_stat("pkt4-release-received") == [2, 1, 0] assert get_stat("pkt4-sent") == [7, 6, 5, 4, 3, 2, 1, 0] assert get_stat("pkt4-unknown-received") == [0] assert get_stat("reclaimed-declined-addresses") == [0] assert get_stat("reclaimed-leases") == [0] assert get_stat("subnet[1].assigned-addresses") == [1, 0, 1, 0, 1, 0] assert get_stat("subnet[1].declined-addresses") == [1, 0] assert get_stat("subnet[1].reclaimed-declined-addresses") == [0] assert get_stat("subnet[1].reclaimed-leases") == [0] assert get_stat("subnet[1].total-addresses") == [10]
def test_v6_options_all(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.config_srv_opt('preference', '123') srv_control.config_srv_opt('sip-server-dns', 'srv1.example.com,srv2.isc.org') srv_control.config_srv_opt('dns-servers', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('domain-search', 'domain1.example.com,domain2.isc.org') srv_control.config_srv_opt('sip-server-addr', '2001:db8::1,2001:db8::2') srv_control.config_srv_opt('nisp-servers', '2001:db8::abc,3000::1,2000::1234') srv_control.config_srv_opt('nis-servers', '2001:db8::abc,3000::1,2000::1234') srv_control.config_srv_opt('nis-domain-name', 'ntp.example.com') srv_control.config_srv_opt('nisp-domain-name', 'ntp.example.com') srv_control.config_srv_opt('sntp-servers', '2001:db8::abc,3000::1,2000::1234') srv_control.config_srv_opt('information-refresh-time', '12345678') srv_control.config_srv_opt('unicast', '3000::66') srv_control.config_srv_opt('bcmcs-server-dns', 'very.good.domain.name.com') srv_control.config_srv_opt('bcmcs-server-addr', '3000::66,3000::77') srv_control.config_srv_opt('pana-agent', '3000::66,3000::77') srv_control.config_srv_opt('new-posix-timezone', 'EST5EDT4') srv_control.config_srv_opt('new-tzdb-timezone', 'Europe/Zurich') srv_control.config_srv_opt('bootfile-url', 'http://www.kea.isc.org') srv_control.config_srv_opt('bootfile-param', '000B48656C6C6F20776F726C640003666F6F') srv_control.config_srv_opt('erp-local-domain-name', 'erp-domain.isc.org') srv_control.config_srv('domain-search', '0', 'subnet.example.com') srv_control.config_srv_custom_opt('foo', '100', 'uint8', '123') srv_control.config_srv_opt_space('vendor-4491', 'tftp-servers', '2001:558:ff18:16:10:253:175:76') srv_control.config_srv_opt_space('vendor-4491', 'config-file', 'normal_erouter_v6.cm') srv_control.config_srv_opt_space('vendor-4491', 'syslog-servers', '2001:558:ff18:10:10:253:124:101') srv_control.config_srv_opt_space('vendor-4491', 'time-servers', '2001:558:ff18:16:10:253:175:76') srv_control.config_srv_opt_space('vendor-4491', 'time-offset', '-10000') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('7') srv_msg.client_requests_option('12') srv_msg.client_requests_option('21') srv_msg.client_requests_option('22') srv_msg.client_requests_option('23') srv_msg.client_requests_option('24') srv_msg.client_requests_option('27') srv_msg.client_requests_option('28') srv_msg.client_requests_option('29') srv_msg.client_requests_option('30') srv_msg.client_requests_option('31') srv_msg.client_requests_option('32') srv_msg.client_requests_option('33') srv_msg.client_requests_option('34') srv_msg.client_requests_option('40') srv_msg.client_requests_option('41') srv_msg.client_requests_option('42') srv_msg.client_requests_option('59') srv_msg.client_requests_option('60') srv_msg.client_requests_option('65') srv_msg.client_requests_option('100') srv_msg.client_send_msg('INFOREQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '123') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'srvaddr', '3000::66') srv_msg.response_check_include_option('Response', None, '21') srv_msg.response_check_option_content('Response', '21', None, 'addresses', 'srv1.example.com.,srv2.isc.org.') srv_msg.response_check_include_option('Response', None, '22') srv_msg.response_check_option_content('Response', '22', None, 'addresses', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option('Response', None, '23') srv_msg.response_check_option_content('Response', '23', None, 'addresses', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option('Response', None, '24') srv_msg.response_check_include_option('Response', None, '27') srv_msg.response_check_option_content('Response', '27', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '28') srv_msg.response_check_option_content('Response', '28', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '29') srv_msg.response_check_option_content('Response', '29', None, 'domain', 'ntp.example.com.') srv_msg.response_check_include_option('Response', None, '30') srv_msg.response_check_option_content('Response', '30', None, 'domain', 'ntp.example.com.') srv_msg.response_check_include_option('Response', None, '31') srv_msg.response_check_option_content('Response', '31', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '32') srv_msg.response_check_option_content('Response', '32', None, 'value', '12345678') srv_msg.response_check_include_option('Response', None, '33') srv_msg.response_check_option_content('Response', '33', None, 'bcmcsdomains', 'very.good.domain.name.com.') srv_msg.response_check_include_option('Response', None, '34') srv_msg.response_check_option_content('Response', '34', None, 'bcmcsservers', '3000::66,3000::77') srv_msg.response_check_include_option('Response', None, '40') srv_msg.response_check_option_content('Response', '40', None, 'paaaddr', '3000::66,3000::77') srv_msg.response_check_include_option('Response', None, '41') srv_msg.response_check_option_content('Response', '41', None, 'optdata', 'EST5EDT4') srv_msg.response_check_include_option('Response', None, '42') srv_msg.response_check_option_content('Response', '42', None, 'optdata', 'Europe/Zurich') srv_msg.response_check_include_option('Response', None, '59') srv_msg.response_check_option_content('Response', '59', None, 'optdata', 'http://www.kea.isc.org') srv_msg.response_check_include_option('Response', None, '65') srv_msg.response_check_option_content('Response', '65', None, 'erpdomain', 'erp-domain.isc.org.') misc.test_procedure() srv_msg.client_requests_option('7') srv_msg.client_requests_option('12') srv_msg.client_requests_option('21') srv_msg.client_requests_option('22') srv_msg.client_requests_option('23') srv_msg.client_requests_option('24') srv_msg.client_requests_option('27') srv_msg.client_requests_option('28') srv_msg.client_requests_option('29') srv_msg.client_requests_option('30') srv_msg.client_requests_option('31') srv_msg.client_requests_option('32') srv_msg.client_requests_option('33') srv_msg.client_requests_option('34') srv_msg.client_requests_option('40') srv_msg.client_requests_option('41') srv_msg.client_requests_option('42') srv_msg.client_requests_option('59') srv_msg.client_requests_option('60') srv_msg.client_requests_option('65') srv_msg.client_requests_option('100') srv_msg.client_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', None, 'vendor-class') srv_msg.add_vendor_suboption('Client', '1', '32') srv_msg.add_vendor_suboption('Client', '1', '33') srv_msg.add_vendor_suboption('Client', '1', '34') srv_msg.add_vendor_suboption('Client', '1', '37') srv_msg.add_vendor_suboption('Client', '1', '38') srv_msg.client_does_include('Client', None, 'vendor-specific-info') 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, '17') srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32') srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33') srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '34') srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '37') srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '38') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '123') srv_msg.response_check_include_option('Response', None, '12') srv_msg.response_check_option_content('Response', '12', None, 'srvaddr', '3000::66') srv_msg.response_check_include_option('Response', None, '21') srv_msg.response_check_option_content('Response', '21', None, 'addresses', 'srv1.example.com.,srv2.isc.org.') srv_msg.response_check_include_option('Response', None, '22') srv_msg.response_check_option_content('Response', '22', None, 'addresses', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option('Response', None, '23') srv_msg.response_check_option_content('Response', '23', None, 'addresses', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option('Response', None, '24') srv_msg.response_check_option_content('Response', '24', None, 'domains', 'subnet.example.com.') srv_msg.response_check_include_option('Response', None, '27') srv_msg.response_check_option_content('Response', '27', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '28') srv_msg.response_check_option_content('Response', '28', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '29') srv_msg.response_check_option_content('Response', '29', None, 'domain', 'ntp.example.com.') srv_msg.response_check_include_option('Response', None, '30') srv_msg.response_check_option_content('Response', '30', None, 'domain', 'ntp.example.com.') srv_msg.response_check_include_option('Response', None, '31') srv_msg.response_check_option_content('Response', '31', None, 'addresses', '2001:db8::abc,3000::1,2000::1234') srv_msg.response_check_include_option('Response', None, '32') srv_msg.response_check_option_content('Response', '32', None, 'value', '12345678') srv_msg.response_check_include_option('Response', None, '33') srv_msg.response_check_option_content('Response', '33', None, 'bcmcsdomains', 'very.good.domain.name.com.') srv_msg.response_check_include_option('Response', None, '34') srv_msg.response_check_option_content('Response', '34', None, 'bcmcsservers', '3000::66,3000::77') srv_msg.response_check_include_option('Response', None, '40') srv_msg.response_check_option_content('Response', '40', None, 'paaaddr', '3000::66,3000::77') srv_msg.response_check_include_option('Response', None, '41') srv_msg.response_check_option_content('Response', '41', None, 'optdata', 'EST5EDT4') srv_msg.response_check_include_option('Response', None, '42') srv_msg.response_check_option_content('Response', '42', None, 'optdata', 'Europe/Zurich') srv_msg.response_check_include_option('Response', None, '59') srv_msg.response_check_option_content('Response', '59', None, 'optdata', 'http://www.kea.isc.org') srv_msg.response_check_include_option('Response', None, '65') srv_msg.response_check_option_content('Response', '65', None, 'erpdomain', 'erp-domain.isc.org.')
def test_v6_message_renew_reply_different_clients_the_same_iaid(): # Two clients try to renew address, using the same IA_ID but different Client-ID misc.test_setup() srv_control.set_time('renew-timer', 50) srv_control.set_time('rebind-timer', 60) srv_control.set_time('preferred-lifetime', 70) srv_control.set_time('valid-lifetime', 80) srv_control.config_srv_subnet('3000::/64', '3000::1-3000::2') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') 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) misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') 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('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) misc.test_procedure() # client try to renew address that is not his srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_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, 'validlft', 0) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::2') srv_msg.response_check_suboption_content(5, 3, 'validlft', 80) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::1') references.references_check('RFC')
def test_v6_rfc7550_14(): misc.test_setup() srv_control.set_time('preferred-lifetime', 300) srv_control.set_time('valid-lifetime', 400) srv_control.set_time('renew-timer', 100) srv_control.set_time('rebind-timer', 200) srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1') srv_control.config_srv_prefix('3001::', 0, 90, 96) srv_control.configure_loggers('kea-dhcp6', 'DEBUG', 99) srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') 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_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'T1', 0) srv_msg.client_sets_value('Client', 'T2', 0) srv_msg.client_sets_value('Client', 'validlft', 0) srv_msg.client_sets_value('Client', 'preflft', 0) srv_msg.client_sets_value('Client', 'IA_Address', '3000::1') srv_msg.client_does_include('Client', 'IA_Address') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REBIND') 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_include_option(25)
def test_v6_rfc7550_12(): misc.test_setup() srv_control.set_time('preferred-lifetime', '300') srv_control.set_time('valid-lifetime', '400') srv_control.set_time('renew-timer', '100') srv_control.set_time('rebind-timer', '200') srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1') srv_control.config_srv_prefix('3001::', '0', '90', '96') srv_control.configure_loggers('kea-dhcp6', 'DEBUG', '99') # start server: 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_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_copy_option('server-id') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') 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_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') 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:f6:f5:f4:f3:f2:02') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') 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, '1') srv_msg.response_check_include_option('Response', None, '2') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26')
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_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_prefix_renew_after_expire( ): misc.test_setup() srv_control.set_time('renew-timer', 5) srv_control.set_time('rebind-timer', 6) srv_control.set_time('valid-lifetime', 7) srv_control.set_time('preferred-lifetime', 8) srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.config_srv_prefix('2001:db8:1::', 0, 32, 33) 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_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_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') 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', '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_does_include('Client', 'IA-PD') 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', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') # SAVE VALUES srv_msg.client_save_option('IA_PD') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:44') 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') 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.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) 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', 'client-id') srv_msg.client_send_msg('RENEW') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_setup() srv_control.set_time('renew-timer', 5) srv_control.set_time('rebind-timer', 6) srv_control.set_time('valid-lifetime', 7) srv_control.set_time('preferred-lifetime', 8) srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.config_srv_prefix('2001:db8:1::', 0, 32, 33) srv_control.host_reservation_in_subnet('prefix', '2001:db8:1:0:8000::/33', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.host_reservation_in_subnet('prefix', '2001:db8:1::/33', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:02') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep(15, 'seconds') # prefix expired should be able 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') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) 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:0:8000::') misc.test_procedure() srv_msg.client_does_include('Client', 'IA-PD') srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_PD') 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_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:0:8000::') 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_add_saved_option('DONT ') 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(25) srv_msg.response_check_option_content(25, 'sub-option', 26) # Response sub-option 26 from option 25 MUST NOT contain prefix 2001:db8:1::. # this can be in message but with validlifetime 0 # todo: associate validlifetimes with address from single suboption. srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:1:0:8000::', expect_include=False) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5)
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('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":"none"}') srv_control.open_control_channel() srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') srv_msg.forge_sleep('2', 'seconds') srv_msg.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_host_reservation_conflicts_reconfigure_server_with_reservation_of_used_prefix( ): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.config_srv_prefix('2001:db8:1::', 0, 32, 33) 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_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_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') 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', '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_does_include('Client', 'IA-PD') 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', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:33') 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_does_include('Client', 'IA-PD') 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:33') 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') # bigger prefix pool + reservation 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:8001::/34', 0, 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.build_and_send_config_files() 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', '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_does_include('Client', 'IA-PD') 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(25) srv_msg.response_check_option_content(25, 'sub-option', 26) srv_msg.response_check_suboption_content(26, 25, 'prefix', '2001:db8:8001::', expect_include=False) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5)
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_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_fix_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"}') 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.' ) 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::1')
def test_v4_client_classification_one_class_two_subnets_same_values(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_client_classification('0', 'VENDOR_CLASS_my-own-class') srv_control.config_srv_another_subnet_no_interface( '192.168.51.0/24', '192.168.51.100-192.168.51.100') 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', '00:00:00:00:00:00') srv_msg.client_does_include_with_value('client_id', '00010203040506') srv_msg.client_does_include_with_value('vendor_class_id', 'my-own-class') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:00') 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_does_include_with_value('vendor_class_id', 'my-own-class') srv_msg.client_requests_option('1') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:00') 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.51.100') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:00') 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.51.100') 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.51.100') 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', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')
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_hook_v4_lease_cmds_wipe(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.2') 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_requests_option('1') 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_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1') srv_msg.client_requests_option('1') srv_msg.client_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.1') 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_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:05') 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.2') 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.2') srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:05') 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') 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_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message() srv_msg.send_ctrl_cmd_via_socket('{"command": "lease4-wipe","arguments": {"subnet-id":1}}') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:11') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_ddns6_notsig_forw_and_rev_release_fqdn_sanitization_replace_2(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_ddns_server_options('hostname-char-set', '[^A-Za-z]') srv_control.add_ddns_server_options('hostname-char-replacement', 'x') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_save_option_count(1, 'IA_NA') srv_msg.client_save_option_count(1, 'server-id') srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_sets_value('Client', 'FQDN_domain_name', '*a$(WHITE_SPACE).8723()+.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'flags', 'S') srv_msg.response_check_option_content(39, 'fqdn', 'xax.xxxxxxx.') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_add_saved_option_count(1, 'DONT ') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_sets_value('Client', 'FQDN_domain_name', '*a$(WHITE_SPACE).8723()+.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_send_msg('RELEASE') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2)
def test_ddns6_notsig_expired_fqdn_sanitization(): misc.test_setup() srv_control.set_time('renew-timer', 1) srv_control.set_time('rebind-timer', 2) srv_control.set_time('preferred-lifetime', 3) srv_control.set_time('valid-lifetime', 4) srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::50-2001:db8:1::50') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('generated-prefix', 'six') srv_control.add_ddns_server_options('qualifying-suffix', 'example.com') srv_control.add_ddns_server_options('hostname-char-set', '[^A-Za-z.-]') srv_control.add_ddns_server_options('hostname-char-replacement', '$(EMPTY)') srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY') srv_control.add_reverse_ddns('1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_control.use_dns_set_number(1) srv_control.start_srv('DNS', 'started') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'sth6.six.example.com.') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'flags', 'S') srv_msg.response_check_option_content(39, 'fqdn', 'sth.six.example.com.') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', '2001:db8:1::50') misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER') srv_msg.dns_option_content('ANSWER', 'rdata', 'sth.six.example.com.') srv_msg.dns_option_content( 'ANSWER', 'rrname', '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.' ) srv_msg.forge_sleep(15, 'seconds') misc.test_procedure() srv_msg.dns_question_record('sth.six.example.com', 'AAAA', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False) misc.test_procedure() srv_msg.dns_question_record( '0.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'PTR', 'IN') srv_msg.client_send_dns_query() misc.pass_criteria() srv_msg.send_wait_for_query('MUST') srv_msg.dns_option('ANSWER', expect_include=False)
def test_v4_legal_log_rebind_address_mysql(): misc.test_procedure() srv_msg.remove_from_db_table('logs', 'MySQL') misc.test_setup() srv_control.set_time('renew-timer', '3') srv_control.set_time('rebind-timer', '4') srv_control.set_time('valid-lifetime', '600') srv_control.add_hooks('libdhcp_legal_log.so') srv_control.add_parameter_to_hook('1', 'name', '$(DB_NAME)') srv_control.add_parameter_to_hook('1', 'password', '$(DB_PASSWD)') srv_control.add_parameter_to_hook('1', 'type', 'mysql') srv_control.add_parameter_to_hook('1', 'user', '$(DB_USER)') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.build_and_send_config_files('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.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_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_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') 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_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_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)') # make sure that T2 time expires and client will be in REBIND state. srv_msg.forge_sleep('5', 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_sets_value('Client', 'giaddr', '$(GIADDR4)') srv_msg.client_sets_value('Client', 'hops', '1') srv_msg.client_sets_value('Client', 'ciaddr', '192.168.50.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, '54') srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)') srv_msg.table_contains_line( 'logs', 'MySQL', None, 'Address: 192.168.50.1 has been renewed for 0 hrs 10 mins 0 secs') srv_msg.table_contains_line( 'logs', 'MySQL', None, 'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04 connected via relay at address: $(GIADDR4)' )