From ebd79a359358d802adf733cbd6b35eb08e2b03de Mon Sep 17 00:00:00 2001 From: sumaky Date: Thu, 22 Aug 2024 18:49:16 +0530 Subject: [PATCH 01/24] added drlkcluster variable --- src/python_testing/TC_DRLK_2_9.py | 566 ++++++++++++++++++++++++++++++ 1 file changed, 566 insertions(+) create mode 100644 src/python_testing/TC_DRLK_2_9.py diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py new file mode 100644 index 00000000000000..472c4822c35473 --- /dev/null +++ b/src/python_testing/TC_DRLK_2_9.py @@ -0,0 +1,566 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_LOCK_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from chip.interaction_model import InteractionModelError, Status +from drlk_2_x_common import DRLK_COMMON +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +logger = logging.getLogger(__name__) + +drlkcluster = Clusters.DoorLock + + +class TC_DRLK_2_9(MatterBaseTest, DRLK_COMMON): + + def steps_TC_DRLK_2_9(self) -> list[TestStep]: + steps = [ + + TestStep("1", "TH reads NumberOfTotalUsersSupported attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that TH is able to read the attribute successfully."), + TestStep("2b", " TH reads MinPINCodeLength attribute .", + "Verify that TH is able to read the attribute successfully."), + TestStep("2c", "TH reads MaxPINCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2d", "TH reads MinRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2e", "TH reads MaxRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2f", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("3", "TH sends GetCredentialStatus Command .", + "Verify that the DUT responds with GetCredentialStatusResponse Command ."), + TestStep("4", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("5", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE."), + TestStep("6a", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("6b", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("7", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("8", "TH sends ClearCredential Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("9a", "TH sends GetCredentialStatus command to DUT ", + "Verify that the DUT responds with GetCredentialStatusResponse Command."), + TestStep("9b", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("10", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("11", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("12a", "TH sends ClearCredential Command to DUT.", + " Verify that the DUT sends SUCCESS response."), + TestStep("13", " TH sends GetCredentialStatus Command.", + "Verify that the DUT responds with GetCredentialStatusResponse Command with credentialExists=FALSE."), + TestStep("14a", "TH sends ClearCredential Command to DUT", + "if {PICS_SF_ALIRO} verify that the DUT sends a SUCCESS response else DUT sends an INVALID_COMMAND response."), + TestStep("14b", "TH sends ClearCredential Command to DUT with Invalid Credential Type.", + "Verify that the DUT sends an INVALID_COMMAND."), + TestStep("14c", "TH sends ClearUser Command to DUT to clear all the users.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15a", "TH reads NumberOfCredentialsSupportedPerUser attribute from DUT.", + "Verify that TH is able to read the attribute successfully."), + TestStep("15b", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15c", "TH sends SetCredential Command to DUT.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("15d", " TH sends SetCredential Command with CredentialIndex as 'max-num-credential-user'.", + "Verify that the DUT sends SetCredentialResponse command with Status RESOURCE_EXHAUSTION."), + TestStep("15e", "TH sends ClearCredential Command to DUT to clear all the credentials of PIN type.", + "Verify that the DUT sends SUCCESS response."), + TestStep("16", " TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("17", "TH sends SetCredential Command to DUT with CredentialType.RFID.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("18", "TH sends SetCredential Command to DUT with CredentialType.PIN.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("19", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("20", "TH sends SetCredential Command to DUT to modify the CredentialData.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("21", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", + "Verify that the DUT sends SUCCESS response."), + TestStep("23", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + ] + return steps + + async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): + try: + attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, + attribute=attribute) + asserts.assert_equal(expected_status, Status.Success) + return attribute_value + except Exception as e: + logging.error(e) + asserts.assert_equal(expected_status, Status.Success, + f"Error reading attributes, response={attribute_value}") + + def pics_TC_DRLK_2_9(self) -> list[str]: + return ["DRLK.S"] + + async def generate_code(self): + + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code1 = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code2 = bytes(validpincodestr, 'ascii') + inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1) + self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxrfidcodelength) + self.rfid_tag = bytes(validpincodestr, 'ascii') + + async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_user(self, userindex, username, useruniqueid, credentiallist, expected_status: Status = Status.Success): + try: + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetUser(userIndex=userindex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), + "Unexpected return type for GetUserResponse") + asserts.assert_true(response.userIndex == userindex, + "Error when executing GetUserResponse command, credentialExists={}".format( + str(response.userIndex))) + asserts.assert_true(response.userName == username, + "Error when executing GetUserResponse command, credentialExists={}".format( + str(response.userName))) + asserts.assert_true(response.userUniqueID == useruniqueid, + "Error when executing GetUserResponse command, credentialExists={}".format( + str(response.userUniqueID))) + asserts.assert_true(response.credentials == credentiallist, + "Error when executing GetUserResponse command, credentialExists={}".format( + str(response.credentials))) + asserts.assert_equal(expected_status, Status.Success) + + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, + step, userIndex, credential_exists): + if step: + self.step(step) + try: + credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, + credentialType=credentialType) + response = await self.send_single_cmd(endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000, + cmd=drlkcluster.Commands.GetCredentialStatus( + credential=credentials_struct)) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetCredentialStatusResponse), + "Unexpected return type for GetCredentialStatus") + asserts.assert_true(response.credentialExists == credential_exists, + "Error when executing GetCredentialStatus command, credentialExists={}".format( + str(response.credentialExists))) + if (not credential_exists): + asserts.assert_true(response.userIndex == NullValue, + "Error when executing GetCredentialStatus command, credentialExists={}".format( + str(response.userIndex))) + return response + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, Status.Success, f"Unexpected error returned: {e}") + + async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.CredentialTypeEnum, statuscode, credentialIndex, + operationType, userIndex, credentialData, userStatus, userType): + custom_stautus_code = 149 + + credentials = drlkcluster.Structs.CredentialStruct( + credentialType=credential_enum, + credentialIndex=credentialIndex) + try: + logging.info("maxpincodelength value is %s" % (self.maxpincodelength)) + logging.info("maxrfidcodelength value is %s" % (self.maxrfidcodelength)) + logging.info("Credential Data is %s" % (credentialData)) + response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( + operationType=operationType, + credential=credentials, + credentialData=credentialData, + userStatus=userStatus, + userType=userType, + userIndex=userIndex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), + "Unexpected return type for SetCredential") + + if (statuscode != custom_stautus_code): + asserts.assert_true(response.status == statuscode, + "Error sending SetCredential command, status={}".format(str(response.status))) + else: + asserts.assert_true(response.status == 2 or response.status == 3, + "Error sending SetCredential command, status={}".format(str(response.status))) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") + + async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + @async_test_body + async def test_TC_DRLK_2_9(self): + + self.Attrib = 0 + self.numberofcredentialsupportedperuser = None + self.common_cluster_endpoint = 0 + self.app_cluster_endpoint = 1 + self.invalid_credential_type = 9 + self.user_unique_id1 = 6459 + self.user_unique_id2 = 1111 + self.user_name = "xxx" + self.credentialIndex_1 = 1 + self.credentialIndex_2 = 2 + self.credentialIndex_3 = 3 + self.operationType = drlkcluster.Enums.DataOperationTypeEnum.kAdd + self.userIndex_1 = 1 + self.userIndex_2 = 2 + self.invalid_user_status = 5 + self.invalid_user_type = 10 + self.pics_send_setcredential_pin_cmd = False + self.pics_send_setcredential_rfid_cmd = False + self.pin_code = b"" + self.pin_code1 = b"" + self.pin_code2 = b"" + self.inavlid_pincode = b"" + self.rfid_tag = b"" + + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + self.pics_send_setcredential_pin_cmd = True + + if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C22.Rsp") + and self.check_pics("DRLK.S.C23.Tx")): + self.pics_send_setcredential_rfid_cmd = True + + self.step("1") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): + self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfTotalUsersSupported) + self.step("2a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=1, + userName=self.user_name, + userUniqueID=self.user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("2b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.minpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinPINCodeLength) + self.step("2c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.maxpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxPINCodeLength) + self.step("2d") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.minrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinRFIDCodeLength) + self.step("2e") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.maxrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxRFIDCodeLength) + self.step("2f") + await self.generate_code() + if self.pics_send_setcredential_pin_cmd: + + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("3") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=True) + self.step("4") + if self.pics_send_setcredential_pin_cmd: + + await self.set_credential_cmd(credentialData=self.inavlid_pincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_2, userIndex=self.userIndex_1, userStatus=self.invalid_user_status, userType=self.invalid_user_type, statuscode=Status.InvalidCommand) + self.step("5") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_2, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=2) + + self.step("6a") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("6b") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("7") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_3, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.InvalidCommand) + self.step("8") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("9a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): + await self.get_credentials_status(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + self.step("9b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=1) + + self.step("10") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=self.userIndex_2, + userName=self.user_name, + userUniqueID=self.user_unique_id2, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("11") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_2, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("12a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("13") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + self.step("14a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.FeatureMap) + aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning + if (aliro_enabled): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) + await self.clear_credentials_cmd(step=None, credential=credentials) + else: + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, + credentialType=self.invalid_credential_type) + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(self.userIndex_1) + + self.step("15a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A001c")): + + numberofcredentialsupportedperuser = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser) + self.step("15b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=self.userIndex_1, + userName=self.user_name, + userUniqueID=self.user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("15c") + if self.pics_send_setcredential_pin_cmd: + logging.info("setting 'start_credential_index' to value 1 ") + start_credential_index = 1 + while 1: + uniquePincodeString = await self.generate_pincode(self.maxpincodelength) + uniquePincode = bytes(uniquePincodeString, 'ascii') + logging.info("Credential Data value is %s" % (uniquePincode)) + if start_credential_index <= (numberofcredentialsupportedperuser): + await self.set_credential_cmd(credentialData=uniquePincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + start_credential_index += 1 + logging.info(f"The updated value of start_credential_index is {start_credential_index}") + else: + break + self.step("15d") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) + self.step("15e") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("16") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=self.userIndex_1, + userName=self.user_name, + userUniqueID=self.user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("17") + if self.pics_send_setcredential_rfid_cmd: + + await self.set_credential_cmd(credentialData=self.rfid_tag, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kRfid, + credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("18") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("19") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid), + drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(self.userIndex_1, self.user_name, self.user_unique_id1, credentiallist, Status.Success) + + self.step("20") + if self.pics_send_setcredential_pin_cmd: + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("21") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + await self.get_user(self.userIndex_1, self.user_name, self.user_unique_id1, credentiallist, Status.Success) + + self.step("22") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + await self.clear_credentials_cmd(step=None, credential=NullValue) + + self.step("23") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(self.userIndex_1) + + +if __name__ == '__main__': + default_matter_test_main() From 7075ee3456ee63a08d59be9bf8dd4775a3bc0497 Mon Sep 17 00:00:00 2001 From: sumaky <63414112+sumaky@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:45:58 +0530 Subject: [PATCH 02/24] Delete src/python_testing/TC_DRLK_2_9.py --- src/python_testing/TC_DRLK_2_9.py | 566 ------------------------------ 1 file changed, 566 deletions(-) delete mode 100644 src/python_testing/TC_DRLK_2_9.py diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py deleted file mode 100644 index 472c4822c35473..00000000000000 --- a/src/python_testing/TC_DRLK_2_9.py +++ /dev/null @@ -1,566 +0,0 @@ -# -# Copyright (c) 2024 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments -# for details about the block below. -# -# === BEGIN CI TEST ARGUMENTS === -# test-runner-runs: run1 -# test-runner-run/run1/app: ${CHIP_LOCK_APP} -# test-runner-run/run1/factoryreset: True -# test-runner-run/run1/quiet: True -# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json -# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto -# === END CI TEST ARGUMENTS === - -import logging - -import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from chip.interaction_model import InteractionModelError, Status -from drlk_2_x_common import DRLK_COMMON -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches -from mobly import asserts - -logger = logging.getLogger(__name__) - -drlkcluster = Clusters.DoorLock - - -class TC_DRLK_2_9(MatterBaseTest, DRLK_COMMON): - - def steps_TC_DRLK_2_9(self) -> list[TestStep]: - steps = [ - - TestStep("1", "TH reads NumberOfTotalUsersSupported attribute.", - "Verify that TH is able to read the attribute successfully."), - TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that TH is able to read the attribute successfully."), - TestStep("2b", " TH reads MinPINCodeLength attribute .", - "Verify that TH is able to read the attribute successfully."), - TestStep("2c", "TH reads MaxPINCodeLength attribute.", - "Verify that TH is able to read the attribute successfully."), - TestStep("2d", "TH reads MinRFIDCodeLength attribute.", - "Verify that TH is able to read the attribute successfully."), - TestStep("2e", "TH reads MaxRFIDCodeLength attribute.", - "Verify that TH is able to read the attribute successfully."), - TestStep("2f", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), - TestStep("3", "TH sends GetCredentialStatus Command .", - "Verify that the DUT responds with GetCredentialStatusResponse Command ."), - TestStep("4", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), - TestStep("5", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE."), - TestStep("6a", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), - TestStep("6b", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), - TestStep("7", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), - TestStep("8", "TH sends ClearCredential Command to DUT.", - "Verify that the DUT sends SUCCESS response."), - TestStep("9a", "TH sends GetCredentialStatus command to DUT ", - "Verify that the DUT responds with GetCredentialStatusResponse Command."), - TestStep("9b", "TH sends ClearUser Command to DUT.", - "Verify that the DUT sends SUCCESS response"), - TestStep("10", "TH sends SetUser Command to DUT.", - "Verify that the DUT sends SUCCESS response."), - TestStep("11", "TH sends SetCredential Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), - TestStep("12a", "TH sends ClearCredential Command to DUT.", - " Verify that the DUT sends SUCCESS response."), - TestStep("13", " TH sends GetCredentialStatus Command.", - "Verify that the DUT responds with GetCredentialStatusResponse Command with credentialExists=FALSE."), - TestStep("14a", "TH sends ClearCredential Command to DUT", - "if {PICS_SF_ALIRO} verify that the DUT sends a SUCCESS response else DUT sends an INVALID_COMMAND response."), - TestStep("14b", "TH sends ClearCredential Command to DUT with Invalid Credential Type.", - "Verify that the DUT sends an INVALID_COMMAND."), - TestStep("14c", "TH sends ClearUser Command to DUT to clear all the users.", - "Verify that the DUT sends SUCCESS response."), - TestStep("15a", "TH reads NumberOfCredentialsSupportedPerUser attribute from DUT.", - "Verify that TH is able to read the attribute successfully."), - TestStep("15b", "TH sends SetUser Command to DUT.", - "Verify that the DUT sends SUCCESS response."), - TestStep("15c", "TH sends SetCredential Command to DUT.", - "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), - TestStep("15d", " TH sends SetCredential Command with CredentialIndex as 'max-num-credential-user'.", - "Verify that the DUT sends SetCredentialResponse command with Status RESOURCE_EXHAUSTION."), - TestStep("15e", "TH sends ClearCredential Command to DUT to clear all the credentials of PIN type.", - "Verify that the DUT sends SUCCESS response."), - TestStep("16", " TH sends SetUser Command to DUT.", - "Verify that the DUT sends SUCCESS response"), - TestStep("17", "TH sends SetCredential Command to DUT with CredentialType.RFID.", - "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), - TestStep("18", "TH sends SetCredential Command to DUT with CredentialType.PIN.", - "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), - TestStep("19", "TH sends GetUser Command to DUT.", - "Verify that the DUT responds with GetUserResponse Command."), - TestStep("20", "TH sends SetCredential Command to DUT to modify the CredentialData.", - "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), - TestStep("21", "TH sends GetUser Command to DUT.", - "Verify that the DUT responds with GetUserResponse Command."), - TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", - "Verify that the DUT sends SUCCESS response."), - TestStep("23", "TH sends ClearUser Command to DUT.", - "Verify that the DUT sends SUCCESS response."), - ] - return steps - - async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): - try: - attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, - attribute=attribute) - asserts.assert_equal(expected_status, Status.Success) - return attribute_value - except Exception as e: - logging.error(e) - asserts.assert_equal(expected_status, Status.Success, - f"Error reading attributes, response={attribute_value}") - - def pics_TC_DRLK_2_9(self) -> list[str]: - return ["DRLK.S"] - - async def generate_code(self): - - validpincodestr = await self.generate_pincode(self.maxpincodelength) - self.pin_code = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxpincodelength) - self.pin_code1 = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxpincodelength) - self.pin_code2 = bytes(validpincodestr, 'ascii') - inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1) - self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxrfidcodelength) - self.rfid_tag = bytes(validpincodestr, 'ascii') - - async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.assert_equal(expected_status, Status.Success) - except InteractionModelError as e: - asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - - async def get_user(self, userindex, username, useruniqueid, credentiallist, expected_status: Status = Status.Success): - try: - response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetUser(userIndex=userindex), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), - "Unexpected return type for GetUserResponse") - asserts.assert_true(response.userIndex == userindex, - "Error when executing GetUserResponse command, credentialExists={}".format( - str(response.userIndex))) - asserts.assert_true(response.userName == username, - "Error when executing GetUserResponse command, credentialExists={}".format( - str(response.userName))) - asserts.assert_true(response.userUniqueID == useruniqueid, - "Error when executing GetUserResponse command, credentialExists={}".format( - str(response.userUniqueID))) - asserts.assert_true(response.credentials == credentiallist, - "Error when executing GetUserResponse command, credentialExists={}".format( - str(response.credentials))) - asserts.assert_equal(expected_status, Status.Success) - - except InteractionModelError as e: - asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - - async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, - step, userIndex, credential_exists): - if step: - self.step(step) - try: - credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, - credentialType=credentialType) - response = await self.send_single_cmd(endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000, - cmd=drlkcluster.Commands.GetCredentialStatus( - credential=credentials_struct)) - asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetCredentialStatusResponse), - "Unexpected return type for GetCredentialStatus") - asserts.assert_true(response.credentialExists == credential_exists, - "Error when executing GetCredentialStatus command, credentialExists={}".format( - str(response.credentialExists))) - if (not credential_exists): - asserts.assert_true(response.userIndex == NullValue, - "Error when executing GetCredentialStatus command, credentialExists={}".format( - str(response.userIndex))) - return response - except InteractionModelError as e: - logging.error(e) - asserts.assert_equal(e.status, Status.Success, f"Unexpected error returned: {e}") - - async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.CredentialTypeEnum, statuscode, credentialIndex, - operationType, userIndex, credentialData, userStatus, userType): - custom_stautus_code = 149 - - credentials = drlkcluster.Structs.CredentialStruct( - credentialType=credential_enum, - credentialIndex=credentialIndex) - try: - logging.info("maxpincodelength value is %s" % (self.maxpincodelength)) - logging.info("maxrfidcodelength value is %s" % (self.maxrfidcodelength)) - logging.info("Credential Data is %s" % (credentialData)) - response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( - operationType=operationType, - credential=credentials, - credentialData=credentialData, - userStatus=userStatus, - userType=userType, - userIndex=userIndex), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), - "Unexpected return type for SetCredential") - - if (statuscode != custom_stautus_code): - asserts.assert_true(response.status == statuscode, - "Error sending SetCredential command, status={}".format(str(response.status))) - else: - asserts.assert_true(response.status == 2 or response.status == 3, - "Error sending SetCredential command, status={}".format(str(response.status))) - except InteractionModelError as e: - logging.exception(e) - asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") - - async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): - try: - - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - except InteractionModelError as e: - logging.exception(e) - asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - - @async_test_body - async def test_TC_DRLK_2_9(self): - - self.Attrib = 0 - self.numberofcredentialsupportedperuser = None - self.common_cluster_endpoint = 0 - self.app_cluster_endpoint = 1 - self.invalid_credential_type = 9 - self.user_unique_id1 = 6459 - self.user_unique_id2 = 1111 - self.user_name = "xxx" - self.credentialIndex_1 = 1 - self.credentialIndex_2 = 2 - self.credentialIndex_3 = 3 - self.operationType = drlkcluster.Enums.DataOperationTypeEnum.kAdd - self.userIndex_1 = 1 - self.userIndex_2 = 2 - self.invalid_user_status = 5 - self.invalid_user_type = 10 - self.pics_send_setcredential_pin_cmd = False - self.pics_send_setcredential_rfid_cmd = False - self.pin_code = b"" - self.pin_code1 = b"" - self.pin_code2 = b"" - self.inavlid_pincode = b"" - self.rfid_tag = b"" - - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") - and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): - self.pics_send_setcredential_pin_cmd = True - - if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C22.Rsp") - and self.check_pics("DRLK.S.C23.Tx")): - self.pics_send_setcredential_rfid_cmd = True - - self.step("1") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): - self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.NumberOfTotalUsersSupported) - self.step("2a") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): - try: - await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( - operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, - userIndex=1, - userName=self.user_name, - userUniqueID=self.user_unique_id1, - userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, - userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, - credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - except InteractionModelError as e: - logging.exception(e) - - self.step("2b") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): - self.minpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.MinPINCodeLength) - self.step("2c") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): - self.maxpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.MaxPINCodeLength) - self.step("2d") - if self.pics_guard(self.check_pics("DRLK.S.F01")): - self.minrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.MinRFIDCodeLength) - self.step("2e") - if self.pics_guard(self.check_pics("DRLK.S.F01")): - self.maxrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.MaxRFIDCodeLength) - self.step("2f") - await self.generate_code() - if self.pics_send_setcredential_pin_cmd: - - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - self.step("3") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") - and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): - await self.get_credentials_status(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=True) - self.step("4") - if self.pics_send_setcredential_pin_cmd: - - await self.set_credential_cmd(credentialData=self.inavlid_pincode, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_2, userIndex=self.userIndex_1, userStatus=self.invalid_user_status, userType=self.invalid_user_type, statuscode=Status.InvalidCommand) - self.step("5") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_2, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=2) - - self.step("6a") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) - self.step("6b") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code1, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) - self.step("7") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code2, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_3, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.InvalidCommand) - self.step("8") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) - - self.step("9a") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): - await self.get_credentials_status(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) - self.step("9b") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): - await self.send_clear_user_cmd(user_index=1) - - self.step("10") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): - try: - await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( - operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, - userIndex=self.userIndex_2, - userName=self.user_name, - userUniqueID=self.user_unique_id2, - userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, - userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, - credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - except InteractionModelError as e: - logging.exception(e) - - self.step("11") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_2, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - self.step("12a") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) - - self.step("13") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): - await self.get_credentials_status(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) - self.step("14a") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.FeatureMap) - aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning - if (aliro_enabled): - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) - await self.clear_credentials_cmd(step=None, credential=credentials) - else: - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") - - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.InvalidCommand, - "Unexpected error sending ClearCredential Command with invalid CredentialTpe") - - self.step("14b") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, - credentialType=self.invalid_credential_type) - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.InvalidCommand, - "Unexpected error sending ClearCredential Command with invalid CredentialTpe") - - self.step("14c") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): - await self.send_clear_user_cmd(self.userIndex_1) - - self.step("15a") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A001c")): - - numberofcredentialsupportedperuser = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, - cluster=drlkcluster, - attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser) - self.step("15b") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): - try: - await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( - operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, - userIndex=self.userIndex_1, - userName=self.user_name, - userUniqueID=self.user_unique_id1, - userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, - userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, - credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - except InteractionModelError as e: - logging.exception(e) - - self.step("15c") - if self.pics_send_setcredential_pin_cmd: - logging.info("setting 'start_credential_index' to value 1 ") - start_credential_index = 1 - while 1: - uniquePincodeString = await self.generate_pincode(self.maxpincodelength) - uniquePincode = bytes(uniquePincodeString, 'ascii') - logging.info("Credential Data value is %s" % (uniquePincode)) - if start_credential_index <= (numberofcredentialsupportedperuser): - await self.set_credential_cmd(credentialData=uniquePincode, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=start_credential_index, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - start_credential_index += 1 - logging.info(f"The updated value of start_credential_index is {start_credential_index}") - else: - break - self.step("15d") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=start_credential_index, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) - self.step("15e") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) - - self.step("16") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): - try: - await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( - operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, - userIndex=self.userIndex_1, - userName=self.user_name, - userUniqueID=self.user_unique_id1, - userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, - userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, - credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - except InteractionModelError as e: - logging.exception(e) - - self.step("17") - if self.pics_send_setcredential_rfid_cmd: - - await self.set_credential_cmd(credentialData=self.rfid_tag, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kRfid, - credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - self.step("18") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - - self.step("19") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): - - credentiallist: list[drlkcluster.Structs.CredentialStruct] - credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid), - drlkcluster.Structs.CredentialStruct(credentialIndex=self.credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] - await self.get_user(self.userIndex_1, self.user_name, self.user_unique_id1, credentiallist, Status.Success) - - self.step("20") - if self.pics_send_setcredential_pin_cmd: - await self.set_credential_cmd(credentialData=self.pin_code1, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=self.credentialIndex_1, userIndex=self.userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - - self.step("21") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): - await self.get_user(self.userIndex_1, self.user_name, self.user_unique_id1, credentiallist, Status.Success) - - self.step("22") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - await self.clear_credentials_cmd(step=None, credential=NullValue) - - self.step("23") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): - await self.send_clear_user_cmd(self.userIndex_1) - - -if __name__ == '__main__': - default_matter_test_main() From 2690d4d9fb0b8bacd8c559b75ba563ef3f6b2608 Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 22:41:40 +0530 Subject: [PATCH 03/24] added DRLK_2.5 python script --- src/python_testing/TC_DRLK_2_5.py | 398 ++++++++++++++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 src/python_testing/TC_DRLK_2_5.py diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py new file mode 100644 index 00000000000000..a03c3b38127298 --- /dev/null +++ b/src/python_testing/TC_DRLK_2_5.py @@ -0,0 +1,398 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_LOCK_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +logger = logging.getLogger(__name__) + +drlkcluster = Clusters.DoorLock + + +class TC_DRLK_2_5(MatterBaseTest): + + def steps_TC_DRLK_2_5(self) -> list[TestStep]: + steps = [ + + + TestStep("1", "TH reads NumberOfWeekDaySchedulesSupportedPerUser attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("2b", "TH sends SetWeekDaySchedule Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("2c", "TH sends SetWeekDaySchedule to DUT with different DaysMaskMap.", + "Verify that the DUT sends SUCCESS response."), + TestStep("3", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT sends GetWeekDayScheduleResponse command with expected values."), + TestStep("4", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("5", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("6", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("7", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("8", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("9", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status NOT_FOUND."), + TestStep("10a", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("10b", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), + TestStep("10c", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), + TestStep("11", "TH sends GetWeekDaySchedule Command to DUT.", "Verify that the DUT sends NOT_FOUND response."), + TestStep("12", "TH sends ClearUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), + ] + + return steps + + async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): + try: + attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, + attribute=attribute) + asserts.assert_equal(expected_status, Status.Success) + return attribute_value + except Exception as e: + logging.error(e) + logging.info("Error reading attributes,%s" % (attribute)) + + async def clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + def pics_TC_DRLK_2_5(self) -> list[str]: + return ["DRLK.S", "DRLK.S.F04"] + + async def clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def clear_week_day_schedule_cmd(self, week_day_index, user_index, expected_status): + try: + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(weekDayIndex=week_day_index, userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_weekday_schedule_cmd(self, week_day_index, user_index, days_Mask, start_Hour, start_Minute, end_Hour, end_Minute, expected_status): + + try: + + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetWeekDaySchedule( + weekDayIndex=week_day_index, userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetWeekDayScheduleResponse), + "Unexpected return type for GetWeekDayScheduleResponse") + + if (expected_status == Status.Success): + + asserts.assert_true(response.weekDayIndex == week_day_index, + "Error when executing GetWeekDayScheduleResponse command, weekDayIndex={}".format( + str(response.weekDayIndex))) + asserts.assert_true(response.userIndex == user_index, + "Error when executing GetWeekDayScheduleResponse command, userIndex={}".format( + str(response.userIndex))) + + asserts.assert_true(response.daysMask == days_Mask, + "Error when executing GetWeekDayScheduleResponse command, days_Mask={}".format( + str(response.daysMask))) + asserts.assert_true(response.startHour == start_Hour, + "Error when executing GetWeekDayScheduleResponse command, startHour={}".format( + str(response.startHour))) + asserts.assert_true(response.startMinute == start_Minute, + "Error when executing GetWeekDayScheduleResponse command, startMinute={}".format( + str(response.startMinute))) + asserts.assert_true(response.endHour == end_Hour, + "Error when executing GetWeekDayScheduleResponse command, endHour={}".format( + str(response.endHour))) + asserts.assert_true(response.endMinute == end_Minute, + "Error when executing GetWeekDayScheduleResponse command, endMinute={}".format( + str(response.endMinute))) + + return response + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def set_week_days_schedule_cmd(self, week_day_index, user_index, day_mask_map_index, start_Hour, start_Minute, end_Hour, end_Minute, expected_status): + try: + + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetWeekDaySchedule( + weekDayIndex=week_day_index, + userIndex=user_index, + daysMask=day_mask_map_index, + startHour=start_Hour, + startMinute=start_Minute, + endHour=end_Hour, + endMinute=end_Minute), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + @async_test_body + async def test_TC_DRLK_2_5(self): + + self.common_cluster_endpoint = 0 + self.app_cluster_endpoint = 1 + user_name = "xxx" + user_index = 1 + user_unique_id = 6452 + week_day_index = 1 + day_mask_map_index = 1 + start_Hour = 15 + start_Minute = 45 + end_Hour = 16 + end_Minute = 55 + + self.step("1") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.A0014")): + number_week_day_schedules_supported_per_user = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfWeekDaySchedulesSupportedPerUser) + logging.info("NumberOfWeekDaySchedulesSupportedPerUser %s" % (number_week_day_schedules_supported_per_user)) + self.step("2a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=user_index, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("2b") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + try: + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + + except InteractionModelError as e: + logging.exception(e) + self.step("2c") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + try: + days_masks_map = [2, 4, 8, 16, 32, 64, 24, 42, 51, 107, 123, 127] + for day_mask_map_index in days_masks_map: + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + except InteractionModelError as e: + logging.exception(e) + + self.step("3") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + days_Mask = 127 + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + self.step("4") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 0 + days_Mask = 2 + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("5") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 0 # invalid value + days_Mask = 2 # valid value + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("6") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 1 # valid value + days_Mask = 0 # invalid value + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + + self.step("7") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 1 # valid value + days_Mask = 1 # valid value + start_Hour = 18 # inavlid value > end hour + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + + self.step("8") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + week_day_index = 0 + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("9") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + user_index = 2 # invalid value as it does not exist + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("10a") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 1 + user_index = 1 + await self.clear_week_day_schedule_cmd(week_day_index, + user_index, + Status.Success) + + self.step("10b") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 0 + user_index = 1 + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(week_day_index, user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearWeekDaySchedule Command with invalid week_day_index") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearWeekDaySchedule Command with invalid week_day_index") + self.step("10c") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 1 + user_index = 0 + + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(week_day_index, user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearWeekDaySchedule Command with invalid week_day_index") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearWeekDaySchedule Command with invalid week_day_index") + + self.step("11") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + user_index = 1 # invalid value as it is cleared + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.NotFound) + self.step("12") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.clear_user_cmd(user_index) + + +if __name__ == '__main__': + default_matter_test_main() From 36b1d00cb08af6914bec65094d5e264efe9d4939 Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 22:42:37 +0530 Subject: [PATCH 04/24] Added Script DRLK_2.9 --- src/python_testing/TC_DRLK_2_9.py | 565 ++++++++++++++++++++++++++++++ 1 file changed, 565 insertions(+) create mode 100644 src/python_testing/TC_DRLK_2_9.py diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py new file mode 100644 index 00000000000000..2b4941d1d50cf8 --- /dev/null +++ b/src/python_testing/TC_DRLK_2_9.py @@ -0,0 +1,565 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_LOCK_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from chip.interaction_model import InteractionModelError, Status +from drlk_2_x_common import DRLK_COMMON +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +logger = logging.getLogger(__name__) + +drlkcluster = Clusters.DoorLock + + +class TC_DRLK_2_9(MatterBaseTest, DRLK_COMMON): + + def steps_TC_DRLK_2_9(self) -> list[TestStep]: + steps = [ + + TestStep("1", "TH reads NumberOfTotalUsersSupported attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that TH is able to read the attribute successfully."), + TestStep("2b", " TH reads MinPINCodeLength attribute .", + "Verify that TH is able to read the attribute successfully."), + TestStep("2c", "TH reads MaxPINCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2d", "TH reads MinRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2e", "TH reads MaxRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2f", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("3", "TH sends GetCredentialStatus Command .", + "Verify that the DUT responds with GetCredentialStatusResponse Command ."), + TestStep("4", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("5", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE."), + TestStep("6a", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("6b", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("7", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("8", "TH sends ClearCredential Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("9a", "TH sends GetCredentialStatus command to DUT ", + "Verify that the DUT responds with GetCredentialStatusResponse Command."), + TestStep("9b", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("10", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("11", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("12a", "TH sends ClearCredential Command to DUT.", + " Verify that the DUT sends SUCCESS response."), + TestStep("13", " TH sends GetCredentialStatus Command.", + "Verify that the DUT responds with GetCredentialStatusResponse Command with credentialExists=FALSE."), + TestStep("14a", "TH sends ClearCredential Command to DUT", + "if {PICS_SF_ALIRO} verify that the DUT sends a SUCCESS response else DUT sends an INVALID_COMMAND response."), + TestStep("14b", "TH sends ClearCredential Command to DUT with Invalid Credential Type.", + "Verify that the DUT sends an INVALID_COMMAND."), + TestStep("14c", "TH sends ClearUser Command to DUT to clear all the users.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15a", "TH reads NumberOfCredentialsSupportedPerUser attribute from DUT.", + "Verify that TH is able to read the attribute successfully."), + TestStep("15b", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15c", "TH sends SetCredential Command to DUT.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("15d", " TH sends SetCredential Command with CredentialIndex as 'max-num-credential-user'.", + "Verify that the DUT sends SetCredentialResponse command with Status RESOURCE_EXHAUSTION."), + TestStep("15e", "TH sends ClearCredential Command to DUT to clear all the credentials of PIN type.", + "Verify that the DUT sends SUCCESS response."), + TestStep("16", " TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("17", "TH sends SetCredential Command to DUT with CredentialType.RFID.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("18", "TH sends SetCredential Command to DUT with CredentialType.PIN.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("19", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("20", "TH sends SetCredential Command to DUT to modify the CredentialData.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("21", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", + "Verify that the DUT sends SUCCESS response."), + TestStep("23", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + ] + return steps + + async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): + try: + attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, + attribute=attribute) + asserts.assert_equal(expected_status, Status.Success) + return attribute_value + except Exception as e: + logging.error(e) + asserts.assert_equal(expected_status, Status.Success, + f"Error reading attributes, response={attribute_value}") + + def pics_TC_DRLK_2_9(self) -> list[str]: + return ["DRLK.S"] + + async def generate_code(self): + + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code1 = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxpincodelength) + self.pin_code2 = bytes(validpincodestr, 'ascii') + inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1) + self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') + validpincodestr = await self.generate_pincode(self.maxrfidcodelength) + self.rfid_tag = bytes(validpincodestr, 'ascii') + + async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_user(self, userindex, username, useruniqueid, credentiallist, expected_status: Status = Status.Success): + try: + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetUser(userIndex=userindex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), + "Unexpected return type for GetUserResponse") + asserts.assert_true(response.userIndex == userindex, + "Error when executing GetUserResponse command, userIndex={}".format( + str(response.userIndex))) + asserts.assert_true(response.userName == username, + "Error when executing GetUserResponse command, userName={}".format( + str(response.userName))) + asserts.assert_true(response.userUniqueID == useruniqueid, + "Error when executing GetUserResponse command, userUniqueID={}".format( + str(response.userUniqueID))) + asserts.assert_true(response.credentials == credentiallist, + "Error when executing GetUserResponse command, credentials={}".format( + str(response.credentials))) + asserts.assert_equal(expected_status, Status.Success) + + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, + step, userIndex, credential_exists): + + try: + credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, + credentialType=credentialType) + response = await self.send_single_cmd(endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000, + cmd=drlkcluster.Commands.GetCredentialStatus( + credential=credentials_struct)) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetCredentialStatusResponse), + "Unexpected return type for GetCredentialStatus") + asserts.assert_true(response.credentialExists == credential_exists, + "Error when executing GetCredentialStatus command, credentialExists={}".format( + str(response.credentialExists))) + if (not credential_exists): + asserts.assert_true(response.userIndex == NullValue, + "Error when executing GetCredentialStatus command, userIndex={}".format( + str(response.userIndex))) + return response + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, Status.Success, f"Unexpected error returned: {e}") + + async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.CredentialTypeEnum, statuscode, credentialIndex, + operationType, userIndex, credentialData, userStatus, userType): + custom_stautus_code = 149 + + credentials = drlkcluster.Structs.CredentialStruct( + credentialType=credential_enum, + credentialIndex=credentialIndex) + try: + logging.info("maxpincodelength value is %s" % (self.maxpincodelength)) + logging.info("maxrfidcodelength value is %s" % (self.maxrfidcodelength)) + logging.info("Credential Data is %s" % (credentialData)) + response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( + operationType=operationType, + credential=credentials, + credentialData=credentialData, + userStatus=userStatus, + userType=userType, + userIndex=userIndex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), + "Unexpected return type for SetCredential") + + if (statuscode != custom_stautus_code): + asserts.assert_true(response.status == statuscode, + "Error sending SetCredential command, status={}".format(str(response.status))) + else: + asserts.assert_true(response.status == 2 or response.status == 3, + "Error sending SetCredential command, status={}".format(str(response.status))) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") + + async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + @async_test_body + async def test_TC_DRLK_2_9(self): + + self.Attrib = 0 + numberofcredentialsupportedperuser = None + self.app_cluster_endpoint = 1 + invalid_credential_type = 9 + user_unique_id1 = 6459 + user_unique_id2 = 1111 + user_name = "xxx" + credentialIndex_1 = 1 + credentialIndex_2 = 2 + credentialIndex_3 = 3 + userIndex_1 = 1 + userIndex_2 = 2 + invalid_user_status = 5 + invalid_user_type = 10 + + self.pin_code = b"" + self.pin_code1 = b"" + self.pin_code2 = b"" + self.inavlid_pincode = b"" + self.rfid_tag = b"" + + self.step("1") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): + self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfTotalUsersSupported) + self.step("2a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=1, + userName=user_name, + userUniqueID=user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("2b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.minpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinPINCodeLength) + self.step("2c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.maxpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxPINCodeLength) + self.step("2d") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.minrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinRFIDCodeLength) + self.step("2e") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.maxrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxRFIDCodeLength) + self.step("2f") + await self.generate_code() + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("3") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=True) + self.step("4") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + + await self.set_credential_cmd(credentialData=self.inavlid_pincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_2, userIndex=userIndex_1, userStatus=invalid_user_status, userType=invalid_user_type, statuscode=Status.InvalidCommand) + self.step("5") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_2, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=2) + + self.step("6a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("6b") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("7") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_3, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.InvalidCommand) + self.step("8") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("9a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + self.step("9b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=1) + + self.step("10") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_2, + userName=user_name, + userUniqueID=user_unique_id2, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("11") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_2, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("12a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("13") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + self.step("14a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.FeatureMap) + aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning + if (aliro_enabled): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) + await self.clear_credentials_cmd(step=None, credential=credentials) + else: + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=invalid_credential_type) + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) + + self.step("15a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A001c")): + + numberofcredentialsupportedperuser = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser) + self.step("15b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("15c") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + logging.info("setting 'start_credential_index' to value 1 ") + start_credential_index = 1 + while 1: + uniquePincodeString = await self.generate_pincode(self.maxpincodelength) + uniquePincode = bytes(uniquePincodeString, 'ascii') + logging.info("Credential Data value is %s" % (uniquePincode)) + if start_credential_index <= (numberofcredentialsupportedperuser): + await self.set_credential_cmd(credentialData=uniquePincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + start_credential_index += 1 + logging.info(f"The updated value of start_credential_index is {start_credential_index}") + else: + break + self.step("15d") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) + self.step("15e") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(step=None, credential=credentials) + + self.step("16") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("17") + if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C22.Rsp") + and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.rfid_tag, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kRfid, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("18") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("19") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + + self.step("20") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("21") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + + self.step("22") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + await self.clear_credentials_cmd(step=None, credential=NullValue) + + self.step("23") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) + + +if __name__ == '__main__': + default_matter_test_main() From 9348edf98b3b8607050c1f955b9538b9bab47dea Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 22:48:52 +0530 Subject: [PATCH 05/24] removed DRLK_2_5 yaml file --- .../certification/Test_TC_DRLK_2_5.yaml | 320 ------------------ 1 file changed, 320 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml deleted file mode 100644 index c0c8feb91775cd..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml +++ /dev/null @@ -1,320 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 111.2.5. [TC-DRLK-2.5] Verification for the following Commands - Set Week - Day Schedule, Get Week Day Schedule , Get Week Day Schedule Response, Clear - Week Day Schedule [DUT-Server] - -PICS: - - DRLK.S - - DRLK.S.F08 - -config: - nodeId: 0x12344321 - cluster: "Door Lock" - endpoint: 1 - -tests: - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Precondition: Create new user" - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: "Precondition: Read the user back and verify its fields" - command: "GetUser" - arguments: - values: - - name: "UserIndex" - value: 1 - response: - values: - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - name: "Credentials" - value: [] - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextUserIndex" - value: null - - - label: - "Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute - and saves for future use" - PICS: DRLK.S.F04 && DRLK.S.A0014 - command: "readAttribute" - attribute: "NumberOfWeekDaySchedulesSupportedPerUser" - response: - saveAs: NumberOfWeekDaySchedulesSupportedPerUserValue - constraints: - minValue: 0 - maxValue: 255 - - - label: - "Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for - future use" - PICS: DRLK.S.F08 && DRLK.S.A0011 - command: "readAttribute" - attribute: "NumberOfTotalUsersSupported" - response: - saveAs: NumberOfTotalUsersSupportedValue - constraints: - minValue: 0 - maxValue: 65534 - - - label: - "Step 3: TH send Set Week Day Schedule Command to DUT with the - following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap - as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute - as 55 " - PICS: DRLK.S.F04 && DRLK.S.C0b.Rsp - command: "SetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "DaysMask" - value: 2 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - value: 16 - - name: "EndMinute" - value: 55 - - #issue #18591 - - label: - "Step 4: TH send Get Week Day Schedule Command to DUT with - a)WeekDayIndex as 1 b)UserIndex as 1 " - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x0 - - name: "DaysMask" - value: 2 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - constraints: - hasValue: true - minValue: 16 - - name: "EndMinute" - constraints: - hasValue: true - minValue: 55 - - - label: - "Step 5: TH send Set Week Day Schedule Command to DUT with the - following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as - 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute - as 45 f)EndHour as 16 g)EndMinute as 55" - PICS: DRLK.S.F04 && DRLK.S.C0b.Rsp - command: "SetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - - name: "DaysMask" - value: 7 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - value: 16 - - name: "EndMinute" - value: 55 - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex - as 0 b)UserIndex as 1 " - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x85 - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: - "Step 7: TH sends Get Week Day Schedule Command to DUT with following - values: a)WeekDayIndex as 1 (index of existing Schedule entry) - b)UserIndex as 2 (index on non-existent User)" - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 2 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 2 - - name: "Status" - value: 0x8B - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: - "Step 8: TH sends Clear Week Day Schedule Command to DUT with : - a)WeekDayIndex as 1 b)UserIndex as 1" - PICS: DRLK.S.F04 && DRLK.S.C0d.Rsp - command: "ClearWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - - label: - "Step 9: TH sends Get Week Day Schedule Command to DUT with following - values: a)WeekDayIndex as 1 b)UserIndex as 1" - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x8B - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: "Cleanup the created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 1 From 175640ca8c9fc29c0dbc412bfab0adfe1efebafc Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 22:49:26 +0530 Subject: [PATCH 06/24] removed DRLK_2.9.yaml file --- .../certification/Test_TC_DRLK_2_9.yaml | 471 ------------------ 1 file changed, 471 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml deleted file mode 100644 index 0c0a372b175d7e..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml +++ /dev/null @@ -1,471 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 111.2.9. [TC-DRLK-2.9] Verification for the following Commands - Set - Credential , Set Credential Response, Get Credential Status, Get Credential - Status Response, Clear Credential [DUT-Server] - -PICS: - - DRLK.S - -config: - nodeId: 0x12344321 - cluster: "Door Lock" - endpoint: 1 - -tests: - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Precondition: Create new user with default parameters" - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: "Precondition: Read the user back and verify its fields" - command: "GetUser" - arguments: - values: - - name: "UserIndex" - value: 1 - response: - values: - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - name: "Credentials" - value: [] - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextUserIndex" - value: null - - - label: - "Step 1: TH reads NumberOfTotalUsersSupported attribute and saves for - future use." - PICS: DRLK.S.F08 && DRLK.S.A0011 - command: "readAttribute" - attribute: "NumberOfTotalUsersSupported" - response: - saveAs: NumberOfTotalUsersSupportedValue - constraints: - minValue: 0 - maxValue: 65534 - - - label: - "Step 2: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 1 c)CredentialData as - 123456 d)UserIndex as 1 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123456" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0 - - name: "UserIndex" - value: null - - name: "NextCredentialIndex" - value: 2 - - - label: - "Step 3: TH sends Get Credential Status Command with a)CredentialType - as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - response: - values: - - name: "CredentialExists" - constraints: - type: boolean - - name: "UserIndex" - value: 1 - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextCredentialIndex" - value: null - - - label: - "Step 4: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 2 C)CredentialData as - 4321 D)UserIndex as null e)UserStatus as 5(Invalid value) f)UserType - as 10(Invalid value)" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 2 } - - name: "CredentialData" - value: "4321" - - name: "UserIndex" - value: null - - name: "UserStatus" - value: UserStatusEnum.UnknownEnumValue(5) - - name: "UserType" - value: 10 - response: - values: - - name: "Status" - value: 0x85 - - name: "UserIndex" - value: null - - - label: - "Step 5: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 2 d)CredentialData as - 123456 (same as step 2) e)UserIndex as null f)UserStatus as null - g)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 2 } - - name: "CredentialData" - value: "123456" - - name: "UserIndex" - value: null - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0x02 - - name: "UserIndex" - value: null - - - label: - "Step 6a: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 1 (same as step 2) - c)CredentialData as 123456 d)UserIndex as 1 e)UserStatus as null - f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123456" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - constraints: - anyOf: [0x2, 0x3] - - - label: - "Step 6b: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 0 b)Credential as 1 1 (same as step 2) - c)CredentialData as 123457 d)UserIndex as 1 e)UserStatus as null - f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123457" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - constraints: - anyOf: [0x2, 0x3] - - - label: - "Step 7: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 2 b)Credential as 1 3 c)CredentialData as - 1234567 d)UserIndex as 1 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 2 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 3 } - - name: "CredentialData" - value: "1234567" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0x85 - - - label: - "Step 8: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - - label: - "Step 9: TH sends Get Credential command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - response: - values: - - name: "CredentialExists" - value: false - - name: "UserIndex" - value: null - - name: "CreatorFabricIndex" - value: null - - name: "LastModifiedFabricIndex" - value: null - - name: "NextCredentialIndex" - value: null - - - label: - "Step 10: TH sends Set User Command to DUT with the following values: - a)OperationType as 0 b)UserIndex as 2 c)UserName as xxx d)UserUniqueID - as 6452 e)UserStatus as 1 f)UserType as 0 g)CredentialRule as 0" - PICS: DRLK.S.F08 && DRLK.S.C1a.Rsp - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 2 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: "6452" - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: - "Step 11: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 0 b)Credential as 1 1 c)CredentialData as - 123456 d)UserIndex as 2 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123456" - - name: "UserIndex" - value: 2 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0 - - name: "UserIndex" - value: null - - - label: - "Step 12a: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 0xFFFE" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 65534 } - - - label: - "Step 12b: TH sends Get Credential command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 0xFFFE" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 65534 } - response: - values: - - name: "CredentialExists" - value: false - - name: "UserIndex" - value: null - - name: "CreatorFabricIndex" - value: null - - name: "LastModifiedFabricIndex" - value: null - - name: "NextCredentialIndex" - value: null - - - label: - "Step 13: TH sends Get Credential Status Command with a)CredentialType - as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - response: - values: - - name: "CredentialExists" - value: false - - name: "UserIndex" - value: null - - name: "CreatorFabricIndex" - value: null - - name: "LastModifiedFabricIndex" - value: null - - name: "NextCredentialIndex" - value: null - - - label: - "Step 14: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 8(Invalid value) b)CredentialIndex as 2" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && !DRLK.S.F0d - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 8, CredentialIndex: 2 } - response: - error: INVALID_COMMAND - - - label: - "Step 14: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 9(Invalid value) b)CredentialIndex as 2" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && DRLK.S.F0d - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 9, CredentialIndex: 2 } - response: - error: INVALID_COMMAND - - - label: "Cleanup the first created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 1 - - - label: "Cleanup the second created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 2 From 8b1656acd2c10ebc1cc5638943e52e0acb2b9361 Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 22:55:15 +0530 Subject: [PATCH 07/24] updated DLOG_2_1.yaml --- .../certification/Test_TC_DLOG_2_1.yaml | 93 +++++++++++-------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml b/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml index 45111b016974d2..ebc658f16523b7 100644 --- a/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml @@ -34,6 +34,18 @@ tests: Length of TransferFileDesignator is equal to 32 characters Length of TransferFileDesignator is greater than 32 characters To send a message that mismatches the current transfer mode + 1. Execute the below commands in the interactive mode: + ./chip-tool interactive start + 2. Before running the below steps ensure that \tmp folder on the system does not contain the below files. + If they are present please delete these files: + TH_LOG_OK_NORMAL : "Length_1234567.txt" + TH_LOG_OK_FULL_LENGTH : "Length_123456789123456789123.txt" + 3. Use the below command in the all-cluster-app for setting up the diagonistics logs. + ./chip-all-clusters-app --trace_decode 1 --end_user_support_log ~/tmp/end_user_support_log.txt --network_diagnostics_log ~/tmp/nw_log.txt --crash_log ~/tmp/crash_log.txt + The log file content can be set such that the file size can be as follows to obtain different status code from DUT: + 1. end_user_support_log > 1024 bytes + 2. Make sure that nw_log.txt does not exist + 3. crash_log < 1024 bytes disabled: true - label: "Step 1: Commission DUT to TH" @@ -187,7 +199,7 @@ tests: TH_LOG_OK_NORMAL)" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT sends SendInit message with TransferFileDesignator field set to Length_1234567891234567891 [1707967645.770994][10882:10885] CHIP:ATM: SendInit @@ -219,7 +231,7 @@ tests: by setting Intent field to . NetworkDiag . CrashLogs" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 0 1 0 + diagnosticlogs retrieve-logs-request 0 0 1 0 On TH(chip-tool), Verify that the DUT responds with Success(0) status code for the RetrieveLogsResponse command Verify that LogContent field contains at most 1024 bytes @@ -254,7 +266,7 @@ tests: EndUserSupport, RequestedProtocol= BDX)" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 + diagnosticlogs retrieve-logs-request 0 1 1 0 On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent without TransferFileDesignator @@ -290,7 +302,7 @@ tests: RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_OK_NORMAL)" PICS: "!MCORE.BDX.Initiator" verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT responds with Exhausted(1) status code for the RetrieveLogsResponse command with the LogContent field containing at most 1024 bytes @@ -299,14 +311,40 @@ tests: [1707979121.749593][7593:7596] CHIP:TOO: logContent: 31353238303033363031313533353030333730303234303030303234303133653234303230313138333530313331303034373032313533313031316230323330383230323137303630393261383634383836663730643031303730326130383230323038333038323032303430323031303333313064333030623036303936303836343830313635303330343032303133303832303137303036303932613836343838366637306430313037303161303832303136313034383230313564313532343030303132353031663166663336303230353030383030353031383030353032383030353033383030353034383030353035383030353036383030353037383030353038383030353039383030353061383030353062383030353063383030353064383030353065383030353066383030353130383030353131383030353132383030353133383030353134383030353135383030353136383030353137383030353138383030353139383030353161383030353162383030353163383030353164383030353165383030353166383030353230383030353231383030353232383030353233383030353234383030353235383030353236383030353237383030353238383030353239383030353261383030353262383030353263383030353264383030353265383030353266383030353330383030353331383030353332383030353333383030353334383030353335383030353336383030353337383030353338383030353339383030353361383030353362383030353363383030353364383030353365383030353366383030353430383030353431383030353432383030353433383030353434383030353435383030353436383030353437383030353438383030353439383030353461383030353462383030353463383030353464383030353465383030353466383030353530383030353531383030353532383030353533383030353534383030353535383030353536383030353537383030353538383030353539383030353561383030353562383030353563383030353564383030353565383030353566383030353630383030353631383030353632383030353633383031383234303331363263303431333433353334313330333033303330333035333537343333303330333033303330326433303330323430353030323430363030323430373031323430383030313833313763333037613032303130333830313466653334336639353939343737363362363165653435333931333133333834393466653637643865333030623036303936303836343830633733653461363039363038363438303630393630383634383036303936303836343830363039363038363438303630393630383634383036303936303836}" disabled: true + - label: + "Step 11: TH sends RetrieveLogsRequest Command to DUT with Invalid + Intent : RetrieveLogsRequest(Intent = 3, RequestedProtocol= BDX, + TransferFileDesignator = TH_LOG_OK_NORMAL) Repeat this step with + RequestedProtocol as ResponsePayload" + verification: | + diagnosticlogs retrieve-logs-request 3 0 1 0 --TransferFileDesignator Length_1234567.txt + + On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent invalid Intent(3) + + [1707901794.468552][36124:36127] CHIP:DMG: StatusIB = + [1707901794.468560][36124:36127] CHIP:DMG: { + [1707901794.468569][36124:36127] CHIP:DMG: status = 0x85 (INVALID_COMMAND), + [1707901794.468576][36124:36127] CHIP:DMG: }, + [1707901794.468584][36124:36127] CHIP:DMG: + [1707901794.468591][36124:36127] CHIP:DMG: }, + + Repeat this step by setting RequestedProtocol as ResponsePayload : + + diagnosticlogs retrieve-logs-request 3 1 1 0 --TransferFileDesignator Length_1234567.txt + On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent invalid Intent(3) + [1707901794.468552][36124:36127] CHIP:DMG: StatusIB = + [1707901794.468560][36124:36127] CHIP:DMG: { + [1707901794.468569][36124:36127] CHIP:DMG: status = 0x85 (INVALID_COMMAND), + [1707901794.468576][36124:36127] CHIP:DMG: }, + disabled: true + - label: "Step 12: TH sends RetrieveLogsRequest Command to DUT with Invalid RequestedProtocol : RetrieveLogsRequest(Intent = EndUserSupport,RequestedProtocol= 2, TransferFileDesignator = TH_LOG_OK_NORMAL)" - PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 2 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 2 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent Invalid RequestedProtocol(2) @@ -344,39 +382,14 @@ tests: TransferFileDesignator length : RetrieveLogsRequest(Intent = EndUserSupport,RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_ERROR_EMPTY)" + PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator '' - - [1707904517.151453][36678:36681] CHIP:DMG: ICR moving to [ResponseRe] - [1707904517.151489][36678:36681] CHIP:DMG: InvokeResponseMessage = - [1707904517.151501][36678:36681] CHIP:DMG: { - [1707904517.151511][36678:36681] CHIP:DMG: suppressResponse = false, - [1707904517.151522][36678:36681] CHIP:DMG: InvokeResponseIBs = - [1707904517.151541][36678:36681] CHIP:DMG: [ - [1707904517.151548][36678:36681] CHIP:DMG: InvokeResponseIB = - [1707904517.151565][36678:36681] CHIP:DMG: { - [1707904517.151573][36678:36681] CHIP:DMG: CommandStatusIB = - [1707904517.151582][36678:36681] CHIP:DMG: { - [1707904517.151590][36678:36681] CHIP:DMG: CommandPathIB = - [1707904517.151599][36678:36681] CHIP:DMG: { - [1707904517.151613][36678:36681] CHIP:DMG: EndpointId = 0x0, - [1707904517.151627][36678:36681] CHIP:DMG: ClusterId = 0x32, - [1707904517.151640][36678:36681] CHIP:DMG: CommandId = 0x0, - [1707904517.151652][36678:36681] CHIP:DMG: }, - [1707904517.151670][36678:36681] CHIP:DMG: - [1707904517.151681][36678:36681] CHIP:DMG: StatusIB = - [1707904517.151696][36678:36681] CHIP:DMG: { - [1707904517.151708][36678:36681] CHIP:DMG: status = 0x87 (CONSTRAINT_ERROR), - [1707904517.151720][36678:36681] CHIP:DMG: }, - [1707904517.151734][36678:36681] CHIP:DMG: - [1707904517.151745][36678:36681] CHIP:DMG: }, - [1707904517.151763][36678:36681] CHIP:DMG: - [1707904517.151772][36678:36681] CHIP:DMG: }, - [1707904517.151790][36678:36681] CHIP:DMG: - [1707904517.151798][36678:36681] CHIP:DMG: ], - [1707904517.151816][36678:36681] CHIP:DMG: - [1707904517.151824][36678:36681] CHIP:DMG: InteractionModelRevision = 11 - [1707904517.151830][36678:36681] CHIP:DMG: }," + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator '' + On TH(chip-tool), Verify that DUT sends RetrieveLogsResponse command to TH with Denied(4) status code. + [1719990173.360981][8053:8056] CHIP:TOO: RetrieveLogsResponse: { + [1719990173.361009][8053:8056] CHIP:TOO: status: 4 + [1719990173.361021][8053:8056] CHIP:TOO: logContent: + [1719990173.361030][8053:8056] CHIP:TOO: } disabled: true - label: @@ -385,9 +398,9 @@ tests: EndUserSupport,RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_BAD_LENGTH)" verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567891234567891234567891212345.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567891234567891234567891212345.txt - On TH(chip-tool), Verify that the DUT responds with CONSTRAINT_ERRORfor the RetrieveLogsRequest that was sent Invalid Invalid TransferFileDesignator length(> 32) + On TH(chip-tool), Verify that the DUT responds with CONSTRAINT_ERROR for the RetrieveLogsRequest that was sent Invalid Invalid TransferFileDesignator length(> 32) [1707904517.151453][36678:36681] CHIP:DMG: ICR moving to [ResponseRe] [1707904517.151489][36678:36681] CHIP:DMG: InvokeResponseMessage = From c43c857988762deae657c513e1365e4c94995d64 Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 23:44:47 +0530 Subject: [PATCH 08/24] removed redefined command clear user --- src/python_testing/TC_DRLK_2_5.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py index a03c3b38127298..18703de16dacc5 100644 --- a/src/python_testing/TC_DRLK_2_5.py +++ b/src/python_testing/TC_DRLK_2_5.py @@ -84,15 +84,6 @@ async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_ logging.error(e) logging.info("Error reading attributes,%s" % (attribute)) - async def clear_user_cmd(self, user_index, expected_status: Status = Status.Success): - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.assert_equal(expected_status, Status.Success) - except InteractionModelError as e: - asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - def pics_TC_DRLK_2_5(self) -> list[str]: return ["DRLK.S", "DRLK.S.F04"] From 489ea540700fc8ff19dbb1ebd64522940a61053c Mon Sep 17 00:00:00 2001 From: sumaky Date: Mon, 26 Aug 2024 23:59:18 +0530 Subject: [PATCH 09/24] removed unsed var --- src/python_testing/TC_DRLK_2_5.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py index 18703de16dacc5..c9f8786ee89851 100644 --- a/src/python_testing/TC_DRLK_2_5.py +++ b/src/python_testing/TC_DRLK_2_5.py @@ -29,7 +29,6 @@ import logging import chip.clusters as Clusters -from chip.clusters.Types import NullValue from chip.interaction_model import InteractionModelError, Status from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches from mobly import asserts From 971daa9ceee7c520c8b1fb96ba5eff0331453226 Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 27 Aug 2024 00:41:17 +0530 Subject: [PATCH 10/24] removed unused var --- src/python_testing/TC_DRLK_2_5.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py index c9f8786ee89851..09e2c6595d747e 100644 --- a/src/python_testing/TC_DRLK_2_5.py +++ b/src/python_testing/TC_DRLK_2_5.py @@ -97,9 +97,9 @@ async def clear_user_cmd(self, user_index, expected_status: Status = Status.Succ async def clear_week_day_schedule_cmd(self, week_day_index, user_index, expected_status): try: - response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(weekDayIndex=week_day_index, userIndex=user_index), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(weekDayIndex=week_day_index, userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") @@ -147,7 +147,7 @@ async def get_weekday_schedule_cmd(self, week_day_index, user_index, days_Mask, async def set_week_days_schedule_cmd(self, week_day_index, user_index, day_mask_map_index, start_Hour, start_Minute, end_Hour, end_Minute, expected_status): try: - response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetWeekDaySchedule( + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetWeekDaySchedule( weekDayIndex=week_day_index, userIndex=user_index, daysMask=day_mask_map_index, @@ -242,7 +242,7 @@ async def test_TC_DRLK_2_5(self): self.step("3") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): - days_Mask = 127 + day_mask_map_index = 127 await self.get_weekday_schedule_cmd( week_day_index, user_index, @@ -255,7 +255,7 @@ async def test_TC_DRLK_2_5(self): self.step("4") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): week_day_index = 0 - days_Mask = 2 + day_mask_map_index = 2 await self.set_week_days_schedule_cmd( week_day_index, user_index, @@ -268,7 +268,7 @@ async def test_TC_DRLK_2_5(self): self.step("5") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): week_day_index = 0 # invalid value - days_Mask = 2 # valid value + day_mask_map_index = 2 # valid value await self.set_week_days_schedule_cmd( week_day_index, user_index, @@ -281,7 +281,7 @@ async def test_TC_DRLK_2_5(self): self.step("6") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): week_day_index = 1 # valid value - days_Mask = 0 # invalid value + day_mask_map_index = 0 # invalid value await self.set_week_days_schedule_cmd( week_day_index, user_index, @@ -295,7 +295,7 @@ async def test_TC_DRLK_2_5(self): self.step("7") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): week_day_index = 1 # valid value - days_Mask = 1 # valid value + day_mask_map_index = 1 # valid value start_Hour = 18 # inavlid value > end hour await self.set_week_days_schedule_cmd( week_day_index, @@ -310,6 +310,7 @@ async def test_TC_DRLK_2_5(self): self.step("8") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): week_day_index = 0 + user_index = 1 await self.get_weekday_schedule_cmd( week_day_index, user_index, @@ -321,6 +322,7 @@ async def test_TC_DRLK_2_5(self): Status.InvalidCommand) self.step("9") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + week_day_index = 1 user_index = 2 # invalid value as it does not exist await self.get_weekday_schedule_cmd( week_day_index, From 89eb94602bd76c3034ee0526d7d80b001644aa9f Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 27 Aug 2024 21:14:32 +0530 Subject: [PATCH 11/24] Updated TC_DRLK_2_4.yaml script as per test plan --- .../certification/Test_TC_DRLK_2_4.yaml | 192 ++++++++---------- 1 file changed, 85 insertions(+), 107 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml index bece149e34ed32..a52538964c97f3 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml @@ -33,9 +33,50 @@ tests: - name: "nodeId" value: nodeId - - label: "Create new user" + - label: + "Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on + the DUT" + PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 10 + + - label: + "Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on + the DUT" + PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 60 + + - label: + "Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on + the DUT" + PICS: PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 10 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on + the DUT" + PICS: PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 60 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 2a: TH sends SetUser Command to DUT with the following values:" command: "SetUser" - PICS: DRLK.S.F08 && DRLK.S.F00 + PICS: DRLK.S.F08 && DRLK.S.C1a.Rsp timedInteractionTimeoutMs: 1000 arguments: values: @@ -54,39 +95,33 @@ tests: - name: "CredentialRule" value: 0 - - label: "Read the user back and verify its fields" - command: "GetUser" - PICS: DRLK.S.F08 && DRLK.S.F00 - arguments: - values: - - name: "UserIndex" - value: 1 + - label: "Step 2b: TH reads MinPINCodeLength attribute from DUT" + PICS: DRLK.S.F00 && DRLK.S.A0018 + command: "readAttribute" + attribute: "MinPINCodeLength" response: - values: - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - name: "Credentials" - value: [] - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextUserIndex" - value: null - - - label: "Create new PIN credential and lock/unlock user" + saveAs: MinPINCodeLengthValue + constraints: + type: int8u + minValue: 0 + maxValue: 255 + + - label: "Step 2c: TH reads MaxPINCodeLength attribute from DUT" + PICS: DRLK.S.F00 && DRLK.S.A0017 + command: "readAttribute" + attribute: "MaxPINCodeLength" + response: + saveAs: MaxPINCodeLengthValue + constraints: + type: int8u + minValue: 0 + maxValue: 255 + - label: + "Step 2d: TH sends SetCredential Command to DUT with the following + fields and CredentialData Length is in an inclusive range of + MaxPINCodeLengthValue to MaxPINCodeLengthValue" command: "SetCredential" - PICS: DRLK.S.F08 && DRLK.S.F00 + PICS: DRLK.S.F00 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx timedInteractionTimeoutMs: 1000 arguments: values: @@ -111,68 +146,8 @@ tests: - name: "NextCredentialIndex" value: 2 - - label: "Verify created PIN credential" - PICS: DRLK.S.F08 && DRLK.S.F00 - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - response: - values: - - name: "CredentialExists" - value: true - - name: "UserIndex" - value: 1 - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextCredentialIndex" - value: null - - - label: - "Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on - the DUT" - PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 10 - - - label: - "Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on - the DUT" - PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 60 - - - label: - "Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on - the DUT" - PICS: PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 10 - response: - error: UNSUPPORTED_WRITE - - label: - "Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on - the DUT" - PICS: PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 60 - response: - error: UNSUPPORTED_WRITE - - - label: - "Step 2a: TH sends the Unlock with Timeout argument value as 10 + "Step 2e: TH sends the Unlock with Timeout argument value as 10 seconds" PICS: DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY command: "UnlockWithTimeout" @@ -185,7 +160,7 @@ tests: value: "123456" - label: - "Step 2b: TH sends the Unlock with Timeout argument value as 60 + "Step 2f: TH sends the Unlock with Timeout argument value as 60 seconds" PICS: " DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP " @@ -199,7 +174,7 @@ tests: value: "123456" - label: - "Step 2b: TH sends the Unlock with Timeout argument value as 60 + "Step 2g: TH sends the Unlock with Timeout argument value as 60 seconds" PICS: " (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && @@ -230,27 +205,30 @@ tests: - name: "ms" value: 70000 - - label: "Step 2c: TH reads LockState attribute" + - label: "Step 2h: TH reads LockState attribute" PICS: DRLK.S.A0000 && DRLK.S.C03.Rsp command: "readAttribute" attribute: "LockState" response: value: 1 - - label: "Cleanup the created user" - command: "ClearUser" - PICS: DRLK.S.F08 && DRLK.S.F00 + - label: + "Step 3a: TH sends ClearCredential Command to DUT with the following + fields:" + PICS: DRLK.S.F00 && DRLK.S.C26.Rsp + command: "ClearCredential" timedInteractionTimeoutMs: 1000 arguments: values: - - name: "UserIndex" - value: 1 + - name: "Credential" + value: { CredentialType: 1, CredentialIndex: 1 } - - label: "Clean the created credential" - PICS: DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp - command: "ClearCredential" + - label: + "Step 3b: TH sends ClearUser Command to DUT with the UserIndex as 1" + command: "ClearUser" + PICS: DRLK.S.F08 && DRLK.S.C1d.Rsp timedInteractionTimeoutMs: 1000 arguments: values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } + - name: "UserIndex" + value: 1 From d2b4c32bb0ed1038e7c194b38128e910f4502280 Mon Sep 17 00:00:00 2001 From: sumaky Date: Wed, 28 Aug 2024 20:20:25 +0530 Subject: [PATCH 12/24] Updated the TC to include PIN, Aliro combination and do Modify credential --- src/python_testing/TC_DRLK_2_9.py | 148 +++++++++++++++++++++++++++--- 1 file changed, 134 insertions(+), 14 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 2b4941d1d50cf8..70767a3bf2bffa 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -114,9 +114,25 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: "Verify that the DUT responds with GetUserResponse Command."), TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", "Verify that the DUT sends SUCCESS response."), - TestStep("23", "TH sends ClearUser Command to DUT.", + TestStep("23a", "TH sends ClearAliroReaderConfig Command to DUT.", "Verify that the DUT sends SUCCESS response."), - ] + TestStep("23b", ",TH sends SetAliroReaderConfig Command to DUT without GroupResolvingKey.", + "Verify that DUT sends success response."), + TestStep("24", "TH sends SetCredential Command CredentialType as AliroEvictableEndpointKey.", + "Verify that the DUT responds with SetCredentialResponse commad with status success "), + TestStep("25", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("26", "TH sends SetCredential Command to modify PIN CredentialType", + "Verify that the DUT responds with SetCredentialResponse command with status success "), + TestStep("27", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("28", "TH sends ClearCredential Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("29", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("30", "TH sends ClearAliroReaderConfig Command to DUT.", + "Verify that the DUT sends SUCCESS response."),] + return steps async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): @@ -160,6 +176,9 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetUser(userIndex=userindex), endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000) + + logging.info("Credentials value is %s" % (str(response.credentials))) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), "Unexpected return type for GetUserResponse") asserts.assert_true(response.userIndex == userindex, @@ -179,8 +198,7 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, - step, userIndex, credential_exists): + async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, credential_exists): try: credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, @@ -235,7 +253,7 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential logging.exception(e) asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") - async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): + async def clear_credentials_cmd(self, credential, expected_status: Status = Status.Success): try: await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), @@ -245,6 +263,54 @@ async def clear_credentials_cmd(self, credential, step=None, expected_status: St logging.exception(e) asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + async def send_clear_aliro_reader_config_cmd(self, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearAliroReaderConfig(), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def send_set_aliro_reader_config_cmd(self, use_group_resolving_key: bool, + expected_status: Status = Status.Success): + try: + + signingKey = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4adb2f5d9bc9ea6c49e9566d144367df3ff") + verificationKey = bytes.fromhex( + "047a4c992d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + groupIdentifier = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4ad") + groupResolvingKey = bytes.fromhex("89d0859bfcdecdf3c4adfc302ca53e27") + + grp_resolve = False + + # Checks Pics condition + if self.check_pics("DRLK.S.F0e") is False: + grp_resolve = self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C28.Rsp")) + else: + grp_resolve = self.pics_guard(self.check_pics("DRLK.S.C28.Rsp")) + + if not grp_resolve: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( + signingKey=signingKey, + verificationKey=verificationKey, + groupIdentifier=self.groupIdentifier), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + elif grp_resolve: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( + signingKey=signingKey, + verificationKey=verificationKey, + groupIdentifier=groupIdentifier, + groupResolvingKey=groupResolvingKey), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + logging.exception(f"Got exception when performing SetAliroReaderConfig {e}") + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + @async_test_body async def test_TC_DRLK_2_9(self): @@ -269,6 +335,11 @@ async def test_TC_DRLK_2_9(self): self.inavlid_pincode = b"" self.rfid_tag = b"" + # Aliro Keys for setting Aliro configuration and credential + + aliroevictableendpointkey = bytes.fromhex( + "047a4c772d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + self.step("1") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, @@ -323,7 +394,7 @@ async def test_TC_DRLK_2_9(self): if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=True) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=True) self.step("4") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): @@ -365,12 +436,12 @@ async def test_TC_DRLK_2_9(self): if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) + await self.clear_credentials_cmd(credential=credentials) self.step("9a") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False) self.step("9b") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): await self.send_clear_user_cmd(user_index=1) @@ -402,12 +473,12 @@ async def test_TC_DRLK_2_9(self): if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) + await self.clear_credentials_cmd(credential=credentials) self.step("13") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, step=None, userIndex=1, credential_exists=False) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False) self.step("14a") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, @@ -417,7 +488,7 @@ async def test_TC_DRLK_2_9(self): if (aliro_enabled): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) - await self.clear_credentials_cmd(step=None, credential=credentials) + await self.clear_credentials_cmd(credential=credentials) else: try: await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), @@ -497,7 +568,7 @@ async def test_TC_DRLK_2_9(self): if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) - await self.clear_credentials_cmd(step=None, credential=credentials) + await self.clear_credentials_cmd(credential=credentials) self.step("16") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): @@ -553,12 +624,61 @@ async def test_TC_DRLK_2_9(self): await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) self.step("22") + if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C26.Rsp")): + + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid) + await self.clear_credentials_cmd(credential=credentials) + + self.step("23a") + if self.check_pics("DRLK.S.C29.Rsp"): + await self.send_clear_aliro_reader_config_cmd() + + self.step("23b") + await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=False, expected_status=Status.Success) + + self.step("24") + await self.set_credential_cmd(credentialData=aliroevictableendpointkey, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("25") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey)] + await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + self.step("26") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("27") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey)] + await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + + self.step("28") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): - await self.clear_credentials_cmd(step=None, credential=NullValue) + await self.clear_credentials_cmd(credential=NullValue) - self.step("23") + self.step("29") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): await self.send_clear_user_cmd(userIndex_1) + self.step("30") + if self.pics_guard(self.check_pics("DRLK.S.C29.Rsp")): + await self.send_clear_aliro_reader_config_cmd() if __name__ == '__main__': From 835df50730673f31faa8c080770964acc9b8d161 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 28 Aug 2024 14:51:48 +0000 Subject: [PATCH 13/24] Restyled by autopep8 --- src/python_testing/TC_DRLK_2_9.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 70767a3bf2bffa..a835ddf8adc79d 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -131,7 +131,7 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: TestStep("29", "TH sends ClearUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), TestStep("30", "TH sends ClearAliroReaderConfig Command to DUT.", - "Verify that the DUT sends SUCCESS response."),] + "Verify that the DUT sends SUCCESS response."), ] return steps From 1a27981d574fed50cb515ac786242d13476446e3 Mon Sep 17 00:00:00 2001 From: sumaky Date: Wed, 28 Aug 2024 21:07:39 +0530 Subject: [PATCH 14/24] updated PICS --- src/python_testing/TC_DRLK_2_9.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index a835ddf8adc79d..d905e2d98a6818 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -272,8 +272,7 @@ async def send_clear_aliro_reader_config_cmd(self, expected_status: Status = Sta except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - async def send_set_aliro_reader_config_cmd(self, use_group_resolving_key: bool, - expected_status: Status = Status.Success): + async def send_set_aliro_reader_config_cmd(self, expected_status: Status = Status.Success): try: signingKey = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4adb2f5d9bc9ea6c49e9566d144367df3ff") @@ -635,15 +634,17 @@ async def test_TC_DRLK_2_9(self): await self.send_clear_aliro_reader_config_cmd() self.step("23b") - await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=False, expected_status=Status.Success) + await self.send_set_aliro_reader_config_cmd(expected_status=Status.Success) self.step("24") - await self.set_credential_cmd(credentialData=aliroevictableendpointkey, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, - credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=aliroevictableendpointkey, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) self.step("25") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): credentiallist: list[drlkcluster.Structs.CredentialStruct] credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, @@ -652,15 +653,14 @@ async def test_TC_DRLK_2_9(self): credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey)] await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) self.step("26") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") - and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=self.pin_code2, operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) self.step("27") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): credentiallist: list[drlkcluster.Structs.CredentialStruct] credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, @@ -670,7 +670,7 @@ async def test_TC_DRLK_2_9(self): await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) self.step("28") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): await self.clear_credentials_cmd(credential=NullValue) self.step("29") From 124f306963464f2d554d6a58039532ad31ddf41f Mon Sep 17 00:00:00 2001 From: sumaky Date: Thu, 29 Aug 2024 14:44:51 +0530 Subject: [PATCH 15/24] Appended steps to check modify of both PIN and Aliro credentiaType is as expected --- src/python_testing/TC_DRLK_2_9.py | 139 +++++++++++++++++++++--------- 1 file changed, 98 insertions(+), 41 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index d905e2d98a6818..f93c42cdb18afe 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -114,23 +114,35 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: "Verify that the DUT responds with GetUserResponse Command."), TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", "Verify that the DUT sends SUCCESS response."), - TestStep("23a", "TH sends ClearAliroReaderConfig Command to DUT.", + TestStep("23", "TH sends ClearUser Command to DUT to clear all the users.", "Verify that the DUT sends SUCCESS response."), - TestStep("23b", ",TH sends SetAliroReaderConfig Command to DUT without GroupResolvingKey.", + TestStep("24", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("25", "TH sends ClearAliroReaderConfig Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("26", ",TH sends SetAliroReaderConfig Command to DUT without GroupResolvingKey.", "Verify that DUT sends success response."), - TestStep("24", "TH sends SetCredential Command CredentialType as AliroEvictableEndpointKey.", + TestStep("27", ",TH sends SetAliroReaderConfig Command to DUT with GroupResolvingKey.", + "Verify that DUT sends success response."), + TestStep("28", "TH sends SetCredential Command CredentialType as AliroEvictableEndpointKey.", "Verify that the DUT responds with SetCredentialResponse commad with status success "), - TestStep("25", "TH sends GetUser Command to DUT.", + TestStep("29", "TH sends SetCredential Command to DUT with CredentialType.PIN.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("30", "TH sends GetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("26", "TH sends SetCredential Command to modify PIN CredentialType", + TestStep("31", "TH sends SetCredential Command to modify PIN CredentialType", "Verify that the DUT responds with SetCredentialResponse command with status success "), - TestStep("27", "TH sends GetUser Command to DUT.", + TestStep("32", "TH sends GetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("28", "TH sends ClearCredential Command to DUT.", + TestStep("33", "TH sends SetCredential Command to modify AliroEvictableEndpointKey CredentialType", + "Verify that the DUT responds with SetCredentialResponse command with status success "), + TestStep("34", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("35", "TH sends ClearCredential Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("29", "TH sends ClearUser Command to DUT.", + TestStep("36", "TH sends ClearUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("30", "TH sends ClearAliroReaderConfig Command to DUT.", + TestStep("37", "TH sends ClearAliroReaderConfig Command to DUT.", "Verify that the DUT sends SUCCESS response."), ] return steps @@ -242,7 +254,7 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential timedRequestTimeoutMs=1000) asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), "Unexpected return type for SetCredential") - + asserts.assert_equal(response.userIndex, NullValue) if (statuscode != custom_stautus_code): asserts.assert_true(response.status == statuscode, "Error sending SetCredential command, status={}".format(str(response.status))) @@ -272,7 +284,8 @@ async def send_clear_aliro_reader_config_cmd(self, expected_status: Status = Sta except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - async def send_set_aliro_reader_config_cmd(self, expected_status: Status = Status.Success): + async def send_set_aliro_reader_config_cmd(self, use_group_resolving_key: bool, + expected_status: Status = Status.Success): try: signingKey = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4adb2f5d9bc9ea6c49e9566d144367df3ff") @@ -281,23 +294,22 @@ async def send_set_aliro_reader_config_cmd(self, expected_status: Status = Statu groupIdentifier = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4ad") groupResolvingKey = bytes.fromhex("89d0859bfcdecdf3c4adfc302ca53e27") - grp_resolve = False - # Checks Pics condition - if self.check_pics("DRLK.S.F0e") is False: - grp_resolve = self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C28.Rsp")) + if use_group_resolving_key is False: + pics_check = self.pics_guard(self.check_pics("DRLK.S.F0d") and not self.check_pics("DRLK.S.F0e") and + self.check_pics("DRLK.S.C28.Rsp")) else: - grp_resolve = self.pics_guard(self.check_pics("DRLK.S.C28.Rsp")) + pics_check = self.pics_guard(self.check_pics("DRLK.S.F0e") and self.check_pics("DRLK.S.C28.Rsp")) - if not grp_resolve: + if not use_group_resolving_key and pics_check: await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( signingKey=signingKey, verificationKey=verificationKey, - groupIdentifier=self.groupIdentifier), + groupIdentifier=groupIdentifier), endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000) asserts.assert_equal(expected_status, Status.Success) - elif grp_resolve: + elif use_group_resolving_key and pics_check: await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( signingKey=signingKey, verificationKey=verificationKey, @@ -334,11 +346,14 @@ async def test_TC_DRLK_2_9(self): self.inavlid_pincode = b"" self.rfid_tag = b"" - # Aliro Keys for setting Aliro configuration and credential + # Aliro Keys for setting Aliro configuration and credential - aliroevictableendpointkey = bytes.fromhex( + aliroevictableendpointkey1 = bytes.fromhex( "047a4c772d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + aliroevictableendpointkey2 = bytes.fromhex( + "047a4c662d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + self.step("1") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, @@ -623,60 +638,102 @@ async def test_TC_DRLK_2_9(self): await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) self.step("22") - if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C26.Rsp")): + if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): + await self.clear_credentials_cmd(credential=NullValue) - credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid) - await self.clear_credentials_cmd(credential=credentials) + self.step("23") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) - self.step("23a") + self.step("24") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id1, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("25") if self.check_pics("DRLK.S.C29.Rsp"): await self.send_clear_aliro_reader_config_cmd() - self.step("23b") - await self.send_set_aliro_reader_config_cmd(expected_status=Status.Success) + self.step("26") + await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=False, expected_status=Status.Success) + self.step("27") + await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=True, expected_status=Status.Success) - self.step("24") - if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.F08") + self.step("28") + if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): - await self.set_credential_cmd(credentialData=aliroevictableendpointkey, + await self.set_credential_cmd(credentialData=aliroevictableendpointkey1, operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - self.step("25") + + self.step("29") + if self.pics_guard(self.check_pics("DRLK.S.F00") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("30") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): credentiallist: list[drlkcluster.Structs.CredentialStruct] credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin), + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey)] + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) - self.step("26") + self.step("31") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=self.pin_code2, operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - self.step("27") + self.step("32") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): credentiallist: list[drlkcluster.Structs.CredentialStruct] credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin), + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey)] + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + self.step("33") + if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=aliroevictableendpointkey2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("34") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): - self.step("28") + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + + self.step("35") if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): await self.clear_credentials_cmd(credential=NullValue) - self.step("29") + self.step("36") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): await self.send_clear_user_cmd(userIndex_1) - self.step("30") + self.step("37") if self.pics_guard(self.check_pics("DRLK.S.C29.Rsp")): await self.send_clear_aliro_reader_config_cmd() From 9d88e838f0082088602e8073f96a95d66f7a5091 Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 15:50:51 +0530 Subject: [PATCH 16/24] Updated DRLK-2.5 test case as per PR comment 1.correted test step description for step 4,5,6 and 9 2.Corrected steps 5,6 and 9 --- src/python_testing/TC_DRLK_2_5.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py index 09e2c6595d747e..a43067b05bf4af 100644 --- a/src/python_testing/TC_DRLK_2_5.py +++ b/src/python_testing/TC_DRLK_2_5.py @@ -53,17 +53,17 @@ def steps_TC_DRLK_2_5(self) -> list[TestStep]: TestStep("3", "TH sends GetWeekDaySchedule Command to DUT.", "Verify that the DUT sends GetWeekDayScheduleResponse command with expected values."), TestStep("4", "TH sends SetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + "Verify that the DUT responds with INVALID_COMMAND."), TestStep("5", "TH sends SetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + "Verify that the DUT responds with INVALID_COMMAND."), TestStep("6", "TH sends SetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + "Verify that the DUT responds with INVALID_COMMAND."), TestStep("7", "TH sends SetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + "Verify that the DUT responds with INVALID_COMMAND."), TestStep("8", "TH sends GetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + "Verify that the DUT responds with with INVALID_COMMAND."), TestStep("9", "TH sends GetWeekDaySchedule Command to DUT.", - "Verify that the DUT responds with SetCredentialResponse command with Status NOT_FOUND."), + "Verify that the DUT responds with GetWeekDayScheduleResponse command with Status NOT_FOUND."), TestStep("10a", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends SUCCESS response."), TestStep("10b", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), TestStep("10c", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), @@ -192,6 +192,8 @@ async def test_TC_DRLK_2_5(self): cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.NumberOfWeekDaySchedulesSupportedPerUser) logging.info("NumberOfWeekDaySchedulesSupportedPerUser %s" % (number_week_day_schedules_supported_per_user)) + asserts.assert_in(number_week_day_schedules_supported_per_user, range( + 0, 255), "NumberOfWeekDaySchedulesSupportedPerUser value is out of range") self.step("2a") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): try: @@ -267,8 +269,8 @@ async def test_TC_DRLK_2_5(self): Status.InvalidCommand) self.step("5") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): - week_day_index = 0 # invalid value - day_mask_map_index = 2 # valid value + week_day_index = 1 # Valid value + day_mask_map_index = 0 # invalid value await self.set_week_days_schedule_cmd( week_day_index, user_index, @@ -281,7 +283,7 @@ async def test_TC_DRLK_2_5(self): self.step("6") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): week_day_index = 1 # valid value - day_mask_map_index = 0 # invalid value + day_mask_map_index = 128 # invalid value await self.set_week_days_schedule_cmd( week_day_index, user_index, @@ -332,7 +334,7 @@ async def test_TC_DRLK_2_5(self): start_Minute, end_Hour, end_Minute, - Status.InvalidCommand) + Status.NotFound) self.step("10a") if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): week_day_index = 1 From 534f77bd938d7d9e676266d008d1346323a6b459 Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 15:58:22 +0530 Subject: [PATCH 17/24] Updated DRLK-2.9 1. Corrected test step description 2. Corrected PICS 3. Validated arrtibutes read based on respective range 4. modified get_user function to check for given credentialsirespective to the order of credentials listed --- src/python_testing/TC_DRLK_2_9.py | 156 +++++++++++++++++++----------- 1 file changed, 99 insertions(+), 57 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index f93c42cdb18afe..f3e227ae8b4bd2 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -47,15 +47,15 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: TestStep("1", "TH reads NumberOfTotalUsersSupported attribute.", "Verify that TH is able to read the attribute successfully."), - TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that TH is able to read the attribute successfully."), - TestStep("2b", " TH reads MinPINCodeLength attribute .", - "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response"), + TestStep("2b", "TH reads MinPINCodeLength attribute .", + "Verify that TH is able to read the attribute successfully and value is within range."), TestStep("2c", "TH reads MaxPINCodeLength attribute.", - "Verify that TH is able to read the attribute successfully."), + "Verify that TH is able to read the attribute successfully and value is within range."), TestStep("2d", "TH reads MinRFIDCodeLength attribute.", "Verify that TH is able to read the attribute successfully."), TestStep("2e", "TH reads MaxRFIDCodeLength attribute.", - "Verify that TH is able to read the attribute successfully."), + "Verify that TH is able to read the attribute successfully and value is within range."), TestStep("2f", "TH sends SetCredential Command to DUT.", "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), TestStep("3", "TH sends GetCredentialStatus Command .", @@ -90,8 +90,10 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: "Verify that the DUT sends an INVALID_COMMAND."), TestStep("14c", "TH sends ClearUser Command to DUT to clear all the users.", "Verify that the DUT sends SUCCESS response."), + TestStep("14d", "TH reads NumberOfPINUsersSupported attribute.", + "Verify that TH is able to read the attribute successfully and value is within range."), TestStep("15a", "TH reads NumberOfCredentialsSupportedPerUser attribute from DUT.", - "Verify that TH is able to read the attribute successfully."), + "Verify that TH is able to read the attribute successfully and value is within range."), TestStep("15b", "TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), TestStep("15c", "TH sends SetCredential Command to DUT.", @@ -100,6 +102,8 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: "Verify that the DUT sends SetCredentialResponse command with Status RESOURCE_EXHAUSTION."), TestStep("15e", "TH sends ClearCredential Command to DUT to clear all the credentials of PIN type.", "Verify that the DUT sends SUCCESS response."), + TestStep("15f", "TH sends ClearUser Command to DUT with UserIndex as 0xFFFE to clear all the users.", + "Verify that the DUT sends SUCCESS response."), TestStep("16", " TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response"), TestStep("17", "TH sends SetCredential Command to DUT with CredentialType.RFID.", @@ -138,9 +142,9 @@ def steps_TC_DRLK_2_9(self) -> list[TestStep]: "Verify that the DUT responds with SetCredentialResponse command with status success "), TestStep("34", "TH sends GetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("35", "TH sends ClearCredential Command to DUT.", + TestStep("35", "TH sends ClearUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), - TestStep("36", "TH sends ClearUser Command to DUT.", + TestStep("36", "TH sends ClearCredential Command to DUT to clear all the credentials.", "Verify that the DUT sends SUCCESS response."), TestStep("37", "TH sends ClearAliroReaderConfig Command to DUT.", "Verify that the DUT sends SUCCESS response."), ] @@ -189,8 +193,6 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000) - logging.info("Credentials value is %s" % (str(response.credentials))) - asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), "Unexpected return type for GetUserResponse") asserts.assert_true(response.userIndex == userindex, @@ -202,10 +204,18 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe asserts.assert_true(response.userUniqueID == useruniqueid, "Error when executing GetUserResponse command, userUniqueID={}".format( str(response.userUniqueID))) - asserts.assert_true(response.credentials == credentiallist, - "Error when executing GetUserResponse command, credentials={}".format( - str(response.credentials))) - asserts.assert_equal(expected_status, Status.Success) + logging.info("Credentials value is GetUserResponse Command %s" % (str(response.credentials))) + # traverse through input credentials and match each value with the resonse credential + for input_credential_index in range(len(credentiallist)): + match_found = False + for response_credential_index in range(len(response.credentials)): + if (response.credentials[response_credential_index] == credentiallist[input_credential_index]): + match_found = True + break + if (not match_found): + asserts.assert_true(match_found == True, + "Error mismatch in expected credential from GetUserResponse command = {}".format( + str(credentiallist))) except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") @@ -261,9 +271,11 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential else: asserts.assert_true(response.status == 2 or response.status == 3, "Error sending SetCredential command, status={}".format(str(response.status))) + return response.nextCredentialIndex except InteractionModelError as e: logging.exception(e) asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") + return -1 async def clear_credentials_cmd(self, credential, expected_status: Status = Status.Success): try: @@ -329,8 +341,7 @@ async def test_TC_DRLK_2_9(self): numberofcredentialsupportedperuser = None self.app_cluster_endpoint = 1 invalid_credential_type = 9 - user_unique_id1 = 6459 - user_unique_id2 = 1111 + user_unique_id = 6459 user_name = "xxx" credentialIndex_1 = 1 credentialIndex_2 = 2 @@ -346,6 +357,9 @@ async def test_TC_DRLK_2_9(self): self.inavlid_pincode = b"" self.rfid_tag = b"" + self.endpoint = self.user_params.get("endpoint", 1) + print("endpoint", self.endpoint) + # Aliro Keys for setting Aliro configuration and credential aliroevictableendpointkey1 = bytes.fromhex( @@ -359,14 +373,16 @@ async def test_TC_DRLK_2_9(self): self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.NumberOfTotalUsersSupported) + asserts.assert_in(self.numberoftotaluserssupported, range( + 0, 65534), "NumberOfTotalUsersSupported value is out of range") self.step("2a") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): try: await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, - userIndex=1, + userIndex=userIndex_1, userName=user_name, - userUniqueID=user_unique_id1, + userUniqueID=user_unique_id, userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), @@ -380,21 +396,29 @@ async def test_TC_DRLK_2_9(self): self.minpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.MinPINCodeLength) + asserts.assert_in(self.minpincodelength, range( + 0, 255), "MinPINCodeLength value is out of range") self.step("2c") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): self.maxpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.MaxPINCodeLength) + asserts.assert_in(self.maxpincodelength, range( + 0, 255), "MaxPINCodeLength value is out of range") self.step("2d") if self.pics_guard(self.check_pics("DRLK.S.F01")): self.minrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.MinRFIDCodeLength) + asserts.assert_in(self.minrfidcodelength, range( + 0, 255), "MinRFIDCodeLength value is out of range") self.step("2e") if self.pics_guard(self.check_pics("DRLK.S.F01")): self.maxrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.MaxRFIDCodeLength) + asserts.assert_in(self.maxrfidcodelength, range( + 0, 255), "MaxRFIDCodeLength value is out of range") self.step("2f") await self.generate_code() if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") @@ -416,7 +440,7 @@ async def test_TC_DRLK_2_9(self): await self.set_credential_cmd(credentialData=self.inavlid_pincode, operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=credentialIndex_2, userIndex=userIndex_1, userStatus=invalid_user_status, userType=invalid_user_type, statuscode=Status.InvalidCommand) + credentialIndex=credentialIndex_2, userIndex=NullValue, userStatus=invalid_user_status, userType=invalid_user_type, statuscode=Status.InvalidCommand) self.step("5") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): @@ -467,7 +491,7 @@ async def test_TC_DRLK_2_9(self): operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, userIndex=userIndex_2, userName=user_name, - userUniqueID=user_unique_id2, + userUniqueID=user_unique_id, userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), @@ -529,14 +553,23 @@ async def test_TC_DRLK_2_9(self): self.step("14c") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): - await self.send_clear_user_cmd(userIndex_1) - + await self.send_clear_user_cmd(user_index=int(0xFFFE)) + + self.step("14d") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.A0012")): + num_pin_users_supported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfPINUsersSupported) + asserts.assert_in(num_pin_users_supported, range( + 0, 65534), "NumberOfPINUsersSupported value is out of range") self.step("15a") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A001c")): numberofcredentialsupportedperuser = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser) + asserts.assert_in(numberofcredentialsupportedperuser, range( + 0, 255), "NumberOfCredentialsSupportedPerUser value is out of range") self.step("15b") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): try: @@ -544,7 +577,7 @@ async def test_TC_DRLK_2_9(self): operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, userIndex=userIndex_1, userName=user_name, - userUniqueID=user_unique_id1, + userUniqueID=user_unique_id, userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), @@ -556,33 +589,43 @@ async def test_TC_DRLK_2_9(self): self.step("15c") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): - logging.info("setting 'start_credential_index' to value 1 ") - start_credential_index = 1 - while 1: - uniquePincodeString = await self.generate_pincode(self.maxpincodelength) - uniquePincode = bytes(uniquePincodeString, 'ascii') - logging.info("Credential Data value is %s" % (uniquePincode)) - if start_credential_index <= (numberofcredentialsupportedperuser): - await self.set_credential_cmd(credentialData=uniquePincode, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) - start_credential_index += 1 - logging.info(f"The updated value of start_credential_index is {start_credential_index}") - else: - break + if (numberofcredentialsupportedperuser < num_pin_users_supported): + logging.info("setting 'start_credential_index' to value 1 ") + start_credential_index = 1 + nextCredentialIndex = 1 + while 1: + uniquePincodeString = await self.generate_pincode(self.maxpincodelength) + uniquePincode = bytes(uniquePincodeString, 'ascii') + logging.info("Credential Data value is %s" % (uniquePincode)) + if start_credential_index <= (numberofcredentialsupportedperuser): + nextCredentialIndex = await self.set_credential_cmd(credentialData=uniquePincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + logging.info(f"The updated value of nextCredentialIndex is {nextCredentialIndex}") + start_credential_index += 1 + asserts.assert_true(nextCredentialIndex == start_credential_index, + "Error mismatch in expected nextCredentialIndex={}".format(str(nextCredentialIndex))) + logging.info(f"The updated value of start_credential_index is {start_credential_index}") + else: + break self.step("15d") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): - await self.set_credential_cmd(credentialData=self.pin_code, - operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, - credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, - credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) + if (numberofcredentialsupportedperuser < num_pin_users_supported): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) self.step("15e") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) await self.clear_credentials_cmd(credential=credentials) + self.step("15f") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=int(0xFFFE)) self.step("16") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): @@ -591,7 +634,7 @@ async def test_TC_DRLK_2_9(self): operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, userIndex=userIndex_1, userName=user_name, - userUniqueID=user_unique_id1, + userUniqueID=user_unique_id, userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), @@ -608,8 +651,7 @@ async def test_TC_DRLK_2_9(self): credential_enum=drlkcluster.Enums.CredentialTypeEnum.kRfid, credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) self.step("18") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") - and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=self.pin_code, operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, @@ -623,11 +665,10 @@ async def test_TC_DRLK_2_9(self): credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] - await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) self.step("20") - if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") - and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=self.pin_code1, operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, @@ -635,10 +676,10 @@ async def test_TC_DRLK_2_9(self): self.step("21") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): - await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) self.step("22") - if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): await self.clear_credentials_cmd(credential=NullValue) self.step("23") @@ -652,7 +693,7 @@ async def test_TC_DRLK_2_9(self): operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, userIndex=userIndex_1, userName=user_name, - userUniqueID=user_unique_id1, + userUniqueID=user_unique_id, userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), @@ -693,7 +734,7 @@ async def test_TC_DRLK_2_9(self): credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] - await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) self.step("31") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=self.pin_code2, @@ -709,7 +750,7 @@ async def test_TC_DRLK_2_9(self): credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] - await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) self.step("33") if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): await self.set_credential_cmd(credentialData=aliroevictableendpointkey2, @@ -724,15 +765,16 @@ async def test_TC_DRLK_2_9(self): credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] - await self.get_user(userIndex_1, user_name, user_unique_id1, credentiallist, Status.Success) + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) self.step("35") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) + + self.step("36") if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): await self.clear_credentials_cmd(credential=NullValue) - self.step("36") - if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): - await self.send_clear_user_cmd(userIndex_1) self.step("37") if self.pics_guard(self.check_pics("DRLK.S.C29.Rsp")): await self.send_clear_aliro_reader_config_cmd() From e0755e5ddc6ff80378036c3064a865e8a894b68d Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 16:44:12 +0530 Subject: [PATCH 18/24] Added nextcredentialIndex check in get_credential_status function --- src/python_testing/TC_DRLK_2_9.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index f3e227ae8b4bd2..792ac50fba302f 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -220,7 +220,7 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") - async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, credential_exists): + async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, credential_exists, next_credential_index): try: credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, @@ -237,6 +237,9 @@ async def get_credentials_status(self, credentialIndex: int, credentialType: drl asserts.assert_true(response.userIndex == NullValue, "Error when executing GetCredentialStatus command, userIndex={}".format( str(response.userIndex))) + asserts.assert_true(response.nextCredentialIndex == next_credential_index, + "Error when executing GetCredentialStatus command, nextCredentialIndex={}".format( + str(response.nextCredentialIndex))) return response except InteractionModelError as e: logging.error(e) @@ -244,7 +247,7 @@ async def get_credentials_status(self, credentialIndex: int, credentialType: drl async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.CredentialTypeEnum, statuscode, credentialIndex, operationType, userIndex, credentialData, userStatus, userType): - custom_stautus_code = 149 + custom_status_code = 149 credentials = drlkcluster.Structs.CredentialStruct( credentialType=credential_enum, @@ -265,7 +268,7 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), "Unexpected return type for SetCredential") asserts.assert_equal(response.userIndex, NullValue) - if (statuscode != custom_stautus_code): + if (statuscode != custom_status_code): asserts.assert_true(response.status == statuscode, "Error sending SetCredential command, status={}".format(str(response.status))) else: @@ -432,7 +435,7 @@ async def test_TC_DRLK_2_9(self): if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=True) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=True, next_credential_index=NullValue) self.step("4") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): @@ -479,7 +482,7 @@ async def test_TC_DRLK_2_9(self): self.step("9a") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False, next_credential_index=NullValue) self.step("9b") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): await self.send_clear_user_cmd(user_index=1) @@ -516,7 +519,7 @@ async def test_TC_DRLK_2_9(self): self.step("13") if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): await self.get_credentials_status(credentialIndex=credentialIndex_1, - credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False) + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False, next_credential_index=NullValue) self.step("14a") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, From 4eed013bf8e958627ddd4a24fa3bc50da1d5f776 Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 17:21:32 +0530 Subject: [PATCH 19/24] fixed code-lints error --- src/python_testing/TC_DRLK_2_9.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 792ac50fba302f..91457dc653a0b2 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -212,10 +212,8 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe if (response.credentials[response_credential_index] == credentiallist[input_credential_index]): match_found = True break - if (not match_found): - asserts.assert_true(match_found == True, - "Error mismatch in expected credential from GetUserResponse command = {}".format( - str(credentiallist))) + asserts.assert_equal(match_found, True, "Error mismatch in expected credential from GetUserResponse command = {}".format( + str(credentiallist))) except InteractionModelError as e: asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") From 48bb70556155bd190ad19a25a19155ffe473372c Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 19:14:30 +0530 Subject: [PATCH 20/24] Added generate_max_pincode_len for generating valid pin code of Max pincode length --- src/python_testing/TC_DRLK_2_9.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 91457dc653a0b2..5c8f7a9d8a78c5 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -27,6 +27,8 @@ # === END CI TEST ARGUMENTS === import logging +import random +import string import chip.clusters as Clusters from chip.clusters.Types import NullValue @@ -35,6 +37,7 @@ from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches from mobly import asserts + logger = logging.getLogger(__name__) drlkcluster = Clusters.DoorLock @@ -165,17 +168,20 @@ async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_ def pics_TC_DRLK_2_9(self) -> list[str]: return ["DRLK.S"] + async def generate_max_pincode_len(self, maxPincodeLength): + return ''.join(random.choices(string.digits, k=maxPincodeLength)) + async def generate_code(self): - validpincodestr = await self.generate_pincode(self.maxpincodelength) + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) self.pin_code = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxpincodelength) + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) self.pin_code1 = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxpincodelength) + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) self.pin_code2 = bytes(validpincodestr, 'ascii') - inavlidpincodestr = await self.generate_pincode(self.maxpincodelength+1) + inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') - validpincodestr = await self.generate_pincode(self.maxrfidcodelength) + validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) self.rfid_tag = bytes(validpincodestr, 'ascii') async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): @@ -595,7 +601,7 @@ async def test_TC_DRLK_2_9(self): start_credential_index = 1 nextCredentialIndex = 1 while 1: - uniquePincodeString = await self.generate_pincode(self.maxpincodelength) + uniquePincodeString = await self.generate_max_pincode_len(self.maxpincodelength) uniquePincode = bytes(uniquePincodeString, 'ascii') logging.info("Credential Data value is %s" % (uniquePincode)) if start_credential_index <= (numberofcredentialsupportedperuser): From df6c4cb83bbe4558e5367a48c20f27ab82fedca6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 17 Sep 2024 13:46:09 +0000 Subject: [PATCH 21/24] Restyled by isort --- src/python_testing/TC_DRLK_2_9.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 5c8f7a9d8a78c5..d71cbf0b232835 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -37,7 +37,6 @@ from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches from mobly import asserts - logger = logging.getLogger(__name__) drlkcluster = Clusters.DoorLock From 7779420634d7e2fc22fd076be77b07bd431ee90c Mon Sep 17 00:00:00 2001 From: sumaky Date: Tue, 17 Sep 2024 20:34:26 +0530 Subject: [PATCH 22/24] added a check in get_user funtion that length of given Credential list matches with length of response credential list --- src/python_testing/TC_DRLK_2_9.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index d71cbf0b232835..231486506f7067 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -210,7 +210,10 @@ async def get_user(self, userindex, username, useruniqueid, credentiallist, expe "Error when executing GetUserResponse command, userUniqueID={}".format( str(response.userUniqueID))) logging.info("Credentials value is GetUserResponse Command %s" % (str(response.credentials))) - # traverse through input credentials and match each value with the resonse credential + + asserts.assert_equal(len(credentiallist), len(response.credentials), "Error mismatch in expected credential from GetUserResponse command = {}".format( + str(credentiallist))) + # traverse through input credentials and match each value with the resonse credential for input_credential_index in range(len(credentiallist)): match_found = False for response_credential_index in range(len(response.credentials)): From 9ee695b7320f438a59e1ab0e5ec0e49f4d98dfb6 Mon Sep 17 00:00:00 2001 From: sumaky Date: Wed, 18 Sep 2024 18:48:56 +0530 Subject: [PATCH 23/24] PR review -Init the pin and rid variables --- src/python_testing/TC_DRLK_2_9.py | 54 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 231486506f7067..3f843f1d32ccdb 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -171,17 +171,18 @@ async def generate_max_pincode_len(self, maxPincodeLength): return ''.join(random.choices(string.digits, k=maxPincodeLength)) async def generate_code(self): - - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code1 = bytes(validpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) - self.pin_code2 = bytes(validpincodestr, 'ascii') - inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) - self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') - validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) - self.rfid_tag = bytes(validpincodestr, 'ascii') + if (self.maxpincodelength != None): + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code1 = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code2 = bytes(validpincodestr, 'ascii') + inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) + self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') + if (self.maxrfidcodelength != None): + validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) + self.rfid_tag = bytes(validpincodestr, 'ascii') async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): try: @@ -259,8 +260,7 @@ async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.Credential credentialType=credential_enum, credentialIndex=credentialIndex) try: - logging.info("maxpincodelength value is %s" % (self.maxpincodelength)) - logging.info("maxrfidcodelength value is %s" % (self.maxrfidcodelength)) + logging.info("Credential Data is %s" % (credentialData)) response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( operationType=operationType, @@ -366,6 +366,11 @@ async def test_TC_DRLK_2_9(self): self.inavlid_pincode = b"" self.rfid_tag = b"" + self.minpincodelength = None + self.maxpincodelength = None + self.maxrfidcodelength = None + self.minrfidcodelength = None + self.endpoint = self.user_params.get("endpoint", 1) print("endpoint", self.endpoint) @@ -532,20 +537,21 @@ async def test_TC_DRLK_2_9(self): cluster=drlkcluster, attribute=Clusters.DoorLock.Attributes.FeatureMap) aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning - if (aliro_enabled): credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) - await self.clear_credentials_cmd(credential=credentials) - else: - try: - await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), - endpoint=self.app_cluster_endpoint, - timedRequestTimeoutMs=1000) - asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + if (aliro_enabled): - except InteractionModelError as e: - asserts.assert_equal(e.status, Status.InvalidCommand, - "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + await self.clear_credentials_cmd(credential=credentials) + else: + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") self.step("14b") if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): From 98c6049b99f29a6bc4bd5414db8a650c97e980cc Mon Sep 17 00:00:00 2001 From: sumaky Date: Wed, 18 Sep 2024 19:12:41 +0530 Subject: [PATCH 24/24] fixed lint error --- src/python_testing/TC_DRLK_2_9.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py index 3f843f1d32ccdb..954ca7dd7b2f3d 100644 --- a/src/python_testing/TC_DRLK_2_9.py +++ b/src/python_testing/TC_DRLK_2_9.py @@ -171,7 +171,7 @@ async def generate_max_pincode_len(self, maxPincodeLength): return ''.join(random.choices(string.digits, k=maxPincodeLength)) async def generate_code(self): - if (self.maxpincodelength != None): + if (self.maxpincodelength is not None): validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) self.pin_code = bytes(validpincodestr, 'ascii') validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) @@ -180,7 +180,7 @@ async def generate_code(self): self.pin_code2 = bytes(validpincodestr, 'ascii') inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') - if (self.maxrfidcodelength != None): + if (self.maxrfidcodelength is not None): validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) self.rfid_tag = bytes(validpincodestr, 'ascii')