示例#1
0
def test_ddns6_subnet():
    misc.test_setup()
    # simple case, ddns configuration in subnet - get and addres and dns entry
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')

    world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True,
                                         "ddns-generated-prefix": "abc",
                                         "ddns-qualifying-suffix": "example.com"})

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0)

    srv_control.add_ddns_server('127.0.0.1', '53001')
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY')

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

    srv_control.start_srv('DNS', 'started', config_set=31)

    _get_address_and_update_ddns(duid='00:03:00:01:ff:ff:ff:ff:ff:01', fqdn='sth6.six.example.com.',
                                 address='2001:db8:a::1',
                                 arpa='1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.')
示例#2
0
def test_v6_client_classification_shared_subnet_options_subnet():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::10')
    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class(1, 'test',
                                  'option[1].hex == 0x0003000166554433f2f1')
    srv_control.add_option_to_defined_class(1, 'dns-servers', '2001:db8::888')
    srv_control.config_client_classification(0, 'Client_Class_1')

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)
    srv_control.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:f2:f1')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(23)
    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:a::1')
    srv_msg.response_check_include_option(23)
    srv_msg.response_check_option_content(23, 'addresses', '2001:db8::888')
示例#3
0
def test_hook_v4_network_cmds_del_global_options():
    misc.test_setup()
    srv_control.config_srv_opt('domain-name-servers',
                               '199.199.199.1,100.100.100.1')
    srv_control.config_srv_subnet('192.168.50.0/24', '$(EMPTY)')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.1-192.168.51.1')
    # first shared subnet
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')

    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

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

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command": "network4-del","arguments":{"name":"name-abc","subnets-action": "delete"}}'
    )

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

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    # That needs subnet with empty pool to work
    misc.test_procedure()
    srv_msg.client_requests_option('6')
    srv_msg.client_sets_value('Client', 'ciaddr', '$(CIADDR)')
    srv_msg.client_send_msg('INFORM')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_include_option('Response', None, '6')
    srv_msg.response_check_option_content('Response', '6', None, 'value',
                                          '199.199.199.1')
    srv_msg.response_check_option_content('Response', '6', None, 'value',
                                          '100.100.100.1')
示例#4
0
def test_hook_v6_network_cmds_del_2():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    misc.test_procedure()
    srv_msg.client_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.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command": "network6-del","arguments":{"name":"name-abc","subnets-action": "delete"}}'
    )
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}', exp_result=3)

    srv_msg.forge_sleep('5', 'seconds')
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-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')
示例#5
0
def test_ddns6_all_levels_resend_without_ddns():
    misc.test_setup()
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64',
                                                       '2001:db8:b::1-2001:db8:b::1')

    world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True,
                                         "ddns-generated-prefix": "six",
                                         "ddns-qualifying-suffix": "example.com"})

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0)

    srv_control.add_ddns_server('127.0.0.1', '53001')
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY')

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')
    srv_control.start_srv('DNS', 'started', config_set=31)

    _get_address_and_update_ddns(duid='00:03:00:01:ff:ff:ff:ff:ff:01', fqdn='sth6.six.example.com.',
                                 address='2001:db8:a::1',
                                 arpa='1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.')

    _get_address(duid='00:03:00:01:ff:ff:ff:ff:ff:02', fqdn=None)

    _check_fqdn_record("some.abc.example.com.", expect='empty')

    # stop bind, remove data files, start bind with empty zones
    srv_control.start_srv('DNS', 'stopped')
    srv_control.clear_some_data('all', service='DNS')
    srv_control.start_srv('DNS', 'started', config_set=31)
    # check is all records were removed
    _check_fqdn_record("sth6.six.example.com.", expect='empty')
    _check_fqdn_record("some.abc.example.com.", expect='empty')
    _check_fqdn_record("record.xyz.example.com.", expect='empty')

    response = _resend_ddns('2001:db8:b::1', exp_result=1)
    assert response["text"] == 'Lease for: 2001:db8:b::1, has no hostname, nothing to update'
    response = _resend_ddns('2001:db8:a::1', exp_result=0)
    assert response["text"] == "NCR generated for: 2001:db8:a::1, hostname: sth6.six.example.com."

    _check_fqdn_record("sth6.six.example.com.", address='2001:db8:a::1')

    _check_address_record("sth6.six.example.com.",
                          '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.')
    _check_fqdn_record("some.abc.example.com.", expect='empty')
def test_v6_subnet_selection_based_on_global_reservation_of_class():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::10')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:c::/64', '2001:db8:c::1-2001:db8:c::10')
    world.dhcp_cfg["subnet6"][0]["client-class"] = "NOTspecial"
    world.dhcp_cfg["subnet6"][1]["client-class"] = "special"
    world.dhcp_cfg["subnet6"][2]["client-class"] = "special2"

    world.dhcp_cfg.update({
        "reservations": [{
            "client-classes": ["special"],
            "hw-address": "01:02:03:04:05:07"
        }, {
            "client-classes": ["special2"],
            "hw-address": "01:02:03:04:05:08"
        }],
        "client-classes": [{
            "name": "special"
        }, {
            "name": "special2"
        }, {
            "name":
            "NOTspecial",
            "test":
            "not member('special') and not member('special2')"
        }],
        "reservation-mode":
        "global"
    })

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.shared_subnet('2001:db8:c::/64', 0)

    srv_control.set_conf_parameter_shared_subnet('name', 'name-abc', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '$(SERVER_IFACE)', 0)

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

    # not special
    # _send_solicit('00:03:00:01:01:02:03:04:05:08', '2001:db8:a::1')
    # special
    _get_an_address('00:03:00:01:01:02:03:04:05:07', '2001:db8:b::1')
    _get_an_address('00:03:00:01:01:02:03:04:05:08', '2001:db8:c::1')
    # not special
    _send_solicit('00:03:00:01:01:02:03:04:05:09', '2001:db8:a::1')
示例#7
0
def test_hook_v4_network_cmds_get_by_name():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.1-192.168.51.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.52.0/24', '192.168.52.1-192.168.52.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.53.0/24', '192.168.53.1-192.168.53.1')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    # second shared-subnet
    srv_control.shared_subnet('2', '1')
    srv_control.shared_subnet('3', '1')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '1')
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"$(GIADDR4)"}', '1')

    srv_control.config_srv('time-servers', '0', '199.199.199.10')
    srv_control.config_srv('time-servers', '2', '199.199.199.100')
    srv_control.config_srv('time-servers', '3', '199.199.199.200')
    srv_control.add_hooks('libdhcp_subnet_cmds.so')

    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-get","arguments":{"name":"name-xyz"}}')
示例#8
0
def test_hook_v6_network_cmds_del_2():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0')
    srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    misc.test_procedure()
    srv_msg.client_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.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-list","arguments":{}}')
    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command": "network6-del","arguments":{"name":"name-abc","subnets-action": "delete"}}')
    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-list","arguments":{}}')

    srv_msg.forge_sleep('5', 'seconds')
    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-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')
示例#9
0
def test_hook_v4_network_cmds_del_keep_subnet():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.1-192.168.51.1')
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')

    srv_control.config_srv('time-servers', '0', '199.199.199.10')
    srv_control.add_hooks('libdhcp_subnet_cmds.so')

    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

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

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-list","arguments":{}}')
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-del","arguments":{"name":"name-abc","subnets-action": "keep"}}'
    )

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

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-list","arguments":{}}', exp_result=3)
示例#10
0
def test_v6_client_classification_shared_subnet_options_override_subnet():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv('dns-servers', '0', '2001:db8::1,2001:db8::2')

    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class('1', 'test',
                                  'substring(option[1].hex,8,2) == 0xf2f1')
    srv_control.add_option_to_defined_class('1', 'dns-servers',
                                            '2001:db8::888')
    srv_control.config_client_classification('0', 'Client_Class_1')

    srv_control.shared_subnet('0', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    srv_control.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:f2:f1')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses',
                                          '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', 'NOT ',
                                          'addresses', '2001:db8::1')
    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:a::1')
def test_v4_subnet_selection_based_on_global_reservation_of_class():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.50-192.168.50.50')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.50-192.168.51.50')

    world.dhcp_cfg["subnet4"][0]["client-class"] = "NOTspecial"
    world.dhcp_cfg["subnet4"][1]["client-class"] = "special"

    world.dhcp_cfg.update({
        "reservations": [{
            "client-classes": ["special"],
            "hw-address": "ff:01:02:03:ff:04"
        }],
        "client-classes": [{
            "name": "special"
        }, {
            "name": "NOTspecial",
            "test": "not member('special')"
        }],
        "reservation-mode":
        "global"
    })

    srv_control.shared_subnet('192.168.50.0/24', 0)
    srv_control.shared_subnet('192.168.51.0/24', 0)

    srv_control.set_conf_parameter_shared_subnet('name', 'name-abc', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '$(SERVER_IFACE)', 0)

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

    # get offer from NOTspecial
    _send_offer('ff:01:02:03:ff:01', '192.168.50.50')
    # get address from special
    _get_an_address('ff:01:02:03:ff:04', '192.168.51.50')
    # get offer from NOTspecial
    _send_offer('ff:01:02:03:ff:02', '192.168.50.50')
def test_v6_client_classification_shared_subnet_options_override_subnet():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv('dns-servers', '0', '2001:db8::1,2001:db8::2')

    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class('1', 'test', 'substring(option[1].hex,8,2) == 0xf2f1')
    srv_control.add_option_to_defined_class('1', 'dns-servers', '2001:db8::888')
    srv_control.config_client_classification('0', 'Client_Class_1')

    srv_control.shared_subnet('0', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0')
    srv_control.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:f2:f1')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses', '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', 'NOT ', 'addresses', '2001:db8::1')
    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:a::1')
示例#13
0
def test_hook_v4_network_cmds_add_conflict():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.1-192.168.51.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.52.0/24', '192.168.52.1-192.168.52.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.53.0/24', '192.168.53.1-192.168.53.1')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    # second shared-subnet
    srv_control.shared_subnet('2', '1')
    srv_control.shared_subnet('3', '1')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '1')
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"$(GIADDR4)"}', '1')

    srv_control.config_srv('time-servers', '0', '199.199.199.10')
    srv_control.config_srv('time-servers', '2', '199.199.199.100')
    srv_control.config_srv('time-servers', '3', '199.199.199.200')
    srv_control.add_hooks('libdhcp_subnet_cmds.so')

    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-list","arguments":{}}')
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-add","arguments":{"shared-networks": [{"match-client-id": true,"name": "name-xyz","option-data": [],"rebind-timer": 0,"relay": {"ip-address": "0.0.0.0"},"renew-timer": 0,"reservation-mode": "all","subnet4": [{"4o6-interface": "","4o6-interface-id": "","4o6-subnet": "","boot-file-name": "","id": 3,"match-client-id": true,"next-server": "0.0.0.0","option-data": [{"always-send": false,"code": 4,"csv-format": false,"data": "C7C7C764","name": "time-servers","space": "dhcp4"}],"pools": [{"option-data": [],"pool": "192.168.52.1/32"}],"rebind-timer": 2000,"relay": {"ip-address": "192.168.50.249"},"renew-timer": 1000,"reservation-mode": "all","server-hostname": "","subnet": "192.168.52.0/24","valid-lifetime": 4000},{"4o6-interface": "","4o6-interface-id": "","4o6-subnet": "","boot-file-name": "","id": 4,"match-client-id": true,"next-server": "0.0.0.0","option-data": [{"always-send": false,"code": 4,"csv-format": false,"data": "C7C7C7C8","name": "time-servers","space": "dhcp4"}],"pools": [{"option-data": [],"pool": "192.168.53.1/32"}],"rebind-timer": 2000,"relay": {"ip-address": "192.168.50.249"},"renew-timer": 1000,"reservation-mode": "all","server-hostname": "","subnet": "192.168.53.0/24","valid-lifetime": 4000}],"valid-lifetime": 0}]}}',
        exp_result=1)
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-get","arguments":{"name": "name-xyz"}}')
示例#14
0
def test_hook_v4_network_cmds_del_non_existing():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.1-192.168.51.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.52.0/24', '192.168.52.1-192.168.52.1')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.53.0/24', '192.168.53.1-192.168.53.1')
    srv_control.config_srv('time-servers', 0, '199.199.199.10')
    srv_control.config_srv('time-servers', 2, '199.199.199.100')
    srv_control.config_srv('time-servers', 3, '199.199.199.200')
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    # first shared subnet
    srv_control.shared_subnet('192.168.50.0/24', 0)
    srv_control.shared_subnet('192.168.51.0/24', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)
    # second shared-subnet
    srv_control.shared_subnet('192.168.52.0/24', 1)
    srv_control.shared_subnet('192.168.53.0/24', 1)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', 1)
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"$(GIADDR4)"}', 1)

    srv_control.open_control_channel()
    srv_control.build_and_send_config_files()

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-del","arguments":{"name":"name-xxyz,"subnets-action": "delete""}}',
        exp_result=1)
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network4-list","arguments":{}}')
示例#15
0
def test_control_channel_lease4_get_by():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.6')
    srv_control.config_srv_another_subnet_no_interface(
        '192.168.51.0/24', '192.168.51.10-192.168.51.11')

    world.dhcp_cfg.update({"ddns-send-updates": False})
    world.dhcp_cfg["subnet4"][1].update({"ddns-send-updates": False})
    world.dhcp_cfg["subnet4"][0].update({
        "ddns-send-updates": True,
        "ddns-generated-prefix": "four",
        "ddns-qualifying-suffix": "example.com"
    })

    srv_control.shared_subnet('192.168.50.0/24', 0)
    srv_control.shared_subnet('192.168.51.0/24', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)

    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.open_control_channel()

    srv_control.add_ddns_server('127.0.0.1', 53001)
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY')

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

    _get_address("08:08:08:08:08:08",
                 "192.168.50.5",
                 cli_id="00010203040506",
                 fqdn="four.hostname.com.")
    _get_address("09:09:09:09:09:09", "192.168.50.6", cli_id="00010203040507")
    _get_address("10:10:10:10:10:10", "192.168.51.10")
    _get_address("11:11:11:11:11:11", "192.168.51.11", fqdn="xyz.com.")

    # let's get 08:08:08:08:08:08 for in a different ways
    by_id_1 = _send_cmd("lease4-get-by-client-id",
                        extra_param={"client-id": "00010203040506"})
    del by_id_1["arguments"]["leases"][0]["cltt"]
    assert by_id_1["arguments"]["leases"][0] == {
        "fqdn-fwd": True,
        "fqdn-rev": True,
        "client-id": "00:01:02:03:04:05:06",
        "hostname": "four.hostname.com.",
        "hw-address": "08:08:08:08:08:08",
        "ip-address": "192.168.50.5",
        "state": 0,
        "subnet-id": 1,
        "valid-lft": 4000
    }

    by_host_1 = _send_cmd("lease4-get-by-hostname",
                          extra_param={"hostname": "four.hostname.com."})
    del by_host_1["arguments"]["leases"][0]["cltt"]
    assert by_host_1["arguments"]["leases"][0] == {
        "fqdn-fwd": True,
        "fqdn-rev": True,
        "client-id": "00:01:02:03:04:05:06",
        "hostname": "four.hostname.com.",
        "hw-address": "08:08:08:08:08:08",
        "ip-address": "192.168.50.5",
        "state": 0,
        "subnet-id": 1,
        "valid-lft": 4000
    }
    by_hw_1 = _send_cmd("lease4-get-by-hw-address",
                        extra_param={"hw-address": "08:08:08:08:08:08"})
    del by_hw_1["arguments"]["leases"][0]["cltt"]
    assert by_hw_1["arguments"]["leases"][0] == {
        "fqdn-fwd": True,
        "fqdn-rev": True,
        "client-id": "00:01:02:03:04:05:06",
        "hostname": "four.hostname.com.",
        "hw-address": "08:08:08:08:08:08",
        "ip-address": "192.168.50.5",
        "state": 0,
        "subnet-id": 1,
        "valid-lft": 4000
    }

    # let's get 09:09:09:09:09:09 for in a different ways
    by_id_1 = _send_cmd("lease4-get-by-client-id",
                        extra_param={"client-id": "00010203040507"})
    del by_id_1["arguments"]["leases"][0]["cltt"]
    assert by_id_1["arguments"]["leases"][0] == {
        "fqdn-fwd": False,
        "fqdn-rev": False,
        "client-id": "00:01:02:03:04:05:07",
        "hw-address": "09:09:09:09:09:09",
        "ip-address": "192.168.50.6",
        "hostname": "",
        "state": 0,
        "subnet-id": 1,
        "valid-lft": 4000
    }

    by_hw_1 = _send_cmd("lease4-get-by-hw-address",
                        extra_param={"hw-address": "09:09:09:09:09:09"})
    del by_hw_1["arguments"]["leases"][0]["cltt"]
    assert by_hw_1["arguments"]["leases"][0] == {
        "fqdn-fwd": False,
        "fqdn-rev": False,
        "client-id": "00:01:02:03:04:05:07",
        "hw-address": "09:09:09:09:09:09",
        "ip-address": "192.168.50.6",
        "hostname": "",
        "state": 0,
        "subnet-id": 1,
        "valid-lft": 4000
    }

    # let's get 11:11:11:11:11:11 for in a different ways
    # THOSE TWO ARE FAILING
    by_host_1 = _send_cmd("lease4-get-by-hostname",
                          extra_param={"hostname": "xyz.com."})
    del by_host_1["arguments"]["leases"][0]["cltt"]
    assert by_host_1["arguments"]["leases"][0] == {
        "fqdn-fwd": False,
        "fqdn-rev": False,
        # "client-id": "", #TODO I think it should be added
        "hostname": "xyz.com.",
        "hw-address": "11:11:11:11:11:11",
        "ip-address": "192.168.51.11",
        "state": 0,
        "subnet-id": 2,
        "valid-lft": 4000
    }
    by_hw_1 = _send_cmd("lease4-get-by-hw-address",
                        extra_param={"hw-address": "11:11:11:11:11:11"})
    del by_hw_1["arguments"]["leases"][0]["cltt"]
    assert by_hw_1["arguments"]["leases"][0] == {
        "fqdn-fwd": False,
        "fqdn-rev": False,
        # "client-id": "", #TODO I think it should be added
        "hostname": "xyz.com.",
        "hw-address": "11:11:11:11:11:11",
        "ip-address": "192.168.51.11",
        "state": 0,
        "subnet-id": 2,
        "valid-lft": 4000
    }

    by_hw_1 = _send_cmd("lease4-get-by-hw-address",
                        extra_param={"hw-address": "10:10:10:10:10:10"})
    del by_hw_1["arguments"]["leases"][0]["cltt"]
    assert by_hw_1["arguments"]["leases"][0] == {
        "fqdn-fwd": False,
        "fqdn-rev": False,
        # "client-id": "", #TODO I think it should be added
        "hw-address": "10:10:10:10:10:10",
        "ip-address": "192.168.51.10",
        "hostname": "",
        "state": 0,
        "subnet-id": 2,
        "valid-lft": 4000
    }

    _send_cmd("lease4-get-by-hw-address",
              extra_param={"hw-address": "11:11:12:12:13:13"},
              exp_result=3)
    _send_cmd("lease4-get-by-hostname",
              extra_param={"hostname": "abc.com."},
              exp_result=3)
    _send_cmd("lease4-get-by-client-id",
              extra_param={"client-id": "111111111111"},
              exp_result=3)

    _send_cmd("lease4-get-by-hw-address", exp_result=1)
    _send_cmd("lease4-get-by-hostname", exp_result=1)
    _send_cmd("lease4-get-by-client-id", exp_result=1)
示例#16
0
def test_hook_v6_network_cmds_get_by_name():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64',
                                                       '2001:db8:b::1-2001:db8:b::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:c::/64',
                                                       '2001:db8:c::1-2001:db8:c::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:d::/64',
                                                       '2001:db8:d::1-2001:db8:d::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:e::/64',
                                                       '2001:db8:e::1-2001:db8:e::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:f::/64',
                                                       '2001:db8:f::1-2001:db8:f::1')
    srv_control.config_srv('dns-servers', '1', '2001:db8::1,2001:db8::2')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface-id', '"interface-abc"', '0')
    # second shared-subnet
    srv_control.shared_subnet('2', '1')
    srv_control.shared_subnet('3', '1')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '1')
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '1')
    srv_control.shared_subnet('4', '2')
    srv_control.shared_subnet('5', '2')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-something"', '2')
    srv_control.set_conf_parameter_shared_subnet('relay', '{"ip-address":"2001:db8::1234"}', '2')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so')
    srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-get","arguments":{"name":"name-xyz"}}')
示例#17
0
def test_v6_client_classification_shared_subnet_options_override_francis():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')

    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class('1', 'test',
                                  'substring(option[1].hex,8,2) == 0xf2f1')
    srv_control.add_test_to_class('1', 'only-if-required', 'true')
    srv_control.add_option_to_defined_class('1', 'dns-servers',
                                            '2001:db8::888')
    # Server is configured with client-classification option in subnet 0 with name Client_Class_1.
    srv_control.config_require_client_classification('0', 'Client_Class_1')

    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')

    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    srv_control.set_conf_parameter_shared_subnet(
        'option-data',
        '[{"csv-format":true,"code":23,"data":"2001:db8::1","name":"dns-servers","space":"dhcp6"}]',
        '0')

    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:f2:f2')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', 'NOT ',
                                          'addresses', '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses',
                                          '2001:db8::1')
    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:b::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:f2:f1')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses',
                                          '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', 'NOT ',
                                          'addresses', '2001:db8::1')
    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:a::1')
示例#18
0
def test_ddns4_all_levels_lease4_del_with_dns():
    misc.test_setup()
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10')
    srv_control.config_srv_another_subnet_no_interface('192.168.51.0/24',
                                                       '192.168.51.10-192.168.51.10')
    srv_control.config_srv_another_subnet_no_interface('192.168.52.0/24',
                                                       '192.168.52.10-192.168.52.10')

    # let's get 3 different ddns settings, global, shared-network and subnet.
    world.dhcp_cfg.update({"ddns-send-updates": True,
                           "ddns-generated-prefix": "six",
                           "ddns-qualifying-suffix": "example.com"})

    world.dhcp_cfg["subnet4"][1].update({"ddns-send-updates": True,
                                         "ddns-generated-prefix": "abc",
                                         "ddns-qualifying-suffix": "example.com"})

    srv_control.shared_subnet('192.168.50.0/24', 0)
    srv_control.shared_subnet('192.168.51.0/24', 0)
    srv_control.shared_subnet('192.168.52.0/24', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0)

    world.dhcp_cfg["shared-networks"][0].update({"ddns-send-updates": True,
                                                 "ddns-generated-prefix": "xyz",
                                                 "ddns-qualifying-suffix": "example.com"})
    # kea-ddns config
    srv_control.add_ddns_server('127.0.0.1', '53001')
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('four.example.com.', 'EMPTY_KEY')
    srv_control.add_forward_ddns('five.example.com.', 'EMPTY_KEY')
    srv_control.add_forward_ddns('three.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('50.168.192.in-addr.arpa.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('51.168.192.in-addr.arpa.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('52.168.192.in-addr.arpa.', 'EMPTY_KEY')

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')
    srv_control.start_srv('DNS', 'started', config_set=32)

    # let's get 3 different leases with DNS record
    _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:01', fqdn='sth4.four.example.com.',
                                 address='192.168.50.10', arpa='10.50.168.192.in-addr.arpa.')

    _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:02', fqdn='some.five.example.com.',
                                 address='192.168.51.10', arpa='10.51.168.192.in-addr.arpa.')

    _get_address_and_update_ddns(mac='ff:ff:ff:ff:ff:03', fqdn='record.three.example.com.',
                                 address='192.168.52.10', arpa='10.52.168.192.in-addr.arpa.')

    # remove all leases using lease4-del with removing ddns entry
    resp = _delete_lease(extra_param={"ip-address": "192.168.50.10", "update-ddns": True}, exp_result=0)
    assert resp["text"] == "IPv4 lease deleted."
    resp = _delete_lease(extra_param={"ip-address": "192.168.51.10", "update-ddns": True}, exp_result=0)
    assert resp["text"] == "IPv4 lease deleted."
    resp = _delete_lease(extra_param={"ip-address": "192.168.52.10", "update-ddns": True}, exp_result=0)
    assert resp["text"] == "IPv4 lease deleted."

    # check if DNS record was indeed removed
    _check_fqdn_record("sth4.four.example.com.", expect='empty')
    _check_fqdn_record("some.five.example.com.", expect='empty')
    _check_fqdn_record("record.three.example.com.", expect='empty')

    _check_address_record("sth4.four.example.com.", expect='empty')
    _check_address_record("some.five.example.com.", expect='empty')
    _check_address_record("record.three.example.com.", expect='empty')

    # try to add back by resending ddns, all should fail
    _resend_ddns('192.168.51.10', exp_result=3)
    _resend_ddns('192.168.50.10', exp_result=3)
    _resend_ddns('192.168.52.10', exp_result=3)

    _check_fqdn_record("sth4.four.example.com.", expect='empty')
    _check_fqdn_record("some.five.example.com.", expect='empty')
    _check_fqdn_record("record.three.example.com.", expect='empty')

    _check_address_record("sth4.four.example.com.", expect='empty')
    _check_address_record("some.five.example.com.", expect='empty')
    _check_address_record("record.three.example.com.", expect='empty')
示例#19
0
def test_v6_sanity_check_shared_subnet_id():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('id', '666', '0')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.set_conf_parameter_subnet('id', '777', '1')
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    srv_control.set_conf_parameter_global('sanity-checks',
                                          '{"lease-checks":"fix-del"}')
    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command": "config-get","arguments":  {} }')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_sets_value('Client', 'ia_id', '1234567')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')

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

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'REPLY')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')
    # Response sub-option 5 from option 3 MUST contain address 2001:db8:a::1.

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:02')
    srv_msg.client_sets_value('Client', 'ia_id', '7654321')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')

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

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'REPLY')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')

    srv_msg.lease_file_contains('2001:db8:a::1,00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.lease_file_contains(
        '666,3000,0,1234567,128,0,0,,f6:f5:f4:f3:f2:01')
    srv_msg.lease_file_contains('2001:db8:b::1,00:03:00:01:f6:f5:f4:f3:f2:02')
    srv_msg.lease_file_contains(
        '777,3000,0,7654321,128,0,0,,f6:f5:f4:f3:f2:02')

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('id', '888', '0')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.set_conf_parameter_subnet('id', '999', '1')
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '0')
    srv_control.set_conf_parameter_global('sanity-checks',
                                          '{"lease-checks":"fix"}')
    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.forge_sleep('10', 'seconds')
示例#20
0
def test_hook_v6_network_cmds_get_by_name():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:c::/64', '2001:db8:c::1-2001:db8:c::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:d::/64', '2001:db8:d::1-2001:db8:d::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:e::/64', '2001:db8:e::1-2001:db8:e::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:f::/64', '2001:db8:f::1-2001:db8:f::1')
    srv_control.config_srv('dns-servers', 1, '2001:db8::1,2001:db8::2')
    # first shared subnet
    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface-id',
                                                 '"interface-abc"', 0)
    # second shared-subnet
    srv_control.shared_subnet('2001:db8:c::/64', 1)
    srv_control.shared_subnet('2001:db8:d::/64', 1)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', 1)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 1)
    srv_control.shared_subnet('2001:db8:e::/64', 2)
    srv_control.shared_subnet('2001:db8:f::/64', 2)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-something"', 2)
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"2001:db8::1234"}', 2)
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.open_control_channel()
    srv_control.build_and_send_config_files()

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-get","arguments":{"name":"name-xyz"}}')
示例#21
0
def test_hook_v6_network_cmds_del():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:c::/64', '2001:db8:c::1-2001:db8:c::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:d::/64', '2001:db8:d::1-2001:db8:d::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:e::/64', '2001:db8:e::1-2001:db8:e::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:f::/64', '2001:db8:f::1-2001:db8:f::1')
    srv_control.config_srv('dns-servers', 1, '2001:db8::1,2001:db8::2')
    # first shared subnet
    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface-id',
                                                 '"interface-abc"', 0)
    # second shared-subnet
    srv_control.shared_subnet('2001:db8:c::/64', 1)
    srv_control.shared_subnet('2001:db8:d::/64', 1)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', 1)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 1)
    srv_control.shared_subnet('2001:db8:e::/64', 2)
    srv_control.shared_subnet('2001:db8:f::/64', 2)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-something"', 2)
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"2001:db8::1234"}', 2)
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.open_control_channel()
    srv_control.build_and_send_config_files()

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command": "network6-del","arguments":{"name":"name-xyz","subnets-action": "delete"}}'
    )
    # Using UNIX socket on server in path control_socket send {"command": "network6-add","arguments":{"subnet6":[{"id": 234,"interface":"$(SERVER_IFACE)","subnet": "2001:db8:1::/64","pools":[{"pool":"2001:db8:1::1-2001:db8:1::2"}]}]}}
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
示例#22
0
def test_hook_v6_network_cmds_add_conflict():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64',
                                                       '2001:db8:b::1-2001:db8:b::1')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0')
    srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-list","arguments":{}}')
    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-add","arguments":{"shared-networks": [{"interface": "$(SERVER_IFACE)","name": "name-xyz","option-data": [],"preferred-lifetime": 0,"rapid-commit": false,"rebind-timer": 0,"relay": {"ip-address": "::"},"renew-timer": 0,"reservation-mode": "all","subnet6": [{"id": 3,"interface": "$(SERVER_IFACE)","option-data": [],"pd-pools": [],"pools": [{"option-data": [],"pool": "2001:db8:c::1/128"}],"preferred-lifetime": 3000,"rapid-commit": false,"rebind-timer": 2000,"relay": {"ip-address": "::"},"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:c::/64","valid-lifetime": 4000},{"id": 4,"interface": "$(SERVER_IFACE)","option-data": [],"pd-pools": [],"pools": [{"option-data": [],"pool": "2001:db8:d::1/128"}],"preferred-lifetime": 3000,"rapid-commit": false,"rebind-timer": 2000,"relay": {"ip-address": "::"},"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:d::/64","valid-lifetime": 4000}],"valid-lifetime": 0}]}}')

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

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_save_option('server-id')
    srv_msg.client_add_saved_option('DONT ')
    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:66:55:44:33:22:22')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_add_saved_option('DONT ')
    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:66:55:44:33:44:44')
    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')
示例#23
0
def test_hook_v6_network_cmds_del_non_existing():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:c::/64', '2001:db8:c::1-2001:db8:c::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:d::/64', '2001:db8:d::1-2001:db8:d::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:e::/64', '2001:db8:e::1-2001:db8:e::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:f::/64', '2001:db8:f::1-2001:db8:f::1')
    srv_control.config_srv('dns-servers', '1', '2001:db8::1,2001:db8::2')
    # first shared subnet
    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface-id',
                                                 '"interface-abc"', '0')
    # second shared-subnet
    srv_control.shared_subnet('2', '1')
    srv_control.shared_subnet('3', '1')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', '1')
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', '1')
    srv_control.shared_subnet('4', '2')
    srv_control.shared_subnet('5', '2')
    srv_control.set_conf_parameter_shared_subnet('name', '"name-something"',
                                                 '2')
    srv_control.set_conf_parameter_shared_subnet(
        'relay', '{"ip-address":"2001:db8::1234"}', '2')
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.open_control_channel()
    srv_control.build_and_send_config_files('SSH', 'config-file')

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
    response = srv_msg.send_ctrl_cmd_via_socket(
        '{"command": "network6-del","arguments":{"name":"name-xyzc"}}',
        exp_result=3)
    assert response['text'] == "no shared network with name 'name-xyzc' found"
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
示例#24
0
def test_v6_client_classification_shared_subnet_options_override():
    # we discussed classification on numerous occasions. This is actually working
    # as designed, I don't like this design, I still don't know why option defined
    # in shared-network should takes precedence before option defined in class and
    # it's only one level which does this (option in class takes precedence against
    # option defined globally, subnet and pool).

    # I gave up, I'm changing this test to reflect kea current operation.
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')

    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class(1, 'test',
                                  'substring(option[1].hex,8,2) == 0xf2f1')
    srv_control.add_option_to_defined_class(1, 'dns-servers', '2001:db8::888')
    srv_control.config_client_classification(0, 'Client_Class_1')

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)

    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)
    srv_control.set_conf_parameter_shared_subnet(
        'option-data',
        '{"csv-format":true,"code":23,"data":"2001:db8::1","name":"dns-servers","space":"dhcp6"}',
        0)

    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:f2:f2')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(23)
    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(23)
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::888',
                                          expect_include=False)
    srv_msg.response_check_option_content(23, 'addresses', '2001:db8::1')
    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:b::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:f2:f1')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(23)
    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(23)
    # the way this test worked previously
    # srv_msg.response_check_option_content(23, 'addresses', '2001:db8::888')
    # srv_msg.response_check_option_content(23, 'addresses', '2001:db8::1', expect_include=False)
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::888',
                                          expect_include=False)
    srv_msg.response_check_option_content(23, 'addresses', '2001:db8::1')
    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:a::1')
示例#25
0
def test_hook_v6_network_cmds_add_conflict():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    # first shared subnet
    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-xyz"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files()

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

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-list","arguments":{}}')
    response = srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-add","arguments":{"shared-networks": [{"interface": "$(SERVER_IFACE)","name": "name-xyz","option-data": [],"preferred-lifetime": 0,"rapid-commit": false,"rebind-timer": 0,"relay": {"ip-address": "::"},"renew-timer": 0,"reservation-mode": "all","subnet6": [{"id": 3,"interface": "$(SERVER_IFACE)","option-data": [],"pd-pools": [],"pools": [{"option-data": [],"pool": "2001:db8:c::1/128"}],"preferred-lifetime": 3000,"rapid-commit": false,"rebind-timer": 2000,"relay": {"ip-address": "::"},"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:c::/64","valid-lifetime": 4000},{"id": 4,"interface": "$(SERVER_IFACE)","option-data": [],"pd-pools": [],"pools": [{"option-data": [],"pool": "2001:db8:d::1/128"}],"preferred-lifetime": 3000,"rapid-commit": false,"rebind-timer": 2000,"relay": {"ip-address": "::"},"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:d::/64","valid-lifetime": 4000}],"valid-lifetime": 0}]}}',
        exp_result=1)
    assert response[
        'text'] == "duplicate network 'name-xyz' found in the configuration"

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_save_option('server-id')
    srv_msg.client_add_saved_option('DONT ')
    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)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:22')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:22')
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_add_saved_option('DONT ')
    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)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:44:44')
    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)
示例#26
0
def test_ddns6_all_levels_lease4_del_with_dns():
    misc.test_setup()
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:b::/64', '2001:db8:b::1-2001:db8:b::1')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:c::/64', '2001:db8:c::1-2001:db8:c::1')

    # let's get 3 different ddns settings, global, shared-network and subnet.
    world.dhcp_cfg.update({
        "ddns-send-updates": True,
        "ddns-generated-prefix": "six",
        "ddns-qualifying-suffix": "example.com"
    })

    world.dhcp_cfg["subnet6"][1].update({
        "ddns-send-updates": True,
        "ddns-generated-prefix": "abc",
        "ddns-qualifying-suffix": "example.com"
    })

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.shared_subnet('2001:db8:c::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface',
                                                 '"$(SERVER_IFACE)"', 0)

    world.dhcp_cfg["shared-networks"][0].update({
        "ddns-send-updates":
        True,
        "ddns-generated-prefix":
        "xyz",
        "ddns-qualifying-suffix":
        "example.com"
    })

    srv_control.add_ddns_server('127.0.0.1', '53001')
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY')
    srv_control.add_forward_ddns('abc.example.com.', 'EMPTY_KEY')
    srv_control.add_forward_ddns('xyz.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.',
                                 'EMPTY_KEY')
    srv_control.add_reverse_ddns('b.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.',
                                 'EMPTY_KEY')
    srv_control.add_reverse_ddns('c.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.',
                                 'EMPTY_KEY')

    # srv_control.print_cfg()
    # srv_control.print_cfg(service='DDNS')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    srv_control.start_srv('DNS', 'started', config_set=31)

    # let's get 3 different leases with DNS record
    _get_address_and_update_ddns(
        duid='00:03:00:01:ff:ff:ff:ff:ff:01',
        fqdn='sth6.six.example.com.',
        address='2001:db8:a::1',
        arpa=
        '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.'
    )

    _get_address_and_update_ddns(
        duid='00:03:00:01:ff:ff:ff:ff:ff:02',
        fqdn='some.abc.example.com.',
        address='2001:db8:b::1',
        arpa=
        '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.b.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.'
    )

    _get_address_and_update_ddns(
        duid='00:03:00:01:ff:ff:ff:ff:ff:03',
        fqdn='record.xyz.example.com.',
        address='2001:db8:c::1',
        arpa=
        '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.'
    )

    # remove all leases using lease4-del with removing ddns entry
    resp = _delete_lease(extra_param={
        "ip-address": "2001:db8:a::1",
        "update-ddns": True
    },
                         exp_result=0)
    assert resp["text"] == "IPv6 lease deleted."
    resp = _delete_lease(extra_param={
        "ip-address": "2001:db8:b::1",
        "update-ddns": True
    },
                         exp_result=0)
    assert resp["text"] == "IPv6 lease deleted."
    resp = _delete_lease(extra_param={
        "ip-address": "2001:db8:c::1",
        "update-ddns": True
    },
                         exp_result=0)
    assert resp["text"] == "IPv6 lease deleted."

    # check if DNS record was indeed removed
    _check_fqdn_record("sth6.six.example.com.", expect='empty')
    _check_fqdn_record("some.abc.example.com.", expect='empty')
    _check_fqdn_record("record.xyz.example.com.", expect='empty')

    _check_address_record("sth6.six.example.com.", expect='empty')
    _check_address_record("some.abc.example.com.", expect='empty')
    _check_address_record("record.xyz.example.com.", expect='empty')

    # try to add back by resending ddns, all should fail
    _resend_ddns('2001:db8:b::1', exp_result=3)
    _resend_ddns('2001:db8:a::1', exp_result=3)
    _resend_ddns('2001:db8:c::1', exp_result=3)

    _check_fqdn_record("sth6.six.example.com.", expect='empty')
    _check_fqdn_record("some.abc.example.com.", expect='empty')
    _check_fqdn_record("record.xyz.example.com.", expect='empty')

    _check_address_record("sth6.six.example.com.", expect='empty')
    _check_address_record("some.abc.example.com.", expect='empty')
    _check_address_record("record.xyz.example.com.", expect='empty')
示例#27
0
def test_control_channel_lease6_get_by():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::5-2001:db8:a::6')
    srv_control.config_srv_prefix('2000::', 0, 90, 96)
    srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64',
                                                       '2001:db8:b::10-2001:db8:b::11')
    srv_control.config_srv_prefix('2001::', 1, 90, 96)

    world.dhcp_cfg.update({"ddns-send-updates": False})
    world.dhcp_cfg["subnet6"][0].update({"ddns-send-updates": True,
                                         "ddns-generated-prefix": "six",
                                         "ddns-qualifying-suffix": "example.com"})
    world.dhcp_cfg["subnet6"][1].update({"ddns-send-updates": False})

    srv_control.shared_subnet('2001:db8:a::/64', 0)
    srv_control.shared_subnet('2001:db8:b::/64', 0)
    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', 0)
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', 0)

    srv_control.add_hooks('libdhcp_lease_cmds.so')
    srv_control.open_control_channel()

    srv_control.add_ddns_server('127.0.0.1', 53001)
    srv_control.add_ddns_server_options('enable-updates', True)
    srv_control.add_forward_ddns('six.example.com.', 'EMPTY_KEY')
    srv_control.add_reverse_ddns('a.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.', 'EMPTY_KEY')

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

    _get_address("00:03:00:01:08:08:08:08:08:08", "2001:db8:a::5", ia_id=5, fqdn="six.hostname.com.")
    _get_address("00:03:00:01:09:09:09:09:09:09", "2001:db8:a::6", ia_pd=1, ia_id=6)
    _get_address("00:03:00:01:10:10:10:10:10:10", "2001:db8:b::10", ia_id=10)
    _get_address("00:03:00:01:11:11:11:11:11:11", "2001:db8:b::11", fqdn="xyz.com.",
                 ia_id=11, expected_flag='ON')

    by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:08:08:08:08:08:08"})
    del by_id_1["arguments"]["leases"][0]["cltt"]
    assert by_id_1["arguments"]["leases"][0] == {"fqdn-fwd": True,
                                                 "fqdn-rev": True,
                                                 "hw-address": "08:08:08:08:08:08",
                                                 "hostname": "six.hostname.com.",
                                                 "duid": "00:03:00:01:08:08:08:08:08:08",
                                                 "ip-address": "2001:db8:a::5",
                                                 "iaid": 5,
                                                 "preferred-lft": 3000,
                                                 "type": "IA_NA",
                                                 "state": 0,
                                                 "subnet-id": 1,
                                                 "valid-lft": 4000}

    by_host_1 = _send_cmd("lease6-get-by-hostname", extra_param={"hostname": "six.hostname.com."})
    del by_host_1["arguments"]["leases"][0]["cltt"]
    assert by_host_1["arguments"]["leases"][0] == {"fqdn-fwd": True,
                                                   "fqdn-rev": True,
                                                   "hw-address": "08:08:08:08:08:08",
                                                   "hostname": "six.hostname.com.",
                                                   "duid": "00:03:00:01:08:08:08:08:08:08",
                                                   "ip-address": "2001:db8:a::5",
                                                   "iaid": 5,
                                                   "preferred-lft": 3000,
                                                   "type": "IA_NA",
                                                   "state": 0,
                                                   "subnet-id": 1,
                                                   "valid-lft": 4000}

    by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:09:09:09:09:09:09"})
    assert len(by_id_1["arguments"]["leases"]) == 2
    for lease in by_id_1["arguments"]["leases"]:
        del lease["cltt"]
    for lease in by_id_1["arguments"]["leases"]:
        if lease["ip-address"] == "2001:db8:a::6":
            assert lease == {"fqdn-fwd": False,
                             "fqdn-rev": False,
                             "duid": "00:03:00:01:09:09:09:09:09:09",
                             "ip-address": "2001:db8:a::6",
                             "hostname": "",
                             "hw-address": "09:09:09:09:09:09",
                             "state": 0,
                             "subnet-id": 1,
                             "iaid": 6,
                             "preferred-lft": 3000,
                             "type": "IA_NA",
                             "valid-lft": 4000}

        elif lease["ip-address"] == "2000::":
            assert lease == {"duid": "00:03:00:01:09:09:09:09:09:09",
                             "fqdn-fwd": False,
                             "fqdn-rev": False,
                             "hostname": "",
                             "hw-address": "09:09:09:09:09:09",
                             "iaid": 1,
                             "ip-address": "2000::",
                             "preferred-lft": 3000,
                             "prefix-len": 96,
                             "state": 0,
                             "subnet-id": 1,
                             "type": "IA_PD",
                             "valid-lft": 4000}

    by_id_1 = _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:11:11:11:11:11:11"})
    del by_id_1["arguments"]["leases"][0]["cltt"]
    assert by_id_1["arguments"]["leases"][0] == {"fqdn-fwd": False,
                                                 "fqdn-rev": False,
                                                 "hw-address": "11:11:11:11:11:11",
                                                 "hostname": "xyz.com.",
                                                 "duid": "00:03:00:01:11:11:11:11:11:11",
                                                 "ip-address": "2001:db8:b::11",
                                                 "iaid": 11,
                                                 "preferred-lft": 3000,
                                                 "type": "IA_NA",
                                                 "state": 0,
                                                 "subnet-id": 2,
                                                 "valid-lft": 4000}

    _send_cmd("lease6-get-by-hostname", extra_param={"hostname": "abc.com."}, exp_result=3)
    _send_cmd("lease6-get-by-duid", extra_param={"duid": "00:03:00:01:12:12:12:11:11:11"}, exp_result=3)

    _send_cmd("lease6-get-by-hostname", exp_result=1)
    _send_cmd("lease6-get-by-duid", exp_result=1)
def test_v6_client_classification_shared_subnet_options_override_francis():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::10')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:b::/64',
                                                       '2001:db8:b::1-2001:db8:b::1')

    srv_control.create_new_class('Client_Class_1')
    srv_control.add_test_to_class('1', 'test', 'substring(option[1].hex,8,2) == 0xf2f1')
    srv_control.add_test_to_class('1', 'only-if-required', 'true')
    srv_control.add_option_to_defined_class('1', 'dns-servers', '2001:db8::888')
    # Server is configured with client-classification option in subnet 0 with name Client_Class_1.
    srv_control.config_require_client_classification('0', 'Client_Class_1')

    srv_control.shared_subnet('0', '0')
    srv_control.shared_subnet('1', '0')

    srv_control.set_conf_parameter_shared_subnet('name', '"name-abc"', '0')
    srv_control.set_conf_parameter_shared_subnet('interface', '"$(SERVER_IFACE)"', '0')
    srv_control.set_conf_parameter_shared_subnet('option-data',
                                                 '[{"csv-format":true,"code":23,"data":"2001:db8::1","name":"dns-servers","space":"dhcp6"}]',
                                                 '0')

    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:f2:f2')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', 'NOT ', 'addresses', '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses', '2001:db8::1')
    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:b::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:f2:f1')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('23')
    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, '23')
    srv_msg.response_check_option_content('Response', '23', None, 'addresses', '2001:db8::888')
    srv_msg.response_check_option_content('Response', '23', 'NOT ', 'addresses', '2001:db8::1')
    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:a::1')