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] 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()