Skip to content

Commit 7424337

Browse files
committed
fix(mdns): Add test to check aswer section for service instance
1 parent 7aed408 commit 7424337

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/mdns/tests/host_test/pytest_mdns.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ def test_ptr_additional_records_for_service(dig_app):
7676
dig_app.check_additional(resp, 'TXT', 'test_service._http._tcp.local', expected=True)
7777

7878

79+
def test_instance_any_answer_records(dig_app):
80+
"""Query ANY for the service instance and ensure SRV/TXT are in Answer (Q/A path)."""
81+
resp = dig_app.run_query('test_service._http._tcp.local', query_type='ANY')
82+
83+
# Answer section should contain SRV and TXT records for the instance
84+
srv_answers = dig_app.parse_section(resp, 'answer', 'SRV')
85+
txt_answers = dig_app.parse_section(resp, 'answer', 'TXT')
86+
assert any('test_service._http._tcp.local' in a for a in srv_answers)
87+
assert any('test_service._http._tcp.local' in a for a in txt_answers)
88+
89+
# We should not see a PTR for the generic service name in the Answer section
90+
ptr_answers = dig_app.parse_section(resp, 'answer', 'PTR')
91+
assert not any('_http._tcp.local' in a for a in ptr_answers)
92+
93+
7994
def test_remove_service(mdns_console, dig_app):
8095
mdns_console.send_input('mdns_service_remove _http _tcp')
8196
mdns_console.send_input('mdns_service_lookup _http _tcp')

0 commit comments

Comments
 (0)