diff --git a/src/python_testing/TC_SC_4_3.py b/src/python_testing/TC_SC_4_3.py index 86723cecc71336..59428b23ac7a52 100644 --- a/src/python_testing/TC_SC_4_3.py +++ b/src/python_testing/TC_SC_4_3.py @@ -24,7 +24,6 @@ import ipaddress import logging -import dns.resolver import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, TestStep @@ -213,7 +212,6 @@ async def test_TC_SC_4_3(self): # TH performs a query for the SRV record against the qname instance_qname. # Verify SRV record is returned self.step(6) - print("\n"*10) mdns = MdnsDiscovery() operational_record = await mdns.get_service_by_record_type( service_name=instance_qname, @@ -221,8 +219,8 @@ async def test_TC_SC_4_3(self): record_type=DNSRecordType.SRV, log_output=True, load_from_cache=False - ) - + ) + # Verify SRV record is returned srv_record_returned = operational_record is not None and operational_record.service_name == instance_qname asserts.assert_true(srv_record_returned, "SRV record was not returned") @@ -247,31 +245,8 @@ async def test_TC_SC_4_3(self): # TH performs a query for the AAAA record against the target listed in the SRV record. # Verify AAAA record is returned self.step(8) - - # domain = operational_record.server - # try: - # answers = dns.resolver.resolve(domain, 'AAAA') - # for answer in answers: - # print(f"AAAA record for {domain}: {answer}") - # except dns.resolver.NoAnswer: - # print(f"No AAAA record found for {domain}") - # except dns.resolver.NXDOMAIN: - # print(f"Domain {domain} does not exist") - # except Exception as e: - # print(f"An error occurred: {e}") - - # print("\n"*10) - # mdns = MdnsDiscovery() - # await mdns.get_service_by_record_type( - # service_name=f"{instance_name}.{MdnsServiceType.OPERATIONAL.value}", - # service_type=MdnsServiceType.OPERATIONAL.value, - # record_type=DNSRecordType.TXT, - # log_output=True, - # load_from_cache=False - # ) - # print("\n"*10) - + # PENDING # # *** STEP 9 *** # TH verifies the following from the returned records: Hostname: • If (MCORE.COM.WIFI OR MCORE.COM.ETH) target, the hostname must be a @@ -285,94 +260,90 @@ async def test_TC_SC_4_3(self): # is present, verify it is a decimal value with no leading zeros and is less than or equal to 3600000 (1h in ms) self.step(9) - # # ICD TXT KEY - # if supports_lit: - # logging.info("supports_lit is true, verify the ICD key IS present in the TXT record, and it has the value of 0 or 1 (ASCII).") - - # # Verify the ICD key IS present - # asserts.assert_in('ICD', operational.txt_record, "ICD key is NOT present in the TXT record.") - - # # Verify it has the value of 0 or 1 (ASCII) - # icd_value = int(operational.txt_record['ICD']) - # asserts.assert_true(icd_value == 0 or icd_value == 1, "ICD value is different than 0 or 1 (ASCII).") - # else: - # logging.info("supports_lit is false, verify that the ICD key is NOT present in the TXT record.") - # asserts.assert_not_in('ICD', operational.txt_record, "ICD key is present in the TXT record.") - - # # SII TXT KEY - # if supports_icd and not supports_lit: - # sit_mode = True - - # if supports_icd and supports_lit: - # if icd_value == 0: - # sit_mode = True - # else: - # sit_mode = False - - # if not supports_icd: - # sit_mode = False - - # if sit_mode: - # logging.info("sit_mode is True, verify the SII key IS present.") - # asserts.assert_in('SII', operational.txt_record, "SII key is NOT present in the TXT record.") - - # logging.info("Verify SII value is a decimal with no leading zeros and is less than or equal to 3600000 (1h in ms).") - # sii_value = operational.txt_record['SII'] - # result, message = self.verify_decimal_value(sii_value, self.ONE_HOUR_IN_MS) - # asserts.assert_true(result, message) - - # # SAI TXT KEY - # if supports_icd: - # logging.info("supports_icd is True, verify the SAI key IS present.") - # asserts.assert_in('SAI', operational.txt_record, "SAI key is NOT present in the TXT record.") - - # logging.info("Verify SAI value is a decimal with no leading zeros and is less than or equal to 3600000 (1h in ms).") - # sai_value = operational.txt_record['SAI'] - # result, message = self.verify_decimal_value(sai_value, self.ONE_HOUR_IN_MS) - # asserts.assert_true(result, message) - - # # SAT TXT KEY - # if 'SAT' in operational.txt_record: - # logging.info( - # "SAT key is present in TXT record, verify that it is a decimal value with no leading zeros and is less than or equal to 65535.") - # sat_value = operational.txt_record['SAT'] - # result, message = self.verify_decimal_value(sat_value, self.MAX_SAT_VALUE) - # asserts.assert_true(result, message) - - # if supports_icd: - # logging.info("supports_icd is True, verify the SAT value is equal to active_mode_threshold.") - # asserts.assert_equal(int(sat_value), active_mode_threshold_ms) - - # # T TXT KEY - # if 'T' in operational.txt_record: - # logging.info(f"T key is present in TXT record, verify if that it is a decimal value with no leading zeros and is less than or equal to 6. Convert the value to a bitmap and verify bit 0 is clear.") - # t_value = operational.txt_record['T'] - # result, message = self.verify_t_value(t_value) - # asserts.assert_true(result, message) - - # # AAAA - # logging.info("Verify the AAAA record contains at least one IPv6 address") - # result, message = self.contains_ipv6_address(operational.addresses) - # asserts.assert_true(result, message) + # ICD TXT KEY + if supports_lit: + logging.info("supports_lit is true, verify the ICD key IS present in the TXT record, and it has the value of 0 or 1 (ASCII).") + + # Verify the ICD key IS present + asserts.assert_in('ICD', operational_record.txt_record, "ICD key is NOT present in the TXT record.") + + # Verify it has the value of 0 or 1 (ASCII) + icd_value = int(operational_record.txt_record['ICD']) + asserts.assert_true(icd_value == 0 or icd_value == 1, "ICD value is different than 0 or 1 (ASCII).") + else: + logging.info("supports_lit is false, verify that the ICD key is NOT present in the TXT record.") + asserts.assert_not_in('ICD', operational_record.txt_record, "ICD key is present in the TXT record.") + + # SII TXT KEY + if supports_icd and not supports_lit: + sit_mode = True + + if supports_icd and supports_lit: + if icd_value == 0: + sit_mode = True + else: + sit_mode = False + + if not supports_icd: + sit_mode = False + + if sit_mode: + logging.info("sit_mode is True, verify the SII key IS present.") + asserts.assert_in('SII', operational_record.txt_record, "SII key is NOT present in the TXT record.") + + logging.info("Verify SII value is a decimal with no leading zeros and is less than or equal to 3600000 (1h in ms).") + sii_value = operational_record.txt_record['SII'] + result, message = self.verify_decimal_value(sii_value, self.ONE_HOUR_IN_MS) + asserts.assert_true(result, message) + + # SAI TXT KEY + if supports_icd: + logging.info("supports_icd is True, verify the SAI key IS present.") + asserts.assert_in('SAI', operational_record.txt_record, "SAI key is NOT present in the TXT record.") + + logging.info("Verify SAI value is a decimal with no leading zeros and is less than or equal to 3600000 (1h in ms).") + sai_value = operational_record.txt_record['SAI'] + result, message = self.verify_decimal_value(sai_value, self.ONE_HOUR_IN_MS) + asserts.assert_true(result, message) + + # SAT TXT KEY + if 'SAT' in operational_record.txt_record: + logging.info( + "SAT key is present in TXT record, verify that it is a decimal value with no leading zeros and is less than or equal to 65535.") + sat_value = operational_record.txt_record['SAT'] + result, message = self.verify_decimal_value(sat_value, self.MAX_SAT_VALUE) + asserts.assert_true(result, message) + + if supports_icd: + logging.info("supports_icd is True, verify the SAT value is equal to active_mode_threshold.") + asserts.assert_equal(int(sat_value), active_mode_threshold_ms) + + # T TXT KEY + if 'T' in operational_record.txt_record: + logging.info(f"T key is present in TXT record, verify if that it is a decimal value with no leading zeros and is less than or equal to 6. Convert the value to a bitmap and verify bit 0 is clear.") + t_value = operational_record.txt_record['T'] + result, message = self.verify_t_value(t_value) + asserts.assert_true(result, message) + + # AAAA + logging.info("Verify the AAAA record contains at least one IPv6 address") + result, message = self.contains_ipv6_address(operational_record.addresses) + asserts.assert_true(result, message) # # *** STEP 10 *** # TH performs a DNS-SD browse for _I._sub._matter._tcp.local, where is the 64-bit compressed Fabric identifier, expressed as a fixed-length, sixteencharacter hexadecimal string, encoded as # ASCII (UTF-8) text using capital letters. Verify DUT returns a PTR record with DNS-SD instance name set to instance_name self.step(10) - # service_types = await mdns.get_service_types(log_output=True) - # op_sub_type = self.get_operational_subtype() - # asserts.assert_in(op_sub_type, service_types, f"No PTR record with DNS-SD instance name '{op_sub_type}'") + service_types = await mdns.get_service_types(log_output=True) + op_sub_type = self.get_operational_subtype() + asserts.assert_in(op_sub_type, service_types, f"No PTR record with DNS-SD instance name '{op_sub_type}'") # # *** STEP 11 *** # TH performs a DNS-SD browse for _matter._tcp.local # Verify DUT returns a PTR record with DNS-SD instance name set to instance_name self.step(11) - - - - # input() - + # PENDING if __name__ == "__main__": default_matter_test_main()