-
59b6721a fix missing received values when checking option For example, an error would say:
AssertionError: Invalid server_id[54] option received: but expected 10.0.122.32
The empty received value does not mean that the option is not there. The error would have been different if that was the case. There is a received value, but forge does not know how to display it.
This change turns the error into:
AssertionError: Invalid server_id[54] option received: ('server_id', '10.0.122.70') but expected 10.0.122.32
It's not the best, but at least it is clear what the value difference is.
It would be easy to only display the value like for other options, but with all the if-statements that check for specific code options, I don't know how to make it work without breaking the code for other options...
-
1f9971b5 show the entire packet when checking fields - For easier debugging when this situation happens again
Here's a test that you can use to test these changes with. It should fail on the last line.
@pytest.mark.v4
def test_debug():
misc.test_setup()
srv_control.define_temporary_lease_db_backend('memfile')
srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.1')
srv_control.build_and_send_config_files()
srv_control.start_srv('DHCP', 'started')
srv_msg.client_requests_option(1)
srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:11:11:22')
srv_msg.client_send_msg('DISCOVER')
srv_msg.send_wait_for_message('MUST', 'OFFER')
srv_msg.response_check_include_option(1)
srv_msg.response_check_content('yiaddr', '192.168.50.1')
srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
srv_msg.client_copy_option('server_id')
srv_msg.client_sets_value('Client', 'chaddr', '00:00:00:11:11:22')
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')
srv_msg.send_wait_for_message('MUST', 'ACK')
srv_msg.response_check_content('yiaddr', '192.168.50.1')
srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
srv_msg.response_check_option_content(54, 'value', 'whatever')