Exemple #1
0
def test_bootp():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.new_pool('192.168.50.10-192.168.50.10', 0)
    srv_control.add_hooks('libdhcp_bootp.so')

    world.dhcp_cfg["subnet4"][0]["pools"][0]["client-class"] = "BOOTP"
    world.dhcp_cfg["subnet4"][0]["pools"][1]["client-class"] = "DHCP"
    srv_control.create_new_class('DHCP')
    srv_control.add_test_to_class(1, 'test', "not member('BOOTP')")
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_send_msg('DISCOVER')

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

    misc.test_procedure()
    srv_msg.client_send_msg('BOOTP_REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'BOOTP_REPLY')
    srv_msg.response_check_include_option(53, expect_include=False)
    srv_msg.response_check_include_option(58, expect_include=False)
    srv_msg.response_check_include_option(59, expect_include=False)
    srv_msg.response_check_content('yiaddr', '192.168.50.1')
def test_v4_pool_selection_based_on_global_reservation_of_class():
    misc.test_setup()
    # pool selection based on global reservation with class
    # address assigned based on reservation on subnet level
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.new_pool('192.168.50.150-192.168.50.150', 0)
    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"
    })

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

    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.1')
    # get address from special
    _get_an_address('ff:01:02:03:ff:04', '192.168.50.150')
    # get offer from NOTspecial
    _send_offer('ff:01:02:03:ff:02', '192.168.50.1')
def test_v4_options_pool_level():
    misc.test_setup()
    srv_control.config_srv_subnet("172.16.0.0/16", "172.16.0.20-172.16.0.20")
    srv_control.new_pool("172.16.0.50-172.16.0.50", 0)
    srv_control.config_srv_opt('routers', '100.100.100.10')

    option = {"data": "172.17.0.1", "name": "routers"}
    world.dhcp_cfg["subnet4"][0]["pools"][0].update({"option-data": [option]})
    option2 = {"data": "172.170.10.111", "name": "routers"}
    world.dhcp_cfg["subnet4"][0]["pools"][1].update({"option-data": [option2]})

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

    _get_lease("01:01:01:01:01:01", "172.17.0.1", "172.16.0.20")
    _get_lease("01:01:01:02:02:02", "172.170.10.111", "172.16.0.50")
Exemple #4
0
def test_v6_options_pool_level():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::50-2001:db8:1::50')
    srv_control.new_pool("2001:db8:1::500-2001:db8:1::500", 0)
    srv_control.config_srv_opt('preference', "20")

    option = {"name": "preference", "space": "dhcp6", "data": "1"}
    world.dhcp_cfg["subnet6"][0]["pools"][0].update({"option-data": [option]})

    option2 = {"name": "preference", "space": "dhcp6", "data": "2"}
    world.dhcp_cfg["subnet6"][0]["pools"][1].update({"option-data": [option2]})

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

    # lease from first pool should have preference val set to 1
    _get_lease('00:03:00:01:ff:ff:ff:ff:ff:01', 1)
    # lease from seconnd pool should have preference val set to 2
    _get_lease('00:03:00:01:ff:ff:ff:ff:ff:02', 2)
Exemple #5
0
def test_v6_multipleIA_addresses_multiple_pools():
    #  Testing server ability to parse and allocate addresses
    #  when multiple IA option are included in one message.
    #  Server is configured with multiple pools within single subnet
    #  					Client		Server
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  include all IA's REQUEST -->
    #  				 		    <--	REPLY
    #  Pass Criteria:
    #  				REPLY MUST include option:
    # 					IA-NA
    # 					IA-Address with 3000::1 address
    # 					IA-Address with 3000::2 address
    # 					IA-Address with 3000::3 address
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1')
    srv_control.new_pool('3000::2-3000::2', 0)
    srv_control.new_pool('3000::3-3000::3', 0)
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    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_save_option('IA_NA')
    srv_msg.generate_new('IA')
    srv_msg.client_requests_option(7)
    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_save_option('IA_NA')
    srv_msg.generate_new('IA')
    srv_msg.client_requests_option(7)
    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_save_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_add_saved_option(None)
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'REPLY')
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::1')
    srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::2')
    srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::3')
def test_v4_request_selecting_success_chaddr_multiple_pools(backend):

    misc.test_setup()
    srv_control.define_temporary_lease_db_backend(backend)
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')
    srv_control.new_pool('192.168.50.2-192.168.50.2', 0)
    srv_control.new_pool('192.168.50.3-192.168.50.3', 0)
    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', '00:00:00:00:00: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', '192.168.50.1')
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:01')
    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_option_content(1, 'value', '255.255.255.0')
    srv_msg.check_leases(srv_msg.get_all_leases(), backend=backend)

    misc.test_procedure()
    srv_msg.client_requests_option(1)
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:02')
    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.2')
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:02')
    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', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.2')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    srv_msg.check_leases(srv_msg.get_all_leases(), backend=backend)

    misc.test_procedure()
    srv_msg.client_requests_option(1)
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:03')
    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.3')
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:03')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.3')
    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.3')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    srv_msg.check_leases(srv_msg.get_all_leases(), backend=backend)
def test_v6_multipleIA_addresses_multiple_pools():
    #  Testing server ability to parse and allocate addresses
    #  when multiple IA option are included in one message.
    #  Server is configured with multiple pools within single subnet
    #  					Client		Server
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  					SOLICIT -->
    #  save IA_NA				<--	ADVERTISE
    #  include all IA's REQUEST -->
    #  				 		    <--	REPLY
    #  Pass Criteria:
    #  				REPLY MUST include option:
    # 					IA-NA
    # 					IA-Address with 3000::1 address
    # 					IA-Address with 3000::2 address
    # 					IA-Address with 3000::3 address
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1')
    srv_control.new_pool('3000::2-3000::2', '0')
    srv_control.new_pool('3000::3-3000::3', '0')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    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_save_option('IA_NA')
    srv_msg.generate_new('IA')
    srv_msg.client_requests_option('7')
    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_save_option('IA_NA')
    srv_msg.generate_new('IA')
    srv_msg.client_requests_option('7')
    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_save_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_add_saved_option(None)
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'REPLY')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::1')
    srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::2')
    srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::3')
def test_v4_request_selecting_success_chaddr_multiple_pools():

    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1')
    srv_control.new_pool('192.168.50.2-192.168.50.2', '0')
    srv_control.new_pool('192.168.50.3-192.168.50.3', '0')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option('1')
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00: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', '192.168.50.1')
    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:01')
    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_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', '00:00:00:00:00:02')
    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:02')
    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')

    misc.test_procedure()
    srv_msg.client_requests_option('1')
    srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:00:00:03')
    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.3')
    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:03')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.3')
    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.3')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')