Skip to content

Commit 20b726d

Browse files
Step 9 - Updates hostname character length check, other adjustments
1 parent 0d543c1 commit 20b726d

File tree

1 file changed

+26
-45
lines changed

1 file changed

+26
-45
lines changed

src/python_testing/TC_SC_4_3.py

+26-45
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def steps_TC_SC_4_3(self):
6464
TestStep(8, "TH performs a query for the AAAA record against the target listed in the SRV record",
6565
"Verify AAAA record is returned"),
6666
TestStep(9, "TH verifies the following from the returned records:",
67-
"Hostname: • If (MCORE.COM.WIFI OR MCORE.COM.ETH) target, the hostname must be a 12-character uppercase hexadecimal string. • If (MCORE.COM.THR) target, the hostname must be a 16-character hex string using capital letters. ICD TXT key: • If supports_lit is false, verify that the ICD key is NOT present in the TXT record • If supports_lit is true, verify the ICD key IS present in the TXT record, and it has the value of 0 or 1 (ASCII) SII TXT key: • If supports_icd is true and supports_lit is false, set sit_mode to true • If supports_icd is true and supports_lit is true, set sit_mode to true if ICD=0 otherwise set sit_mode to false • If supports_icd is false, set sit_mode to false • If sit_mode is true, verify that the SII key IS present in the TXT record • if the SII key is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms) SAI TXT key: • if supports_icd is true, verify that the SAI key is present in the TXT record • If the SAI key is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms)"),
67+
"TH verifies the following from the returned records: The hostname must be a fixed-length twelve-character (or sixteen-character) hexadecimal string, encoded as ASCII (UTF-8) text using capital letters.. ICD TXT key: • If supports_lit is false, verify that the ICD key is NOT present in the TXT record • If supports_lit is true, verify the ICD key IS present in the TXT record, and it has the value of 0 or 1 (ASCII) SII TXT key: • If supports_icd is true and supports_lit is false, set sit_mode to true • If supports_icd is true and supports_lit is true, set sit_mode to true if ICD=0 otherwise set sit_mode to false • If supports_icd is false, set sit_mode to false • If sit_mode is true, verify that the SII key IS present in the TXT record • if the SII key is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms) SAI TXT key: • if supports_icd is true, verify that the SAI key is present in the TXT record • If the SAI key is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms)"),
6868
TestStep(10, "TH performs a DNS-SD browse for _I<hhhh>._sub._matter._tcp.local, where <hhhh> is the 64-bit compressed Fabric identifier, expressed as a fixed-length, sixteencharacter hexadecimal string, encoded as ASCII (UTF-8) text using capital letters.",
6969
"Verify DUT returns a PTR record with DNS-SD instance name set to instance_name"),
7070
TestStep(11, "TH performs a DNS-SD browse for _matter._tcp.local",
@@ -169,15 +169,15 @@ def extract_ipv6_address(text):
169169
return items[-1]
170170

171171
@staticmethod
172-
def verify_hostname(hostname: str, char_length: int) -> bool:
172+
def verify_hostname(hostname: str) -> bool:
173173
# Remove '.local' or '.local.' suffix if present
174174
if hostname.endswith('.local'):
175175
hostname = hostname[:-6]
176176
elif hostname.endswith('.local.'):
177177
hostname = hostname[:-7]
178178

179-
# Regular expression to match an uppercase hexadecimal string of the specified length
180-
pattern = re.compile(rf'^[0-9A-F]{{{char_length}}}$')
179+
# Regular expression to match an uppercase hexadecimal string of 12 or 16 characters
180+
pattern = re.compile(r'^[0-9A-F]{12}$|^[0-9A-F]{16}$')
181181
return bool(pattern.match(hostname))
182182

183183
@async_test_body
@@ -186,8 +186,6 @@ async def test_TC_SC_4_3(self):
186186
supports_lit = None
187187
active_mode_threshold_ms = None
188188
instance_name = None
189-
# icd_value = None
190-
# sit_mode = None
191189

192190
# *** STEP 1 ***
193191
# DUT is commissioned on the same fabric as TH.
@@ -243,7 +241,7 @@ async def test_TC_SC_4_3(self):
243241

244242
# Will be used in Step 8 and 11
245243
# This is the hostname
246-
server = operational_record.server
244+
hostname = operational_record.server
247245

248246
# Verify SRV record is returned
249247
srv_record_returned = operational_record is not None and operational_record.service_name == instance_qname
@@ -270,51 +268,33 @@ async def test_TC_SC_4_3(self):
270268
self.step(8)
271269

272270
quada_record = await mdns.get_service_by_record_type(
273-
service_name=server,
271+
service_name=hostname,
274272
record_type=DNSRecordType.AAAA,
275273
log_output=True
276274
)
277275

278276
answer_record_type = quada_record.get_type(quada_record.type)
279-
quada = _TYPES[_TYPE_AAAA]
277+
quada_record_type = _TYPES[_TYPE_AAAA]
280278

281279
# Verify AAAA record is returned
282-
asserts.assert_equal(server, quada_record.name, f"Server name mismatch: {server} vs {quada_record.name}")
283-
asserts.assert_equal(quada, answer_record_type, f"Record type should be {quada} but got {answer_record_type}")
280+
asserts.assert_equal(hostname, quada_record.name, f"Server name mismatch: {hostname} vs {quada_record.name}")
281+
asserts.assert_equal(quada_record_type, answer_record_type, f"Record type should be {quada_record_type} but got {answer_record_type}")
284282

285283
# # *** STEP 9 ***
286-
# TH verifies the following from the returned records: Hostname: • If (MCORE.COM.WIFI OR MCORE.COM.ETH) target, the hostname must be a
287-
# 12-character uppercase hexadecimal string. • If (MCORE.COM.THR) target, the hostname must be a 16-character hex string using capital
288-
# letters. ICD TXT key: • If supports_lit is false, verify that the ICD key is NOT present in the TXT record • If supports_lit is true,
289-
# verify the ICD key IS present in the TXT record, and it has the value of 0 or 1 (ASCII) SII TXT key: • If supports_icd is true and
290-
# supports_lit is false, set sit_mode to true • If supports_icd is true and supports_lit is true, set sit_mode to true if ICD=0
291-
# otherwise set sit_mode to false • If supports_icd is false, set sit_mode to false • If sit_mode is true, verify that the SII key IS
292-
# present in the TXT record • if the SII key is present, verify it is a decimal value with no leading zeros and is less than or equal
293-
# to 3600000 (1h in ms) SAI TXT key: • if supports_icd is true, verify that the SAI key is present in the TXT record • If the SAI key
294-
# is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms)
284+
# TH verifies the following from the returned records: The hostname must be a fixed-length twelve-character (or sixteen-character)
285+
# hexadecimal string, encoded as ASCII (UTF-8) text using capital letters.. ICD TXT key: • If supports_lit is false, verify that the
286+
# ICD key is NOT present in the TXT record • If supports_lit is true, verify the ICD key IS present in the TXT record, and it has the
287+
# value of 0 or 1 (ASCII) SII TXT key: • If supports_icd is true and supports_lit is false, set sit_mode to true • If supports_icd is
288+
# true and supports_lit is true, set sit_mode to true if ICD=0 otherwise set sit_mode to false • If supports_icd is false, set
289+
# sit_mode to false • If sit_mode is true, verify that the SII key IS present in the TXT record • if the SII key is present, verify
290+
# it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms) SAI TXT key: • if supports_icd is true,
291+
# verify that the SAI key is present in the TXT record • If the SAI key is present, verify it is a decimal value with no leading
292+
# zeros and is less than or equal to 3600000 (1h in ms)
295293
self.step(9)
296294

297-
# Check MCORE.COM PICS
298-
mc_wifi = 'MCORE.COM.WIFI'
299-
mc_eth = 'MCORE.COM.ETH'
300-
mc_thr = 'MCORE.COM.THR'
301-
302-
303-
## wildcard read of cnet clusters, featuremaps all endpoints, does it support wifi/thread?
304-
305-
is_mc_wifi = self.check_pics(mc_wifi)
306-
is_mc_eth = self.check_pics(mc_eth)
307-
is_thr = self.check_pics(mc_thr)
308-
is_eth_or_wifi = is_mc_wifi or is_mc_eth
309-
310-
if is_eth_or_wifi:
311-
mcore_com = mc_wifi if is_mc_wifi else mc_eth if is_mc_eth else None
312-
asserts.assert_true(self.verify_hostname(hostname=server, char_length=12),
313-
f"Hostname for '{server}' is not a 12-character uppercase hexadecimal string for PICS {mcore_com}")
314-
else:
315-
if is_thr:
316-
asserts.assert_true(self.verify_hostname(hostname=server, char_length=16),
317-
f"Hostname for '{server}' is not a 16-character uppercase hexadecimal string for PICS {mc_thr}")
295+
# Verify hostname character length (12 or 16)
296+
asserts.assert_true(self.verify_hostname(hostname=hostname),
297+
f"Hostname for '{hostname}' is not a 12 or 16 character uppercase hexadecimal string")
318298

319299
# ICD TXT KEY
320300
if supports_lit:
@@ -388,12 +368,13 @@ async def test_TC_SC_4_3(self):
388368
asserts.assert_true(result, message)
389369

390370
# # *** STEP 10 ***
391-
# TH performs a DNS-SD browse for _I<hhhh>._sub._matter._tcp.local, where <hhhh> is the 64-bit compressed Fabric identifier, expressed as a fixed-length, sixteencharacter hexadecimal string, encoded as
392-
# ASCII (UTF-8) text using capital letters. Verify DUT returns a PTR record with DNS-SD instance name set to instance_name
371+
# TH performs a DNS-SD browse for _I<hhhh>._sub._matter._tcp.local, where <hhhh> is the 64-bit compressed
372+
# Fabric identifier, expressed as a fixed-length, sixteencharacter hexadecimal string, encoded as ASCII (UTF-8)
373+
# text using capital letters. Verify DUT returns a PTR record with DNS-SD instance name set to instance_name
393374
self.step(10)
394375
service_types = await mdns.get_service_types(log_output=True)
395376
op_sub_type = self.get_operational_subtype()
396-
asserts.assert_in(op_sub_type, service_types, f"No PTR record with DNS-SD instance name '{op_sub_type}'")
377+
asserts.assert_in(op_sub_type, service_types, f"No PTR record with DNS-SD instance name '{op_sub_type}' wsa found.")
397378

398379
# # *** STEP 11 ***
399380
# TH performs a DNS-SD browse for _matter._tcp.local
@@ -406,7 +387,7 @@ async def test_TC_SC_4_3(self):
406387
)
407388

408389
# Verify DUT returns a PTR record with DNS-SD instance name set instance_name
409-
asserts.assert_equal(op_service_info.server, server,
390+
asserts.assert_equal(op_service_info.server, hostname,
410391
f"No PTR record with DNS-SD instance name '{MdnsServiceType.OPERATIONAL.value}'")
411392
asserts.assert_equal(instance_name, op_service_info.instance_name, "Instance name mismatch")
412393

0 commit comments

Comments
 (0)