def test_v4_hosts_cmds_get_reservation_pgsql_2(): misc.test_setup() srv_control.add_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() 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_ctrl_cmd_via_socket('{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
def test_hook_v6_lease_cmds_legal_logging_add(): 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('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::1') srv_control.config_srv_opt('preference', '123') srv_control.config_srv_opt('domain-search', 'domain1.example.com,domain2.isc.org') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.add_hooks('libdhcp_legal_log.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:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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::1') srv_msg.send_ctrl_cmd_via_socket( '{"command": "lease6-add","arguments": {"subnet-id": 1,"ip-address": "2001:db8:1::1","duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24","iaid": 1234}}' ) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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') 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 added a lease of address: 2001:db8:1::1 to a device with DUID: 1a:1b:1c:1d:1e:1f:20:21:22:23:24' )
def test_stats_sample_age(): 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') cmd = { "command": "statistic-sample-age-set", "arguments": { "name": "pkt4-received", "duration": 1 } } srv_msg.send_ctrl_cmd_via_socket(cmd) assert get_stat('pkt4-received') == [0] assert get_stat('subnet[1].total-addresses') == [10] misc.test_procedure() for _ in range(3): srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') time.sleep(1) assert get_stat('pkt4-received') == [3]
def test_v4_hosts_cmds_conflicts_duplicate_ip_reservations(hosts_db): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation(hosts_db) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "ff:01:02:03:ff:01", "ip-address": "192.168.50.10"}}}) # the same IP - it should fail srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "ff:01:02:03:ff:02", "ip-address": "192.168.50.10"}}}, exp_result=1)
def test_hook_v4_network_cmds_get_by_name(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_srv_another_subnet_no_interface( '192.168.51.0/24', '192.168.51.1-192.168.51.1') srv_control.config_srv_another_subnet_no_interface( '192.168.52.0/24', '192.168.52.1-192.168.52.1') srv_control.config_srv_another_subnet_no_interface( '192.168.53.0/24', '192.168.53.1-192.168.53.1') # first shared subnet 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') # second shared-subnet srv_control.shared_subnet('2', '1') srv_control.shared_subnet('3', '1') srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '1') srv_control.set_conf_parameter_shared_subnet( 'relay', '{"ip-address":"$(GIADDR4)"}', '1') srv_control.config_srv('time-servers', '0', '199.199.199.10') srv_control.config_srv('time-servers', '2', '199.199.199.100') srv_control.config_srv('time-servers', '3', '199.199.199.200') srv_control.add_hooks('libdhcp_subnet_cmds.so') 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":"network4-get","arguments":{"name":"name-xyz"}}')
def test_v4_hosts_cmds_del_reservation_mysql_2(): misc.test_setup() # address reserved without using command srv_control.add_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() 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.100', '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() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.100') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-del","arguments":{"subnet-id":1,"ip-address":"192.168.50.100"}}') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.50')
def test_v4_hosts_cmds_get_reservation_mysql(): misc.test_setup() srv_control.add_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() srv_control.enable_db_backend_reservation('MySQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.50') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"hw-address":"ff:01:02:03:ff:04","ip-address":"192.168.50.100"}}}') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_content('yiaddr', '192.168.50.100') srv_msg.send_ctrl_cmd_via_socket('{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
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() srv_control.add_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)/etc/kea/control_socket send {"command":"subnet4-list","arguments":{}} srv_msg.send_ctrl_cmd_via_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_ctrl_cmd_via_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_control_channel_socket_dhcp_disable(): 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() 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_ctrl_cmd_via_socket('{"command": "dhcp-disable" }') misc.test_procedure() srv_msg.client_requests_option('1') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_dont_wait_for_message()
def test_hook_v4_lease_cmds_legal_logging_add(): 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.5-192.168.50.5') 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('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket( '{"command": "lease4-add","arguments": {"subnet-id": 1,"ip-address": "192.168.50.5","hw-address": "1a:1b:1c:1d:1e:1f","valid-lft":7777,"expire":123456789,"hostname":"my.host.some.name","client-id":"aa:bb:cc:dd:11:22"}}' ) # Now we have to check if lease 192.168.50.50 was actually added -- check leases file srv_msg.lease_file_contains('1a:1b:1c:1d:1e:1f') srv_msg.lease_file_contains('aa:bb:cc:dd:11:22') srv_msg.lease_file_contains('7777') srv_msg.lease_file_contains('123456789') srv_msg.lease_file_contains('my.host.some.name') 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 added a lease of address: 192.168.50.5 to a device with hardware address: 1a:1b:1c:1d:1e:1f, client-id: aa:bb:cc:dd:11:22 for 2 hrs 9 mins 37 secs' )
def test_control_channel_socket_config_get_basic(): 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() srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option(1) srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'OFFER') srv_msg.response_check_include_option(1) srv_msg.response_check_content('yiaddr', '192.168.50.5') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.generate_config_files() srv_msg.send_ctrl_cmd_via_socket( '{"command": "config-get","arguments": $(DHCP_CONFIG) }')
def test_hook_v4_lease_cmds_add_with_additional_values(): 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() 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_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.5') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.send_ctrl_cmd_via_socket( '{"command": "lease4-add","arguments": {"subnet-id": 1,"ip-address": "192.168.50.5","hw-address": "1a:1b:1c:1d:1e:1f","valid-lft":7777,"expire":123456789,"hostname":"my.host.some.name","client-id":"aa:bb:cc:dd:11:22"}}' ) # Now we have to check if lease 192.168.50.50 was actually added -- check leases file srv_msg.lease_file_contains('1a:1b:1c:1d:1e:1f') srv_msg.lease_file_contains('aa:bb:cc:dd:11:22') srv_msg.lease_file_contains('7777') srv_msg.lease_file_contains('123456789') srv_msg.lease_file_contains('my.host.some.name')
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() 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_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.5') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') srv_msg.send_ctrl_cmd_via_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_hook_v4_lease_cmds_get_1(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1') srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') 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') srv_msg.send_ctrl_cmd_via_socket('{"command":"lease4-get","arguments":{"ip-address": "192.168.50.1"}}')
def test_hook_v4_lease_cmds_add_outside_pool(): 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() 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_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_ctrl_cmd_via_socket('{"command": "lease4-add","arguments": {"subnet-id": 1,"ip-address": "192.168.50.50","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_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') # Now we have to check if lease 192.168.50.50 was actually added -- check leases file srv_msg.lease_file_contains('1a:1b:1c:1d:1e:1f')
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() srv_control.add_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_ctrl_cmd_via_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_hook_v6_network_cmds_add_on_relay_addr(): misc.test_setup() srv_control.config_srv_subnet('$(EMPTY)', '$(EMPTY)') srv_control.config_srv_opt('preference', '123') srv_control.config_srv_opt('domain-search', 'domain1.example.com,domain2.isc.org') srv_control.open_control_channel() srv_control.add_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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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') srv_msg.send_ctrl_cmd_via_socket( '{"command":"network6-add","arguments":{"shared-networks":[{"name": "name-abc","relay":{"ip-address":"2001:db8::abcd"},"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"valid-lifetime": 4000,"subnet6":[{"id":1,"pools": [{"pool": "2001:db8:1::1-2001:db8:1::10"}],"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:1::/64","valid-lifetime": 4000}]}]}}' ) srv_msg.send_ctrl_cmd_via_socket( '{"command":"network6-get","arguments":{"name": "name-abc"}}') srv_msg.forge_sleep('5', 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'interface-abc') srv_msg.client_does_include('RelayAgent', None, 'interface-id') srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8::abcd') 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')
def test_hook_v4_network_cmds_del_global_options(): misc.test_setup() srv_control.config_srv_opt('domain-name-servers', '199.199.199.1,100.100.100.1') srv_control.config_srv_subnet('192.168.50.0/24', '$(EMPTY)') srv_control.config_srv_another_subnet_no_interface( '192.168.51.0/24', '192.168.51.1-192.168.51.1') # first shared subnet 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.open_control_channel() srv_control.add_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_ctrl_cmd_via_socket( '{"command": "network4-del","arguments":{"name":"name-abc","subnets-action": "delete"}}' ) 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() # That needs subnet with empty pool to work misc.test_procedure() srv_msg.client_requests_option('6') 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_include_option('Response', None, '6') srv_msg.response_check_option_content('Response', '6', None, 'value', '199.199.199.1') srv_msg.response_check_option_content('Response', '6', None, 'value', '100.100.100.1')
def test_hook_v6_lease_cmds_add_expired_with_options(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::1') srv_control.config_srv_opt('preference', '123') srv_control.config_srv_opt('domain-search', 'domain1.example.com,domain2.isc.org') 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:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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::1') srv_msg.send_ctrl_cmd_via_socket('{"command": "lease6-add","arguments": {"subnet-id": 1,"ip-address": "2001:db8:1::1","duid": "1a:1b:1c:1d:1e:1f:20:21:22:23:24","iaid": 1234,"hw-address": "1a:2b:3c:4d:5e:6f","preferred-lft": 500,"valid-lft": 11111,"expire": 123456789,"fqdn-fwd": true,"fqdn-rev": true,"hostname": "urania.example.org"}}') # Using UNIX socket on server in path control_socket send {"command":"lease6-get","arguments":{"ip-address": "2001:db8:1::1"}} misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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::1') srv_msg.lease_file_contains('1a:2b:3c:4d:5e:6f') srv_msg.lease_file_contains('1a:1b:1c:1d:1e:1f:20:21:22:23:24') srv_msg.lease_file_contains('11111') srv_msg.lease_file_contains('123456789') srv_msg.lease_file_contains('urania.example.org')
def test_hook_v4_lease_cmds_del_using_hw_address(): 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_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')
def test_control_channel_socket_config_get(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::f') 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": {}}')
def test_hook_v6_lease_cmds_get_using_address(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::1') 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_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') 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::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:11:22:33:44:55:66') 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', '13') srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2') srv_msg.send_ctrl_cmd_via_socket('{"command":"lease6-get","arguments":{"ip-address": "2001:db8:1::1"}}')
def test_hook_v4_lease_cmds_legal_logging_update(): 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.config_srv_another_subnet_no_interface('10.0.0.0/24', '10.0.0.5-10.0.0.5') 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('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') srv_msg.lease_file_contains('192.168.50.1,ff:01:02:03:ff:04,,') srv_msg.lease_file_contains(',1,0,0,,0') srv_msg.send_ctrl_cmd_via_socket( '{"command":"lease4-update","arguments":{"ip-address": "192.168.50.1","hostname": "newhostname.example.org","hw-address": "1a:1b:1c:1d:1e:1f","subnet-id":1,"valid-lft":500000}}' ) 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 updated information on the lease of address: 192.168.50.1 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 5 days 18 hrs 53 mins 20 secs' )
def test_hook_v4_lease_cmds_list(): misc.test_setup() 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.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.send_ctrl_cmd_via_socket('{"command":"list-commands","arguments":{}}')
def test_hook_v6_lease_cmds_list(): misc.test_setup() srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::1') srv_control.config_srv_another_subnet_no_interface('1000::/32', '1000::5-1000::5') srv_control.config_srv_another_subnet_no_interface('3000::/100', '3000::5-3000::5') 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.send_ctrl_cmd_via_socket('{"command":"list-commands","arguments":{}}')
def test_hook_v6_lease_cmds_legal_logging_update(): 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('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::2') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_lease_cmds.so') srv_control.add_hooks('libdhcp_legal_log.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:66:55:44:33:22:11') srv_msg.client_sets_value('Client', 'ia_id', 666) 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) misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', '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.lease_file_contains('2001:db8:1::1,00:03:00:01:66:55:44:33:22:11,4000,') srv_msg.lease_file_contains(',1,3000,0,666,128,0,0,,66:55:44:33:22:11,0') srv_msg.lease_file_doesnt_contain('2001:db8:1::1,01:02:03:04:05:06:07:08') srv_msg.lease_file_doesnt_contain(',urania.example.org,1a:1b:1c:1d:1e:1f,') srv_msg.send_ctrl_cmd_via_socket('{"command":"lease6-update", "arguments":{"subnet-id": 1,"ip-address": "2001:db8:1::1","duid": "01:02:03:04:05:06:07:08","iaid": 1234,"hw-address": "1a:1b:1c:1d:1e:1f","preferred-lft": 500,"valid-lft": 1000,"hostname": "urania.example.org"}}') srv_msg.lease_file_contains(',1,500,0,1234,128,0,0,urania.example.org,1a:1b:1c:1d:1e:1f,0') srv_msg.lease_file_contains('2001:db8:1::1,01:02:03:04:05:06:07:08,1000') 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 updated information on the lease of address: 2001:db8:1::1 to a device with DUID: 01:02:03:04:05:06:07:08, hardware address: 1a:1b:1c:1d:1e:1f for 0 hrs 16 mins 40 secs')
def test_hook_v4_subnet_cmds_list(): misc.test_setup() 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.open_control_channel() srv_control.add_hooks('libdhcp_subnet_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket('{"command":"subnet4-get","arguments":{"id": 234}}', exp_result=3) # expect no such subnet i.e. 3
def test_hook_v4_subnet_cmds_get_by_subnet(): misc.test_setup() 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.config_srv('domain-name-servers', '1', '199.199.199.1,100.100.100.1') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_subnet_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket('{"command":"subnet4-get","arguments":{"subnet":"10.0.0.0/24"}}')
def test_hook_v4_subnet_cmds_get_by_id(): misc.test_setup() 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.config_srv_another_subnet_no_interface('150.0.0.0/24', '150.0.0.5-150.0.0.5') srv_control.config_srv('streettalk-directory-assistance-server', '2', '199.1.1.1,200.1.1.2') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_subnet_cmds.so') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket('{"command":"subnet4-get","arguments":{"id":3}}')
def test_hook_v6_network_cmds_add_on_interface(): misc.test_setup() srv_control.config_srv_subnet('$(EMPTY)', '$(EMPTY)') srv_control.config_srv_opt('preference', '123') # Server is configured with domain-search option with value domain1.example.com,domain2.isc.org. srv_control.open_control_channel() srv_control.add_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_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') 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') srv_msg.send_ctrl_cmd_via_socket( '{"command": "network6-add","arguments": {"shared-networks": [{"name": "name-abc","preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"valid-lifetime": 4000,"subnet6":[{"subnet":"2001:db8:a::/64","interface": "$(SERVER_IFACE)","pools":[{"pool":"2001:db8:a::1-2001:db8:a::1"}]}]}]}}' ) srv_msg.send_ctrl_cmd_via_socket( '{"command":"network6-get","arguments":{"name": "name-abc"}}') srv_msg.forge_sleep('5', 'seconds') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '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')