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_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'
    )
Beispiel #3
0
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_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('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')
Beispiel #5
0
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('libdhcp_user_chk.so')
    srv_control.build_and_send_config_files()
    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', '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::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_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')
Beispiel #7
0
def test_user_check_IA_NA_with_registry_unknown_user_logging():
    # With a user registry and multiple subnets
    # an unknown user should get last subnet

    misc.test_setup()
    srv_msg.send_file_to_server(
        'tests/dhcpv4/kea_only/user_chk/registry_1.txt',
        '/tmp/user_chk_registry.txt')
    srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt')
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.5')
    srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24',
                                                       '10.0.0.5-10.0.0.5')
    srv_control.add_hooks('libdhcp_user_chk.so')
    srv_control.configure_loggers('kea-dhcp4.callouts', 'DEBUG', 99)
    srv_control.configure_loggers('kea-dhcp4.hooks', 'INFO', 'None')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option(1)
    srv_msg.client_sets_value('Client', 'chaddr', '0c:0e:0a:01:ff:01')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_content('yiaddr', '10.0.0.5')
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')

    # Check the outcome file for correct content
    srv_msg.copy_remote('/tmp/user_chk_outcome.txt')
    srv_msg.compare_file('tests/dhcpv4/kea_only/user_chk/outcome_1.txt')
    srv_msg.log_contains(r'INFO  \[kea-dhcp4.hooks')
    srv_msg.log_contains(r'DEBUG \[kea-dhcp4.callouts')
def test_v4_legal_log_assigned_address_via_relay_pgsql_1():
    misc.test_procedure()
    srv_msg.remove_file_from_server(world.f_cfg.data_join('kea-legal*.txt'))

    misc.test_setup()
    srv_control.set_time('renew-timer', '3')
    srv_control.set_time('rebind-timer', '50')
    srv_control.set_time('valid-lifetime', '600')
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.2-192.168.50.2')
    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_does_include_with_value('client_id', '00010203040577')
    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', 'chaddr', '00:00:00:00:00:00')
    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_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_sets_value('Client', 'chaddr', '00:00:00:00:00:00')
    srv_msg.client_does_include_with_value('client_id', '00010203040577')
    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.2')
    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.2')
    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.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))

    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'Address: 192.168.50.2 has been assigned for 0 hrs 10 mins 0 secs to a device with hardware address: hwtype=1 00:00:00:00:00:00,'
    )
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'client-id: 00:01:02:03:04:05:77 connected via relay at address: $(GIADDR4)'
    )
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 test_v4_legal_log_assigned_address():
    misc.test_procedure()
    srv_msg.remove_file_from_server(world.f_cfg.data_join('kea-legal*.txt'))

    misc.test_setup()
    srv_control.set_time('renew-timer', '3')
    srv_control.set_time('rebind-timer', '50')
    srv_control.set_time('valid-lifetime', '600')
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.50')
    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', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value',
                                          '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value',
                                          '00010203040506')

    misc.test_procedure()
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value',
                                          '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value',
                                          '00010203040506')

    srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'Address: 192.168.50.1 has been assigned for 0 hrs 10 mins 0 secs')
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client-id: 00:01:02:03:04:05:06'
    )
def test_hook_v6_lease_cmds_legal_logging_add():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/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('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_lease_cmds.so')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_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('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/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')
Beispiel #12
0
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'
    )
Beispiel #13
0
def test_v4_legal_log_assigned_address_via_relay_pgsql_1():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    misc.test_setup()
    srv_control.set_time('renew-timer', '3')
    srv_control.set_time('rebind-timer', '50')
    srv_control.set_time('valid-lifetime', '600')
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.2-192.168.50.2')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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_does_include_with_value('client_id', '00010203040577')
    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', 'chaddr', '00:00:00:00:00:00')
    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_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_sets_value('Client', 'chaddr', '00:00:00:00:00:00')
    srv_msg.client_does_include_with_value('client_id', '00010203040577')
    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.2')
    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.2')
    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.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Address: 192.168.50.2 has been assigned for 0 hrs 10 mins 0 secs to a device with hardware address: hwtype=1 00:00:00:00:00:00,')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'client-id: 00:01:02:03:04:05:77 connected via relay at address: $(GIADDR4)')
def test_user_check_IA_NA_no_registry():
    # Without a user registry and multiple subnets
    # Subnet selection will use subnet interface for subnet selection hint

    misc.test_setup()
    srv_msg.remove_file_from_server('/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_during_process('DHCP', 'configuration')
Beispiel #15
0
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')
Beispiel #16
0
def test_v4_legal_log_assigned_address():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    misc.test_setup()
    srv_control.set_time('renew-timer', '3')
    srv_control.set_time('rebind-timer', '50')
    srv_control.set_time('valid-lifetime', '600')
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')

    misc.test_procedure()
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')

    srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Address: 192.168.50.1 has been assigned for 0 hrs 10 mins 0 secs')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client-id: 00:01:02:03:04:05:06')
Beispiel #17
0
def test_user_check_hook_IA_NA_no_registry():
    # Without a user registry and multiple subnets
    # Subnet selection will use subnet interface for subnet selection hint

    misc.test_setup()
    srv_msg.remove_file_from_server('/tmp/user_chk_registry.txt')
    srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt')
    srv_control.config_srv_subnet('3000::/64', '3000::5-3000::5')
    srv_control.config_srv_another_subnet_no_interface('1000::/64',
                                                       '1000::5-1000::5')
    srv_control.add_hooks('libdhcp_user_chk.so')
    srv_control.build_and_send_config_files()
    srv_control.start_srv_during_process('DHCP', 'configuration')
def test_user_check_hook_IA_NA_no_registry_logging():
    # Without a user registry and multiple subnets
    # Subnet selection will use subnet interface for subnet selection hint

    misc.test_setup()
    srv_msg.remove_file_from_server('/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.configure_loggers('kea-dhcp6.callouts', 'ERROR', 'None', 'kea.log')
    srv_control.configure_loggers('kea-dhcp6.hooks', 'ERROR', 'None', 'kea.log')
    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_during_process('DHCP', 'configuration')
Beispiel #19
0
def _create_pgsql_dump():
    # dump for postrgesql is bit different because we do not have config backend for postgres
    # but we will still use kea 1.6.3 to generate this. In future we will have to create new dump with
    # config backend data
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_PATH)/pg_db_v4.sql')
    world.f_cfg.multi_threading_enabled = False
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10')
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_cb_cmds.so')
    srv_control.add_hooks('libdhcp_mysql_cb.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    srv_control.enable_db_backend_reservation('PostgreSQL')
    srv_control.define_temporary_lease_db_backend('postgresql')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    hr = {"reservation": {"subnet-id": 1,
                          "hw-address": "01:0a:0b:0c:0d:0e:0f",
                          "ip-address": "192.168.50.205",
                          "next-server": "192.0.2.1",
                          "server-hostname": "hal9000",
                          "boot-file-name": "/dev/null",
                          "option-data": [{"name": "domain-name-servers",
                                           "data": "10.1.1.202,10.1.1.203"}],
                          "client-classes": ["special_snowflake", "office"]}}
    _send_cmd("reservation-add", hr)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')
    srv_msg.response_check_content('yiaddr', '192.168.50.10')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')

    # wanted to do this with fabric_sudo_command(cmd, sudo_user='******' but it failed
    cmd = "sudo -S -u postgres pg_dump %s >%s/pg_db_v4.sql" % (world.f_cfg.db_name, world.f_cfg.software_install_path)
    fabric_run_command(cmd, ignore_errors=False, destination_host=world.f_cfg.mgmt_address)
    srv_msg.execute_shell_cmd("sed -i 's/$(DB_USER)/!db_user!/g' %s/pg_db_v4.sql" % world.f_cfg.software_install_path)
Beispiel #20
0
def test_user_check_IA_NA_no_registry_logging():
    # Without a user registry and multiple subnets
    # Subnet selection will use subnet interface for subnet selection hint

    misc.test_setup()
    srv_msg.remove_file_from_server('/tmp/user_chk_registry.txt')
    srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt')
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.5')
    srv_control.config_srv_another_subnet_no_interface('10.0.0.0/24',
                                                       '10.0.0.5-10.0.0.5')
    srv_control.add_hooks('libdhcp_user_chk.so')
    srv_control.configure_loggers('kea-dhcp4.callouts', 'ERROR', 'None')
    srv_control.configure_loggers('kea-dhcp4.hooks', 'ERROR', 'None')
    srv_control.build_and_send_config_files()
    srv_control.start_srv_during_process('DHCP', 'configuration')
def test_user_check_hook_IA_NA_with_registry_unknown_user_logging():
    # With a user registry and multiple subnets
    # an unknown user should get last subnet

    misc.test_setup()
    srv_msg.send_file_to_server(
        'tests/dhcpv6/kea_only/user_chk/registry_1.txt',
        '/tmp/user_chk_registry.txt')
    srv_msg.remove_file_from_server('/tmp/user_chk_outcome.txt')
    srv_control.config_srv_subnet('3000::/64', '3000::5-3000::5')
    srv_control.config_srv_another_subnet_no_interface('1000::/64',
                                                       '1000::5-1000::5')
    srv_control.add_hooks('libdhcp_user_chk.so')
    srv_control.configure_loggers('kea-dhcp6.callouts', 'DEBUG', '99')
    srv_control.configure_loggers('kea-dhcp6.hooks', 'INFO', 'None')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    # Send a query from an unregistered user
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:ff:ff:ff:ff:ff:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA_Address')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    srv_msg.response_check_suboption_content('Response', '5', '3', None,
                                             'addr', '1000::5')
    # Check the outcome file for correct content
    srv_msg.copy_remote('/tmp/user_chk_outcome.txt')
    srv_msg.compare_file('tests/dhcpv6/kea_only/user_chk/outcome_1.txt')
    srv_msg.log_contains(r'INFO  \[kea-dhcp6.hooks')
    srv_msg.log_contains(r'DEBUG \[kea-dhcp6.callouts')
Beispiel #22
0
def test_v6_upgrade_pgsql_db():
    # new db parameters
    world.f_cfg.multi_threading_enabled = False
    tmp_db_name = "kea_tmp_db"
    tmp_user_name = "kea_tmp_user"
    # create new db without schema
    srv_control.build_database(db_name=tmp_db_name,
                               db_user=tmp_user_name,
                               init_db=False)
    # send db dump file
    srv_msg.remove_file_from_server('/tmp/pg_db_v6.sql')
    srv_msg.send_file_to_server('tests/dhcpv6/db_upgrade/pg_db_v6.sql',
                                '/tmp/pg_db_v6.sql')
    # switch username to the one setup is using
    srv_msg.execute_shell_cmd("sed -i 's/!db_user!/%s/g' /tmp/pg_db_v6.sql" %
                              tmp_user_name)
    # recreate db content in new db

    cmd = "sudo -S -u postgres psql -d %s -f/tmp/pg_db_v6.sql" % tmp_db_name
    fabric_run_command(cmd,
                       ignore_errors=False,
                       destination_host=world.f_cfg.mgmt_address)

    # start kea, which should fail due to mismatch in db version
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::10-2001:db8:1::10')
    srv_control.config_srv_prefix('2001:db8:2::', 0, 90, 96)
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    hosts = {
        "hosts-databases": [{
            "user": tmp_user_name,
            "password": "******",
            "name": tmp_db_name,
            "type": "postgresql"
        }]
    }

    leases = {
        "lease-database": {
            "user": tmp_user_name,
            "password": "******",
            "name": tmp_db_name,
            "type": "postgresql"
        }
    }
    world.dhcp_cfg.update(hosts)
    world.dhcp_cfg.update(leases)
    srv_control.build_and_send_config_files()
    srv_control.start_srv_during_process('DHCP', 'started')

    kea_admin = world.f_cfg.sbin_join('kea-admin')
    srv_msg.execute_shell_cmd(
        "sudo %s db-upgrade pgsql -u %s -p $(DB_PASSWD) -n %s" %
        (kea_admin, tmp_user_name, tmp_db_name))

    # start kea
    srv_control.start_srv('DHCP', 'started')

    # check reservation
    hr_get = {
        "subnet-id": 1,
        "identifier-type": "duid",
        "identifier": "01:02:03:04:05:06:07:08:09:0A"
    }
    resp = _send_cmd("reservation-get", hr_get)["arguments"]
    assert resp["duid"] == "01:02:03:04:05:06:07:08:09:0a"
    assert resp["hostname"] == "foo.example.com"
    assert resp["ip-addresses"] == ["2001:db8:1::100"]
    assert resp["option-data"] == [{
        "always-send": False,
        "code": 17,
        "csv-format": True,
        "data": "4491",
        "name": "vendor-opts",
        "space": "dhcp6"
    }]
    assert resp["prefixes"] == ["2001:db8:2:abcd::/64"]

    # check lease
    lease_get = {"duid": "00:03:00:01:f6:f5:f4:f3:f2:01"}
    resp = _send_cmd("lease6-get-by-duid", lease_get)["arguments"]
    assert len(resp["leases"]) == 2
    for lease in resp["leases"]:
        if lease["type"] == "IA_NA":
            assert lease["duid"] == "00:03:00:01:f6:f5:f4:f3:f2:01"
            assert lease["hw-address"] == "f6:f5:f4:f3:f2:01"
            assert lease["iaid"] == 55701
            assert lease["ip-address"] == "2001:db8:1::10"
            assert lease["preferred-lft"] == 3000
            assert lease["state"] == 0
            assert lease["subnet-id"] == 1
            assert lease["valid-lft"] == 4000
        if lease["type"] == "IA_PD":
            assert lease["duid"] == "00:03:00:01:f6:f5:f4:f3:f2:01"
            assert lease["hw-address"] == "f6:f5:f4:f3:f2:01"
            assert lease["iaid"] == 76159
            assert lease["ip-address"] == "2001:db8:2::"
            assert lease["preferred-lft"] == 3000
            assert lease["prefix-len"] == 96
            assert lease["state"] == 0
            assert lease["subnet-id"] == 1
            assert lease["valid-lft"] == 4000
def test_user_check_hook_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/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.configure_loggers('kea-dhcp6.callouts', 'DEBUG', '99', 'kea.log')
    srv_control.configure_loggers('kea-dhcp6.hooks', 'DEBUG', '99', 'kea.log')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    # DHCP server failed to start. During configuration process.
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    # Send a query from an unregistered user
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA_Address')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '1000::5')
    # Check the outcome file for correct content
    srv_msg.copy_remote('/tmp/user_chk_outcome.txt')
    srv_msg.compare_file('tests/dhcpv6/kea_only/user_chk/outcome_1.txt')

    srv_msg.forge_sleep('10', 'seconds')

    srv_control.start_srv('DHCP', 'stopped')
    misc.test_setup()
    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.configure_loggers('kea-dhcp6.callouts', 'DEBUG', '99', 'kea.log')
    srv_control.configure_loggers('kea-dhcp6.hooks', 'INFO', 'None', 'kea.log')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    # Send a query from an unregistered user
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:02')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA_Address')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '1000::5')
    # Check the outcome file for correct content
    srv_msg.copy_remote('/tmp/user_chk_outcome.txt')
def test_hook_v6_lease_cmds_legal_logging_del_using_address():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/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.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.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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_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_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"lease6-del","arguments":{"ip-address": "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', '5')
    srv_msg.response_check_suboption_content('Response',
                                             '5',
                                             '3',
                                             None,
                                             'addr',
                                             '2001:db8:1::1')

    srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Administrator deleted the lease for address: 2001:db8:1::1')
def test_hook_v6_lease_cmds_legal_logging_update():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/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('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_lease_cmds.so')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/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_sets_value('Client', 'ia_id', '666')
    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')

    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.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               '2001:db8:1::1,00:03:00:01:66:55:44:33:22:11,4000,')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               ',1,3000,0,666,128,0,0,,66:55:44:33:22:11,0')

    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               'NOT ',
                               '2001:db8:1::1,01:02:03:04:05:06:07:08')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               'NOT ',
                               ',urania.example.org,1a:1b:1c:1d:1e:1f,')

    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_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.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               ',1,500,0,1234,128,0,0,urania.example.org,1a:1b:1c:1d:1e:1f,0')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               '2001:db8:1::1,01:02:03:04:05:06:07:08,1000')

    srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               '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_v6_lease_cmds_legal_logging_wipe():
    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('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, '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')

    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',
                                          '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:11:22:33:44:55:66')
    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')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:11:11:11:11:11: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":"lease6-wipe", "arguments": {"subnet-id":1}}')

    srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))
    srv_msg.test_fail()
Beispiel #27
0
def test_hook_v4_lease_cmds_legal_logging_wipe():
    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.2')
    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')

    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')

    srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))
    srv_msg.test_fail()
def test_user_check_hook_vendor_options_all():

    # Install the requisite user registry file onto the server and then
    # Configure the server with two subnets.  The first subnet will be used
    # for registeted users, the second for unregistered users.
    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::20')
    srv_control.config_srv_another_subnet_no_interface('1000:1::/64',
                                                       '1000:1::5-1000:1::5')
    srv_control.add_hooks('libdhcp_user_chk.so')
    srv_control.config_srv_opt_space('vendor-4491', 'tftp-servers', '7000::1')
    srv_control.config_srv_opt_space('vendor-4491', 'config-file',
                                     'bootfile.from.server')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    #
    # Send a query from an unknown user
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:ff:ff:ff:ff:ff:01')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # We don't really care about the address value
    # Options should come from default user in registry
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 9000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '33')
    srv_msg.response_check_suboption_content('Response', '33', '17', None,
                                             'config-file',
                                             'bootfile.from.default')

    #
    # Send a query from a registered user with no properties
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:11:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # We don't really care about the address value
    # Options should come from server config
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 7000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '33')
    srv_msg.response_check_suboption_content('Response', '33', '17', None,
                                             'config-file',
                                             'bootfile.from.server')

    #
    # Send a query from a registered user who supplies only bootfile
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:22:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # We don't really care about the address value
    # bootfile should be from user, tftp server from server config
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 7000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '33')
    srv_msg.response_check_suboption_content('Response', '33', '17', None,
                                             'config-file',
                                             'bootfile.from.user')

    #
    # Send a query from a registered user who supplies only tftp server
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:33:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # We don't really care about the address value
    # bootfile should be from server config, tftp server from user
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 8000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '33')
    srv_msg.response_check_suboption_content('Response', '33', '17', None,
                                             'config-file',
                                             'bootfile.from.server')

    misc.test_procedure()
    # Send a query from a registered user who supplies both tftp server and bootfile
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:44:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # We don't really care about the address value
    # tftp server and bootfile should be from user
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 8002::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option',
                                          '33')
    srv_msg.response_check_suboption_content('Response', '33', '17', None,
                                             'config-file',
                                             'bootfile.from.user-2')
Beispiel #29
0
def test_v4_all_hooks_test_cooperation():
    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.10')
    # flex id
    srv_control.host_reservation_in_subnet('hostname', 'reserved-hostname',
                                           '0', 'flex-id', '\'docsis3.0\'')
    srv_control.host_reservation_in_subnet_add_value('0', '0', 'address',
                                                     '192.168.50.10')
    srv_control.add_line(
        '"host-reservation-identifiers": [ "flex-id","hw-address" ]')
    srv_control.add_hooks('libdhcp_flex_id.so')
    srv_control.add_parameter_to_hook('1', 'identifier-expression',
                                      'option[60].hex')
    # legal log
    srv_control.add_hooks('libdhcp_legal_log.so')
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    # Add hooks library located libdhcp_host_cmds.so.
    # Add hooks library located libdhcp_stat_cmds.so.
    # Add hooks library located libdhcp_subnet_cmds.so.
    # Add hooks library located libdhcp_host_cache.so.
    #
    # Add High-Availability hook library located libdhcp_ha.so.
    # To HA hook configuration add this-server-name with value: "server1"
    # To HA hook configuration add mode with value: "load-balancing"
    # To HA hook configuration add heartbeat-delay with value: 1000
    # To HA hook configuration add max-response-delay with value: 1001
    # To HA hook configuration add max-unacked-clients with value: 0
    # To HA hook configuration add max-ack-delay with value: 0
    #
    # To HA hook configuration add peers with value: {"name":"server1","url":"http://$(MGMT_ADDRESS):8080/","role":"primary","auto-failover":true}
    # To HA hook configuration add peers with value: {"name":"server2","url":"http://$(MGMT_ADDRESS_2):8080/","role":"secondary","auto-failover":true}

    srv_control.open_control_channel()
    srv_control.agent_control_channel(host_port='8080')
    srv_control.build_and_send_config_files('SSH', 'config-file')

    srv_control.start_srv('DHCP', 'started')

    # Using UNIX socket on server in path control_socket send {"command": "list-commands","arguments": {}}
    # JSON response in arguments MUST include value: build-report
    # JSON response in arguments MUST include value: cache-clear
    # JSON response in arguments MUST include value: cache-flush
    # JSON response in arguments MUST include value: cache-get
    # JSON response in arguments MUST include value: cache-insert
    # JSON response in arguments MUST include value: cache-load
    # JSON response in arguments MUST include value: cache-remove
    # JSON response in arguments MUST include value: cache-write
    # JSON response in arguments MUST include value: config-get
    # JSON response in arguments MUST include value: config-reload
    # JSON response in arguments MUST include value: config-set
    # JSON response in arguments MUST include value: config-test
    # JSON response in arguments MUST include value: config-write
    # JSON response in arguments MUST include value: dhcp-disable
    # JSON response in arguments MUST include value: dhcp-enable
    # JSON response in arguments MUST include value: ha-continue
    # JSON response in arguments MUST include value: ha-heartbeat
    # JSON response in arguments MUST include value: ha-scopes
    # JSON response in arguments MUST include value: ha-sync
    # JSON response in arguments MUST include value: lease4-add
    # JSON response in arguments MUST include value: lease4-del
    # JSON response in arguments MUST include value: lease4-get
    # JSON response in arguments MUST include value: lease4-get-all
    # JSON response in arguments MUST include value: lease4-get-page
    # JSON response in arguments MUST include value: lease4-update
    # JSON response in arguments MUST include value: lease4-wipe
    # JSON response in arguments MUST include value: lease6-add
    # JSON response in arguments MUST include value: lease6-del
    # JSON response in arguments MUST include value: lease6-get
    # JSON response in arguments MUST include value: lease6-get-all
    # JSON response in arguments MUST include value: lease6-get-page
    # JSON response in arguments MUST include value: lease6-update
    # JSON response in arguments MUST include value: lease6-wipe
    # JSON response in arguments MUST include value: leases-reclaim
    # JSON response in arguments MUST include value: libreload
    # JSON response in arguments MUST include value: list-commands
    # JSON response in arguments MUST include value: network4-add
    # JSON response in arguments MUST include value: network4-del
    # JSON response in arguments MUST include value: network4-get
    # JSON response in arguments MUST include value: network4-list
    # JSON response in arguments MUST include value: network4-subnet-add
    # JSON response in arguments MUST include value: network4-subnet-del
    # JSON response in arguments MUST include value: network6-add
    # JSON response in arguments MUST include value: network6-del
    # JSON response in arguments MUST include value: network6-get
    # JSON response in arguments MUST include value: network6-list
    # JSON response in arguments MUST include value: network6-subnet-add
    # JSON response in arguments MUST include value: network6-subnet-del
    # JSON response in arguments MUST include value: reservation-add
    # JSON response in arguments MUST include value: reservation-del
    # JSON response in arguments MUST include value: reservation-get
    # JSON response in arguments MUST include value: shutdown
    # JSON response in arguments MUST include value: stat-lease4-get
    # JSON response in arguments MUST include value: stat-lease6-get
    # JSON response in arguments MUST include value: statistic-get
    # JSON response in arguments MUST include value: statistic-get-all
    # JSON response in arguments MUST include value: statistic-remove
    # JSON response in arguments MUST include value: statistic-remove-all
    # JSON response in arguments MUST include value: statistic-reset
    # JSON response in arguments MUST include value: statistic-reset-all
    # JSON response in arguments MUST include value: subnet4-add
    # JSON response in arguments MUST include value: subnet4-del
    # JSON response in arguments MUST include value: subnet4-get
    # JSON response in arguments MUST include value: subnet4-list
    # JSON response in arguments MUST include value: subnet6-add
    # JSON response in arguments MUST include value: subnet6-del
    # JSON response in arguments MUST include value: subnet6-get
    # JSON response in arguments MUST include value: subnet6-list
    # JSON response in arguments MUST include value: version-get
    # ha command
    # Using existing HTTP $(MGMT_ADDRESS):8080 connection send: {"command": "ha-heartbeat","service":["dhcp4"],"arguments": {} }
    # JSON response in arguments MUST include value: "state": "partner-down"
    # flex-id
    misc.test_procedure()
    srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')

    # legal log
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value',
                                          '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value',
                                          '00010203040506')

    misc.test_procedure()
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value',
                                          '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value',
                                          '00010203040506')

    srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))

    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'Address: 192.168.50.1 has been assigned for 1 hrs 6 mins 40')
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client-id: 00:01:02:03:04:05:06'
    )

    # lease commands
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"lease4-add","arguments":{"ip-address": "192.168.50.10","hostname": "newhostname.example.org","hw-address": "1a:1b:1c:1d:1e:1f","subnet-id":1,"valid-lft":500000}}'
    )
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'Administrator added a lease of address: 192.168.50.10 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 5 days 18 hrs 53 mins 20 secs'
    )

    #
    # Test Procedure:
    # Client sets chaddr value to 1a:1b:1c:1d:1e:1f.
    # Client sets ciaddr value to 192.168.50.10.
    # Client copies server_id option from received message.
    # Client sends REQUEST message.
    #
    # Pass Criteria:
    # Server MUST respond with ACK message.
    # Response MUST contain yiaddr 192.168.50.10.
    # Response MUST include option 54.
    # Response option 54 MUST contain value $(SRV4_ADDR).
    srv_msg.copy_remote(world.f_cfg.data_join('kea-legal*.txt'))
Beispiel #30
0
def _create_pgsql_dump():
    # dump for postrgesql is bit different because we do not have config backend for postgres
    # but we will still use kea 1.6.3 to generate this. In future we will have to create new dump with
    # config backend data
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_PATH)/pg_db_v6.sql')
    world.f_cfg.multi_threading_enabled = False
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::10-2001:db8:1::10')
    srv_control.config_srv_prefix('2001:db8:2::', 0, 90, 96)
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_cb_cmds.so')
    srv_control.add_hooks('libdhcp_mysql_cb.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    srv_control.enable_db_backend_reservation('PostgreSQL')
    srv_control.define_temporary_lease_db_backend('postgresql')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    hr = {
        "reservation": {
            "subnet-id": 1,
            "duid": "01:02:03:04:05:06:07:08:09:0A",
            "ip-addresses": ["2001:db8:1::100"],
            "prefixes": ["2001:db8:2:abcd::/64"],
            "hostname": "foo.example.com",
            "option-data": [{
                "name": "vendor-opts",
                "data": "4491"
            }]
        }
    }
    _send_cmd("reservation-add", hr)

    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', 'ia_id', 55701)
    srv_msg.client_sets_value('Client', 'ia_pd', 76159)
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('server-id')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('IA_PD')
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'REPLY')
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::10')

    # wanted to do this with fabric_sudo_command(cmd, sudo_user='******' but it failed
    cmd = "sudo -S -u postgres pg_dump %s >%s/pg_db_v6.sql" % (
        world.f_cfg.db_name, world.f_cfg.software_install_path)
    fabric_run_command(cmd,
                       ignore_errors=False,
                       destination_host=world.f_cfg.mgmt_address)
    srv_msg.execute_shell_cmd(
        "sed -i 's/$(DB_USER)/!db_user!/g' %s/pg_db_v6.sql" %
        world.f_cfg.software_install_path)
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('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 kea.log MUST contain line or phrase: INFO  \[kea-dhcp4.hooks
    # File stored in 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('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 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'
    )
Beispiel #33
0
def test_v4_legal_log_rebind_address():
    misc.test_procedure()
    srv_msg.remove_file_from_server(world.f_cfg.data_join('kea-legal*.txt'))

    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.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', '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', 'OFFER')
    srv_msg.response_check_content('yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(54)
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    srv_msg.response_check_option_content(54, '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', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(54)
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    srv_msg.response_check_option_content(54, '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', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option(54)
    srv_msg.response_check_option_content(54, 'value', '$(SRV4_ADDR)')

    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,
        'Address: 192.168.50.1 has been renewed for 0 hrs 10 mins 0 secs')
    srv_msg.file_contains_line(
        world.f_cfg.data_join('kea-legal*.txt'), None,
        'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04 connected via relay at address: $(GIADDR4)'
    )
Beispiel #34
0
def test_v6_upgrade_mysql_db():
    # new db parameters
    tmp_db_name = "kea_tmp_db"
    tmp_user_name = "kea_tmp_user"
    # # make sure that new db does not exists
    # srv_msg.execute_shell_cmd("mysql -u root -N -B -e \"DROP DATABASE IF EXISTS %s;\"" % tmp_db_name)
    # create new db without schema
    srv_control.build_database(db_name=tmp_db_name,
                               db_user=tmp_user_name,
                               init_db=False)
    # send db dump file
    srv_msg.remove_file_from_server('/tmp/my_db_v6.sql')
    srv_msg.send_file_to_server('tests/dhcpv6/db_upgrade/my_db_v6.sql',
                                '/tmp/my_db_v6.sql')
    # switch interface and username to the one setup is using
    srv_msg.execute_shell_cmd(
        "sed -i 's/!serverinterface!/$(SERVER_IFACE)/g' /tmp/my_db_v6.sql")
    srv_msg.execute_shell_cmd("sed -i 's/!db_user!/%s/g' /tmp/my_db_v6.sql" %
                              tmp_user_name)
    # recreate db content in new db
    srv_msg.execute_shell_cmd(
        "mysql -u%s -p$(DB_PASSWD) %s < /tmp/my_db_v6.sql" %
        (tmp_user_name, tmp_db_name))
    # start kea, which should fail due to mismatch in db version
    misc.test_setup()
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.add_hooks('libdhcp_cb_cmds.so')
    srv_control.add_hooks('libdhcp_mysql_cb.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    hosts = {
        "hosts-databases": [{
            "user": tmp_user_name,
            "password": "******",
            "name": tmp_db_name,
            "type": "mysql"
        }]
    }

    leases = {
        "lease-database": {
            "user": tmp_user_name,
            "password": "******",
            "name": tmp_db_name,
            "type": "mysql"
        }
    }

    cb_config = {
        "config-databases": [{
            "user": tmp_user_name,
            "password": "******",
            "name": tmp_db_name,
            "type": "mysql"
        }]
    }
    world.dhcp_cfg.update(hosts)
    world.dhcp_cfg.update(leases)
    world.dhcp_cfg["config-control"] = cb_config
    world.dhcp_cfg["server-tag"] = "abc"
    srv_control.build_and_send_config_files()
    srv_control.start_srv_during_process('DHCP', 'started')
    # upgrade with kea admin
    kea_admin = world.f_cfg.sbin_join('kea-admin')
    srv_msg.execute_shell_cmd(
        "sudo %s db-upgrade mysql -u %s -p $(DB_PASSWD) -n %s" %
        (kea_admin, tmp_user_name, tmp_db_name))

    # start kea
    srv_control.start_srv('DHCP', 'started')

    # check reservation
    hr_get = {
        "subnet-id": 2,
        "identifier-type": "duid",
        "identifier": "01:02:03:04:05:06:07:08:09:0A"
    }
    resp = _send_cmd("reservation-get", hr_get)["arguments"]
    assert resp["duid"] == "01:02:03:04:05:06:07:08:09:0a"
    assert resp["hostname"] == "foo.example.com"
    assert resp["ip-addresses"] == ["2001:db8:1::1"]
    assert resp["option-data"] == [{
        "always-send": False,
        "code": 17,
        "csv-format": True,
        "data": "4491",
        "name": "vendor-opts",
        "space": "dhcp6"
    }]
    assert resp["prefixes"] == ["2001:db8:2:abcd::/64"]

    # check lease
    lease_get = {"duid": "00:03:00:01:f6:f5:f4:f3:f2:01"}
    resp = _send_cmd("lease6-get-by-duid", lease_get)["arguments"]
    assert len(resp["leases"]) == 2
    for lease in resp["leases"]:
        if lease["type"] == "IA_NA":
            assert lease["duid"] == "00:03:00:01:f6:f5:f4:f3:f2:01"
            assert lease["hw-address"] == "f6:f5:f4:f3:f2:01"
            assert lease["iaid"] == 61439
            assert lease["ip-address"] == "2001:db8:1::10"
            assert lease["preferred-lft"] == 3000
            assert lease["state"] == 0
            assert lease["subnet-id"] == 2
            assert lease["valid-lft"] == 1000
        if lease["type"] == "IA_PD":
            assert lease["duid"] == "00:03:00:01:f6:f5:f4:f3:f2:01"
            assert lease["hw-address"] == "f6:f5:f4:f3:f2:01"
            assert lease["iaid"] == 24511
            assert lease["ip-address"] == "2001:db8:2::"
            assert lease["preferred-lft"] == 3000
            assert lease["prefix-len"] == 91
            assert lease["state"] == 0
            assert lease["subnet-id"] == 2
            assert lease["valid-lft"] == 1000

    # check config
    cmd = dict(command="config-get", arguments={})
    cfg = srv_msg.send_ctrl_cmd(cmd, exp_result=0)["arguments"]

    assert len(cfg["Dhcp6"]["subnet6"]) == 1
    assert len(cfg["Dhcp6"]["option-def"]) == 1
    assert len(cfg["Dhcp6"]["option-data"]) == 1
    assert len(cfg["Dhcp6"]["shared-networks"]) == 1

    # let's check subnet and network parameters one by one, it's possible that new
    # parameters will be added in future and it will trash this test, we are sure that
    # no new parameters will be added in 1.6.3 schema.
    resp = _send_cmd("remote-subnet6-get-by-id", {"subnets": [{
        "id": 2
    }]})["arguments"]
    assert resp["count"] == 1
    subnet = resp["subnets"][0]
    assert subnet["id"] == 2
    assert subnet["metadata"] == {"server-tags": ["abc"]}
    assert subnet["option-data"] == [{
        "always-send": True,
        "code": 7,
        "csv-format": True,
        "data": "123",
        "name": "preference",
        "space": "dhcp6"
    }]

    assert subnet["pools"][0] == {
        "option-data": [{
            "always-send": True,
            "code": 7,
            "csv-format": True,
            "data": "12",
            "name": "preference",
            "space": "dhcp6"
        }],
        "pool":
        "2001:db8:1::10/128"
    }
    assert subnet["pd-pools"] == [{
        "delegated-len": 91,
        "option-data": [],
        "prefix": "2001:db8:2::",
        "prefix-len": 90
    }]
    assert subnet["rebind-timer"] == 500
    assert subnet["renew-timer"] == 200
    assert subnet["shared-network-name"] is None
    assert subnet["subnet"] == "2001:db8:1::/64"
    assert subnet["valid-lifetime"] == 1000

    resp = _send_cmd("remote-network6-get",
                     {"shared-networks": [{
                         "name": "net1"
                     }]})["arguments"]
    assert resp["count"] == 1
    network = resp["shared-networks"][0]
    assert network["client-class"] == "abc"
    assert network["metadata"] == {"server-tags": ["abc"]}
    assert network["name"] == "net1"
    assert network["option-data"] == [{
        "always-send": True,
        "code": 7,
        "csv-format": True,
        "data": "123",
        "name": "preference",
        "space": "dhcp6"
    }]
    assert network["rebind-timer"] == 200
    assert network["renew-timer"] == 100
    assert network["require-client-classes"] == ["XYZ"]
    assert network["user-context"] == {"some weird network": 55}
    assert network["valid-lifetime"] == 300

    resp = _send_cmd("remote-global-parameter6-get", {
        "server-tags": ["abc"],
        "parameters": ["decline-probation-period"]
    })["arguments"]
    assert resp["count"] == 1
    assert resp["parameters"] == {
        "decline-probation-period": 123456,
        "metadata": {
            "server-tags": ["abc"]
        }
    }

    resp = _send_cmd("remote-option6-global-get", {
        "server-tags": ["abc"],
        "options": [{
            "code": 21
        }]
    })["arguments"]
    assert resp["count"] == 1
    assert resp["options"][0] == {
        "always-send": False,
        "code": 21,
        "csv-format": True,
        "data": "isc.example.com",
        "metadata": {
            "server-tags": ["abc"]
        },
        "name": "sip-server-dns",
        "space": "dhcp6"
    }

    resp = _send_cmd("remote-option-def6-get", {
        "server-tags": ["abc"],
        "option-defs": [{
            "code": 222
        }]
    })["arguments"]
    assert resp["count"] == 1
    assert resp["option-defs"][0] == {
        "array": False,
        "code": 222,
        "encapsulate": "",
        "metadata": {
            "server-tags": ["abc"]
        },
        "name": "foo",
        "record-types": "",
        "space": "dhcp6",
        "type": "uint32"
    }
Beispiel #35
0
def test_v4_all_hooks_test_cooperation():

    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.10')
    # flex id
    srv_control.host_reservation_in_subnet('hostname',
                                           'reserved-hostname',
                                           '0',
                                           'flex-id',
                                           '\'docsis3.0\'')
    srv_control.host_reservation_in_subnet_add_value('0', '0', 'address', '192.168.50.10')
    srv_control.add_line('"host-reservation-identifiers": [ "flex-id","hw-address" ]')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so')
    srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex')
    # legal log
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_legal_log.so')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_lease_cmds.so')
    # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so.
    # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_stat_cmds.so.
    # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so.
    # Add hooks library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cache.so.
    #
    # Add High-Availability hook library located $(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_ha.so.
    # To HA hook configuration add this-server-name with value: "server1"
    # To HA hook configuration add mode with value: "load-balancing"
    # To HA hook configuration add heartbeat-delay with value: 1000
    # To HA hook configuration add max-response-delay with value: 1001
    # To HA hook configuration add max-unacked-clients with value: 0
    # To HA hook configuration add max-ack-delay with value: 0
    #
    # To HA hook configuration add peers with value: {"name":"server1","url":"http://$(MGMT_ADDRESS):8080/","role":"primary","auto-failover":true}
    # To HA hook configuration add peers with value: {"name":"server2","url":"http://$(MGMT_ADDRESS_2):8080/","role":"secondary","auto-failover":true}

    srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.agent_control_channel('$(MGMT_ADDRESS)',
                                      '8080',
                                      'unix',
                                      '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.build_and_send_config_files('SSH', 'config-file')

    srv_control.start_srv('DHCP', 'started')

    # Using UNIX socket on server in path $(SOFTWARE_INSTALL_DIR)/var/kea/control_socket send {"command": "list-commands","arguments": {}}
    # JSON response in arguments MUST include value: build-report
    # JSON response in arguments MUST include value: cache-clear
    # JSON response in arguments MUST include value: cache-flush
    # JSON response in arguments MUST include value: cache-get
    # JSON response in arguments MUST include value: cache-insert
    # JSON response in arguments MUST include value: cache-load
    # JSON response in arguments MUST include value: cache-remove
    # JSON response in arguments MUST include value: cache-write
    # JSON response in arguments MUST include value: config-get
    # JSON response in arguments MUST include value: config-reload
    # JSON response in arguments MUST include value: config-set
    # JSON response in arguments MUST include value: config-test
    # JSON response in arguments MUST include value: config-write
    # JSON response in arguments MUST include value: dhcp-disable
    # JSON response in arguments MUST include value: dhcp-enable
    # JSON response in arguments MUST include value: ha-continue
    # JSON response in arguments MUST include value: ha-heartbeat
    # JSON response in arguments MUST include value: ha-scopes
    # JSON response in arguments MUST include value: ha-sync
    # JSON response in arguments MUST include value: lease4-add
    # JSON response in arguments MUST include value: lease4-del
    # JSON response in arguments MUST include value: lease4-get
    # JSON response in arguments MUST include value: lease4-get-all
    # JSON response in arguments MUST include value: lease4-get-page
    # JSON response in arguments MUST include value: lease4-update
    # JSON response in arguments MUST include value: lease4-wipe
    # JSON response in arguments MUST include value: lease6-add
    # JSON response in arguments MUST include value: lease6-del
    # JSON response in arguments MUST include value: lease6-get
    # JSON response in arguments MUST include value: lease6-get-all
    # JSON response in arguments MUST include value: lease6-get-page
    # JSON response in arguments MUST include value: lease6-update
    # JSON response in arguments MUST include value: lease6-wipe
    # JSON response in arguments MUST include value: leases-reclaim
    # JSON response in arguments MUST include value: libreload
    # JSON response in arguments MUST include value: list-commands
    # JSON response in arguments MUST include value: network4-add
    # JSON response in arguments MUST include value: network4-del
    # JSON response in arguments MUST include value: network4-get
    # JSON response in arguments MUST include value: network4-list
    # JSON response in arguments MUST include value: network4-subnet-add
    # JSON response in arguments MUST include value: network4-subnet-del
    # JSON response in arguments MUST include value: network6-add
    # JSON response in arguments MUST include value: network6-del
    # JSON response in arguments MUST include value: network6-get
    # JSON response in arguments MUST include value: network6-list
    # JSON response in arguments MUST include value: network6-subnet-add
    # JSON response in arguments MUST include value: network6-subnet-del
    # JSON response in arguments MUST include value: reservation-add
    # JSON response in arguments MUST include value: reservation-del
    # JSON response in arguments MUST include value: reservation-get
    # JSON response in arguments MUST include value: shutdown
    # JSON response in arguments MUST include value: stat-lease4-get
    # JSON response in arguments MUST include value: stat-lease6-get
    # JSON response in arguments MUST include value: statistic-get
    # JSON response in arguments MUST include value: statistic-get-all
    # JSON response in arguments MUST include value: statistic-remove
    # JSON response in arguments MUST include value: statistic-remove-all
    # JSON response in arguments MUST include value: statistic-reset
    # JSON response in arguments MUST include value: statistic-reset-all
    # JSON response in arguments MUST include value: subnet4-add
    # JSON response in arguments MUST include value: subnet4-del
    # JSON response in arguments MUST include value: subnet4-get
    # JSON response in arguments MUST include value: subnet4-list
    # JSON response in arguments MUST include value: subnet6-add
    # JSON response in arguments MUST include value: subnet6-del
    # JSON response in arguments MUST include value: subnet6-get
    # JSON response in arguments MUST include value: subnet6-list
    # JSON response in arguments MUST include value: version-get
    # ha command
    # Using existing HTTP $(MGMT_ADDRESS):8080 connection send: {"command": "ha-heartbeat","service":["dhcp4"],"arguments": {} }
    # JSON response in arguments MUST include value: "state": "partner-down"
    # flex-id
    misc.test_procedure()
    srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')

    # legal log
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')

    misc.test_procedure()
    srv_msg.client_does_include_with_value('client_id', '00010203040506')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.1')
    srv_msg.client_requests_option('1')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '54')
    srv_msg.response_check_include_option('Response', None, '61')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    srv_msg.response_check_option_content('Response', '61', None, 'value', '00010203040506')

    srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Address: 192.168.50.1 has been assigned for 1 hrs 6 mins 40')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04, client-id: 00:01:02:03:04:05:06')

    # lease commands
    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"lease4-add","arguments":{"ip-address": "192.168.50.10","hostname": "newhostname.example.org","hw-address": "1a:1b:1c:1d:1e:1f","subnet-id":1,"valid-lft":500000}}')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Administrator added a lease of address: 192.168.50.10 to a device with hardware address: 1a:1b:1c:1d:1e:1f for 5 days 18 hrs 53 mins 20 secs')

    #
    # Test Procedure:
    # Client sets chaddr value to 1a:1b:1c:1d:1e:1f.
    # Client sets ciaddr value to 192.168.50.10.
    # Client copies server_id option from received message.
    # Client sends REQUEST message.
    #
    # Pass Criteria:
    # Server MUST respond with ACK message.
    # Response MUST contain yiaddr 192.168.50.10.
    # Response MUST include option 54.
    # Response option 54 MUST contain value $(SRV4_ADDR).
    srv_msg.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
Beispiel #36
0
def test_v4_legal_log_rebind_address():
    misc.test_procedure()
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')

    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('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_legal_log.so')
    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.copy_remote('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'Address: 192.168.50.1 has been renewed for 0 hrs 10 mins 0 secs')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-legal*.txt',
                               None,
                               'to a device with hardware address: hwtype=1 ff:01:02:03:ff:04 connected via relay at address: $(GIADDR4)')
Beispiel #37
0
def _create_mysql_dump():
    # start Kea with specific version, run this and you will get DB dump with data in all
    # tables, it's designed for kea 1.6.3; if you are using later, using more commands
    # is probably required
    srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_PATH)/my_db_v6.sql')
    world.f_cfg.multi_threading_enabled = False
    misc.test_setup()
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_cb_cmds.so')
    srv_control.add_hooks('libdhcp_mysql_cb.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    world.reservation_backend = "mysql"
    srv_control.define_temporary_lease_db_backend('mysql')
    cb_config = {
        "config-databases": [{
            "user": "******",
            "password": "******",
            "name": "$(DB_NAME)",
            "type": "mysql"
        }]
    }

    world.dhcp_cfg["config-control"] = cb_config
    world.dhcp_cfg["server-tag"] = "abc"
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    cmd = {
        "command": "remote-server6-set",
        "arguments": {
            "remote": {
                "type": "mysql"
            },
            "servers": [{
                "server-tag": "abc"
            }]
        }
    }
    srv_msg.send_ctrl_cmd(cmd, exp_result=0)

    subnets = [{
        "shared-network-name":
        "",
        "id":
        2,
        "interface":
        "$(SERVER_IFACE)",
        "pools": [{
            "pool":
            "2001:db8:1::10-2001:db8:1::10",
            "option-data": [{
                "code": 7,
                "data": "12",
                "always-send": True,
                "csv-format": True
            }]
        }],
        "pd-pools": [{
            "delegated-len": 91,
            "prefix": "2001:db8:2::",
            "prefix-len": 90
        }],
        "reservation-mode":
        "all",
        "subnet":
        "2001:db8:1::/64",
        "valid-lifetime":
        1000,
        "rebind-timer":
        500,
        "renew-timer":
        200,
        "option-data": [{
            "code": 7,
            "data": "123",
            "always-send": True,
            "csv-format": True
        }]
    }]
    _send_cmd("remote-subnet6-set", dict(subnets=subnets))

    shared_networks = [{
        "name":
        "net1",
        "client-class":
        "abc",
        "require-client-classes": ["XYZ"],
        "rebind-timer":
        200,
        "renew-timer":
        100,
        "calculate-tee-times":
        True,
        "t1-percent":
        0.5,
        "t2-percent":
        0.8,
        "rapid-commit":
        True,
        "valid-lifetime":
        300,
        "reservation-mode":
        "global",
        "user-context": {
            "some weird network": 55
        },
        "interface":
        "$(SERVER_IFACE)",
        "option-data": [{
            "code": 7,
            "data": "123",
            "always-send": True,
            "csv-format": True
        }]
    }]

    _send_cmd("remote-network6-set", {"shared-networks": shared_networks})

    parameters = {"decline-probation-period": 123456}
    _send_cmd("remote-global-parameter6-set", dict(parameters=parameters))

    options = [{"name": "sip-server-dns", "data": "isc.example.com"}]
    _send_cmd("remote-option6-global-set", dict(options=options))

    option_def = [{"name": "foo", "code": 222, "type": "uint32"}]
    _send_cmd("remote-option-def6-set", {"option-defs": option_def})

    cmd = {"command": "config-reload", "arguments": {}}
    srv_msg.send_ctrl_cmd(cmd)

    hr = {
        "reservation": {
            "subnet-id": 2,
            "duid": "01:02:03:04:05:06:07:08:09:0A",
            "ip-addresses": ["2001:db8:1::1"],
            "prefixes": ["2001:db8:2:abcd::/64"],
            "hostname": "foo.example.com",
            "option-data": [{
                "name": "vendor-opts",
                "data": "4491"
            }]
        }
    }
    _send_cmd("reservation-add", hr)

    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', 'ia_id', 61439)
    srv_msg.client_sets_value('Client', 'ia_pd', 24511)
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('server-id')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('IA_PD')
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'REPLY')
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::10')

    # create dump of database with events and procedures
    srv_msg.execute_shell_cmd(
        "mysqldump --events --routines -u $(DB_USER) -p'$(DB_PASSWD)' $(DB_NAME) > $(SOFTWARE_INSTALL_PATH)/my_db_v6.sql"
    )
    # replace interface and user used on setup that was used to generate dump to value later changed to interface
    # it's needed otherwise kea would not start on differently configured setup
    srv_msg.execute_shell_cmd(
        "sed -i 's/$(SERVER_IFACE)/!serverinterface!/g' $(SOFTWARE_INSTALL_PATH)/my_db_v6.sql"
    )
    srv_msg.execute_shell_cmd(
        "sed -i 's/$(DB_USER)/!db_user!/g' $(SOFTWARE_INSTALL_PATH)/my_db_v6.sql"
    )
Beispiel #38
0
def test_v4_upgrade_pgsql_db():
    # new db parameters
    tmp_db_name = "kea_tmp_db"
    tmp_user_name = "kea_tmp_user"
    # create new db without schema
    srv_control.build_database(db_name=tmp_db_name, db_user=tmp_user_name, init_db=False)
    # send db dump file
    srv_msg.remove_file_from_server('/tmp/pg_db_v4.sql')
    srv_msg.send_file_to_server('tests/dhcpv4/db_upgrade/pg_db_v4.sql', '/tmp/pg_db_v4.sql')
    # switch username to the one setup is using
    srv_msg.execute_shell_cmd("sed -i 's/!db_user!/%s/g' /tmp/pg_db_v4.sql" % tmp_user_name)

    # recreate db content in new db
    cmd = "sudo -S -u postgres psql -d %s -f/tmp/pg_db_v4.sql" % tmp_db_name
    fabric_run_command(cmd, ignore_errors=False, destination_host=world.f_cfg.mgmt_address)

    # start kea, which should fail due to mismatch in db version
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10')
    srv_control.add_hooks('libdhcp_host_cmds.so')
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.open_control_channel()
    srv_control.agent_control_channel('$(MGMT_ADDRESS)')
    hosts = {"hosts-databases": [{"user": tmp_user_name,
                                  "password": "******",
                                  "name": tmp_db_name,
                                  "type": "postgresql"}]}

    leases = {"lease-database": {"user": tmp_user_name,
                                 "password": "******",
                                 "name": tmp_db_name,
                                 "type": "postgresql"}}
    world.dhcp_cfg.update(hosts)
    world.dhcp_cfg.update(leases)
    srv_control.build_and_send_config_files()
    srv_control.start_srv_during_process('DHCP', 'started')

    # upgrade database
    kea_admin = world.f_cfg.sbin_join('kea-admin')
    srv_msg.execute_shell_cmd("sudo %s db-upgrade pgsql -u %s -p $(DB_PASSWD) -n %s" % (kea_admin, tmp_user_name, tmp_db_name))

    # start kea
    srv_control.start_srv('DHCP', 'started')

    cmd = dict(command="config-get", arguments={})
    srv_msg.send_ctrl_cmd(cmd, exp_result=0)

    # check reservation
    hr_get = {"subnet-id": 1, "identifier-type": "hw-address", "identifier": "01:0a:0b:0c:0d:0e:0f"}
    response = _send_cmd("reservation-get", hr_get)["arguments"]

    assert response["boot-file-name"] == "/dev/null"
    assert response["client-classes"] == ["special_snowflake", "office"]
    assert response["hw-address"] == "01:0a:0b:0c:0d:0e:0f"
    assert response["ip-address"] == "192.168.50.205"
    assert response["option-data"] == [{"always-send": False,
                                        "code": 6,
                                        "csv-format": True,
                                        "data": "10.1.1.202,10.1.1.203",
                                        "name": "domain-name-servers",
                                        "space": "dhcp4"}]
    assert response["server-hostname"] == "hal9000"
    # check lease
    lease_get = {"hw-address": "ff:01:02:03:ff:04"}
    resp = _send_cmd("lease4-get-by-hw-address", lease_get)["arguments"]
    assert resp["leases"][0]["hw-address"] == "ff:01:02:03:ff:04"
    assert resp["leases"][0]["ip-address"] == "192.168.50.10"
    assert resp["leases"][0]["state"] == 0
    assert resp["leases"][0]["subnet-id"] == 1
    assert resp["leases"][0]["valid-lft"] == 4000
Beispiel #39
0
def test_hook_v6_lease_cmds_legal_logging_del_using_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('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.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_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', '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', '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.response_check_suboption_content(5, 3, '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', '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', 13)
    srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2)

    srv_msg.send_ctrl_cmd_via_socket('{"command":"lease6-del","arguments":{"ip-address": "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', '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)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::1')
    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 the lease for address: 2001:db8:1::1')
def test_user_check_hook_vendor_options_all():

    # Install the requisite user registry file onto the server and then
    # Configure the server with two subnets.  The first subnet will be used
    # for registeted users, the second for unregistered users.
    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::20')
    srv_control.config_srv_another_subnet_no_interface('1000:1::/64', '1000:1::5-1000:1::5')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_user_chk.so')
    srv_control.config_srv_opt_space('vendor-4491', 'tftp-servers', '7000::1')
    srv_control.config_srv_opt_space('vendor-4491', 'config-file', 'bootfile.from.server')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    #
    # Send a query from an unknown user
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:ff:ff:ff:ff:ff:01')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    # We don't really care about the address value
    # Options should come from default user in registry
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 9000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33')
    srv_msg.response_check_suboption_content('Response',
                                             '33',
                                             '17',
                                             None,
                                             'config-file',
                                             'bootfile.from.default')

    #
    # Send a query from a registered user with no properties
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:11:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    # We don't really care about the address value
    # Options should come from server config
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 7000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33')
    srv_msg.response_check_suboption_content('Response',
                                             '33',
                                             '17',
                                             None,
                                             'config-file',
                                             'bootfile.from.server')

    #
    # Send a query from a registered user who supplies only bootfile
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:22:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    # We don't really care about the address value
    # bootfile should be from user, tftp server from server config
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 7000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33')
    srv_msg.response_check_suboption_content('Response',
                                             '33',
                                             '17',
                                             None,
                                             'config-file',
                                             'bootfile.from.user')

    #
    # Send a query from a registered user who supplies only tftp server
    #
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:33:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    # We don't really care about the address value
    # bootfile should be from server config, tftp server from user
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 8000::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33')
    srv_msg.response_check_suboption_content('Response',
                                             '33',
                                             '17',
                                             None,
                                             'config-file',
                                             'bootfile.from.server')

    misc.test_procedure()
    # Send a query from a registered user who supplies both tftp server and bootfile
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:44:02:03:04:05:06')
    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.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, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    # We don't really care about the address value
    # tftp server and bootfile should be from user
    srv_msg.response_check_include_option('Response', None, '17')
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '32')
    # Response sub-option 32 from option 17 MUST contain tftp-servers 8002::1.
    srv_msg.response_check_option_content('Response', '17', None, 'sub-option', '33')
    srv_msg.response_check_suboption_content('Response',
                                             '33',
                                             '17',
                                             None,
                                             'config-file',
                                             'bootfile.from.user-2')