예제 #1
0
def test_v6_IPXE_2():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8::/64', '$(EMPTY)')
    srv_control.create_new_class('a-ipxe')
    srv_control.add_test_to_class(1, 'test', 'option[61].hex == 0x0007')
    srv_control.add_option_to_defined_class(1, 'bootfile-url',
                                            'http://[2001:db8::1]/ipxe.efi')
    # Server is configured with client-classification option in subnet 0 with name a-ipxe.
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'archtypes', 7)
    srv_msg.client_does_include('Client', 'client-arch-type')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(59)
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')
    srv_msg.response_check_include_option(59)
    srv_msg.response_check_option_content(59, 'optdata',
                                          'http://[2001:db8::1]/ipxe.efi')
    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)
예제 #2
0
def test_v6_IPXE_2():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8::/64', '$(EMPTY)')
    srv_control.create_new_class('a-ipxe')
    srv_control.add_test_to_class('1', 'test', 'option[61].hex == 0x0007')
    srv_control.add_option_to_defined_class('1', 'bootfile-url', 'http://[2001:db8::1]/ipxe.efi')
    # Server is configured with client-classification option in subnet 0 with name a-ipxe.
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'archtypes', '7')
    srv_msg.client_does_include('Client', None, 'client-arch-type')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('59')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '59')
    srv_msg.response_check_option_content('Response',
                                          '59',
                                          None,
                                          'optdata',
                                          'http://[2001:db8::1]/ipxe.efi')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13')
    srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2')
예제 #3
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')
예제 #4
0
def test_v4_host_reservation_reserved_classes_1():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.1')

    srv_control.create_new_class('ipxe_efi_x64')
    srv_control.add_test_to_class('1', 'next-server', '192.0.2.254')
    srv_control.add_test_to_class('1', 'server-hostname', 'hal9000')
    srv_control.add_test_to_class('1', 'boot-file-name', '/dev/null')
    srv_control.add_option_to_defined_class('1', 'interface-mtu', '321')

    srv_control.add_line_to_subnet(
        '0',
        ',"reservations": [{"hw-address": "aa:bb:cc:dd:ee:ff","ip-address": "192.168.50.10","client-classes": [ "ipxe_efi_x64" ]}]'
    )
    srv_control.add_line('"host-reservation-identifiers": [ "hw-address" ]')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55')
    srv_msg.client_requests_option('26')
    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', 'NOT ', '26')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:ff')
    srv_msg.client_requests_option('26')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')
    srv_msg.response_check_include_option('Response', None, '26')
    srv_msg.response_check_option_content('Response', '26', None, 'value',
                                          '321')

    misc.test_procedure()
    srv_msg.client_requests_option('26')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10')
    srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:ff')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_option_content('Response', '1', None, 'value',
                                          '255.255.255.0')
    srv_msg.response_check_include_option('Response', None, '26')
    srv_msg.response_check_option_content('Response', '26', None, 'value',
                                          '321')
    srv_msg.response_check_content('Response', None, 'siaddr', '192.0.2.254')
    srv_msg.response_check_content('Response', None, 'file', '/dev/null')
    srv_msg.response_check_content('Response', None, 'sname', 'hal9000')
예제 #5
0
def test_v6_IPXE_1():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8::/64', '$(EMPTY)')
    srv_control.create_new_class('a-ipxe')
    srv_control.add_test_to_class('1', 'test',
                                  'substring(option[15].hex,2,4) == \'iPXE\'')
    srv_control.add_option_to_defined_class('1', 'bootfile-url',
                                            'http://[2001:db8::1]/ubuntu.cfg')
    # Server is configured with client-classification option in subnet 0 with name a-ipxe.
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'archtypes', '7')
    srv_msg.client_does_include('Client', None, 'client-arch-type')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_sets_value('Client', 'user_class_data', 'iPXE')
    srv_msg.client_does_include('Client', None, 'user-class')
    srv_msg.client_requests_option('59')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '59')
    srv_msg.response_check_option_content('Response', '59', None, 'optdata',
                                          'http://[2001:db8::1]/ubuntu.cfg')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '13')
    srv_msg.response_check_suboption_content('Response', '13', '3', None,
                                             'statuscode', '2')
def test_v4_host_reservation_reserved_classes_2():
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1')

    srv_control.create_new_class('ipxe_efi_x64')
    srv_control.add_test_to_class('1', 'server-hostname', 'hal9000')
    srv_control.add_test_to_class('1', 'boot-file-name', '/dev/null')

    srv_control.create_new_class('class-abc')
    srv_control.add_test_to_class('2', 'next-server', '192.0.2.254')
    srv_control.add_option_to_defined_class('2', 'interface-mtu', '321')

    srv_control.add_line_to_subnet('0',
                                   ',"reservations": [{"hw-address": "aa:bb:cc:dd:ee:ff","ip-address": "192.168.50.10","client-classes": [ "ipxe_efi_x64", "class-abc" ]}]')
    srv_control.add_line('"host-reservation-identifiers": [ "hw-address" ]')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:55')
    srv_msg.client_requests_option('26')
    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', 'NOT ', '26')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:ff')
    srv_msg.client_requests_option('26')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'OFFER')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')
    srv_msg.response_check_include_option('Response', None, '26')
    srv_msg.response_check_option_content('Response', '26', None, 'value', '321')

    misc.test_procedure()
    srv_msg.client_requests_option('26')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10')
    srv_msg.client_sets_value('Client', 'chaddr', 'aa:bb:cc:dd:ee:ff')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ACK')
    srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    srv_msg.response_check_include_option('Response', None, '26')
    srv_msg.response_check_option_content('Response', '26', None, 'value', '321')
    srv_msg.response_check_content('Response', None, 'siaddr', '192.0.2.254')
    srv_msg.response_check_content('Response', None, 'file', '/dev/null')
    srv_msg.response_check_content('Response', None, 'sname', 'hal9000')
예제 #7
0
def test_v6_client_classification_class_with_option():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64',
                                  '2001:db8:a::1-2001:db8:a::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::666')
    srv_control.config_client_classification('0', 'Client_Class_1')

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

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

    misc.test_procedure()
    srv_msg.client_sets_value('Client', '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::666')
    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')

    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_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', 'NOT ', '23')
    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_v6_client_classification_class_with_option():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::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::666')
    srv_control.config_client_classification('0', 'Client_Class_1')

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

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

    misc.test_procedure()
    srv_msg.client_sets_value('Client', '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::666')
    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')

    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_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', 'NOT ', '23')
    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')
예제 #9
0
def test_v6_host_reservation_classes_2():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::1')
    srv_control.add_line_to_subnet(
        0, {
            "reservations": [{
                "duid":
                "00:03:00:01:f6:f5:f4:f3:f2:22",
                "client-classes": ["reserved-class1", "reserved-class2"]
            }]
        })

    srv_control.create_new_class('reserved-class1')
    srv_control.add_option_to_defined_class(1, 'sip-server-addr',
                                            '2001:db8::1,2001:db8::2')

    srv_control.create_new_class('reserved-class2')
    srv_control.add_option_to_defined_class(2, 'preference', '123')

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

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

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')
    srv_msg.response_check_include_option(22, expect_include=False)
    srv_msg.response_check_include_option(7, expect_include=False)

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:22')
    srv_msg.client_requests_option(7)
    srv_msg.client_requests_option(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(22)
    srv_msg.response_check_option_content(22, 'addresses',
                                          '2001:db8::1,2001:db8::2')
    srv_msg.response_check_include_option(7)
    srv_msg.response_check_option_content(7, 'prefval', 123)
예제 #10
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')
예제 #11
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')
예제 #12
0
def test_v6_client_classification_multiple_subnets_options_override_global():
    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_opt('dns-servers', '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.create_new_class('Client_Class_2')
    srv_control.add_test_to_class(2, 'test',
                                  'substring(option[1].hex,8,2) == 0xf2f2')
    srv_control.add_option_to_defined_class(2, 'dns-servers', '2001:db8::777')
    srv_control.config_client_classification(1, 'Client_Class_2')

    srv_control.create_new_class('Client_Class_3')
    srv_control.add_test_to_class(3, 'test',
                                  'substring(option[1].hex,8,2) == 0xf299')
    srv_control.add_option_to_defined_class(3, 'dns-servers', '2001:db8::999')
    srv_control.config_client_classification(2, 'Client_Class_3')

    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:11:11:11:11:11:11')
    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::1,2001:db8::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:d::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)
    srv_msg.response_check_option_content(23, 'addresses', '2001:db8::888')
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::2',
                                          expect_include=False)
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::1',
                                          expect_include=False)
    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')

    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::777')
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::2',
                                          expect_include=False)
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::1',
                                          expect_include=False)
    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:99')
    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::999')
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::2',
                                          expect_include=False)
    srv_msg.response_check_option_content(23,
                                          'addresses',
                                          '2001:db8::1',
                                          expect_include=False)
    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:c::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')