Skip to content

Commit 8a00ae9

Browse files
committed
fix: add more tests
1 parent 01cf42b commit 8a00ae9

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/test_handlers.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,45 @@ def test_known_answer_supression_service_type_enumeration_query():
910910
zc.close()
911911

912912

913+
def test_upper_case_enumeration_query():
914+
zc = Zeroconf(interfaces=['127.0.0.1'])
915+
type_ = "_otherknown._tcp.local."
916+
name = "knownname"
917+
registration_name = f"{name}.{type_}"
918+
desc = {'path': '/~paulsm/'}
919+
server_name = "ash-2.local."
920+
info = ServiceInfo(
921+
type_, registration_name, 80, 0, 0, desc, server_name, addresses=[socket.inet_aton("10.0.1.2")]
922+
)
923+
zc.registry.async_add(info)
924+
925+
type_2 = "_otherknown2._tcp.local."
926+
name = "knownname"
927+
registration_name2 = f"{name}.{type_2}"
928+
desc = {'path': '/~paulsm/'}
929+
server_name2 = "ash-3.local."
930+
info2 = ServiceInfo(
931+
type_2, registration_name2, 80, 0, 0, desc, server_name2, addresses=[socket.inet_aton("10.0.1.2")]
932+
)
933+
zc.registry.async_add(info2)
934+
_clear_cache(zc)
935+
936+
# Test PTR supression
937+
generated = r.DNSOutgoing(const._FLAGS_QR_QUERY)
938+
question = r.DNSQuestion(const._SERVICE_TYPE_ENUMERATION_NAME.upper(), const._TYPE_PTR, const._CLASS_IN)
939+
generated.add_question(question)
940+
packets = generated.packets()
941+
question_answers = zc.query_handler.async_response([r.DNSIncoming(packet) for packet in packets], False)
942+
assert not question_answers.ucast
943+
assert not question_answers.mcast_now
944+
assert question_answers.mcast_aggregate
945+
assert not question_answers.mcast_aggregate_last_second
946+
# unregister
947+
zc.registry.async_remove(info)
948+
zc.registry.async_remove(info2)
949+
zc.close()
950+
951+
913952
# This test uses asyncio because it needs to access the cache directly
914953
# which is not threadsafe
915954
@pytest.mark.asyncio

0 commit comments

Comments
 (0)