diff --git a/components/mdns/tests/host_test/pytest_mdns.py b/components/mdns/tests/host_test/pytest_mdns.py index 95fefc2eb..f492ef63e 100644 --- a/components/mdns/tests/host_test/pytest_mdns.py +++ b/components/mdns/tests/host_test/pytest_mdns.py @@ -76,6 +76,21 @@ def test_ptr_additional_records_for_service(dig_app): dig_app.check_additional(resp, 'TXT', 'test_service._http._tcp.local', expected=True) +def test_instance_any_answer_records(dig_app): + """Query ANY for the service instance and ensure SRV/TXT are in Answer (Q/A path).""" + resp = dig_app.run_query('test_service._http._tcp.local', query_type='ANY') + + # Answer section should contain SRV and TXT records for the instance + srv_answers = dig_app.parse_section(resp, 'answer', 'SRV') + txt_answers = dig_app.parse_section(resp, 'answer', 'TXT') + assert any('test_service._http._tcp.local' in a for a in srv_answers) + assert any('test_service._http._tcp.local' in a for a in txt_answers) + + # We should not see a PTR for the generic service name in the Answer section + ptr_answers = dig_app.parse_section(resp, 'answer', 'PTR') + assert not any('_http._tcp.local' in a for a in ptr_answers) + + def test_remove_service(mdns_console, dig_app): mdns_console.send_input('mdns_service_remove _http _tcp') mdns_console.send_input('mdns_service_lookup _http _tcp')