Skip to content

Commit

Permalink
Python Script DRLK 2.13 is updated as per latest test-plan
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshith-GRL committed Sep 18, 2024
1 parent 2396bb4 commit 075dde0
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions src/python_testing/TC_DRLK_2_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TC_DRLK_2_13(MatterBaseTest):

def steps_TC_DRLK_2_13(self) -> list[TestStep]:
steps = [
TestStep("0", "Commissoning with DUT is done", is_commissioning=True),
TestStep("1a", "TH reads OperationalCredentials cluster's CurrentFabricIndex and save the attribute",
"TH Reads Attribute Successfully"),
TestStep("1b", "TH sends ClearUser Command to DUT with the UserIndex as 0xFFFE to clear all the users",
Expand Down Expand Up @@ -148,7 +149,7 @@ def steps_TC_DRLK_2_13(self) -> list[TestStep]:
"Verify that the DUT responds with SetCredentialResponse command and Status success."),
TestStep("32", "TH sends GetCredentialStatus Command with Credential as 7 startcredentialindex+1",
"DUT responds with GetCredentialStatusResponse Command and CredentialExists is false"),
TestStep("33", "TH sends GetCredentialStatus Command with Credential as 8 startcredentialindex+1",
TestStep("33", "TH sends GetCredentialStatus Command with Credential as 8 startcredentialindex+2",
"Verify DUT responds with GetCredentialStatusResponse having CredentialExists is true and UserIndex as 1"),
TestStep("34", "TH sends ClearCredential Command to DUT to clear the ALIRO CredentialType",
"Verify that the DUT sends SUCCESS response"),
Expand Down Expand Up @@ -268,7 +269,8 @@ async def get_credentials_status(self, credentialIndex: int, credentialType: clu
asserts.assert_equal(e.status, Status.Success, f"Unexpected error returned: {e}")

async def set_credential_cmd(self, credential_enum: Clusters.DoorLock.Enums.CredentialTypeEnum, credentialIndex,
operationType, userIndex, credentialData, userStatus, userType, step=None):
operationType, userIndex, credentialData, userStatus, userType, step=None,
expected_status: list[Status] = [Status.Success]):
if step:
self.step(step)
credentials = cluster.Structs.CredentialStruct(
Expand All @@ -287,7 +289,7 @@ async def set_credential_cmd(self, credential_enum: Clusters.DoorLock.Enums.Cred
timedRequestTimeoutMs=1000)
asserts.assert_true(type_matches(response, Clusters.Objects.DoorLock.Commands.SetCredentialResponse),
"Unexpected return type for SetCredential")
asserts.assert_true(response.status == Status.Success,
asserts.assert_true(response.status in expected_status,
"Error sending SetCredential command, status={}".format(str(response.status)))
except InteractionModelError as e:
logging.exception(e)
Expand Down Expand Up @@ -370,6 +372,7 @@ async def test_TC_DRLK_2_13(self):
self.alirononevictableendpointkey1 = bytes.fromhex(
"047a4c552d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4")
# step 1 TH reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute
self.step("0")
self.step("1a")
self.fabric_idx1 = await self.read_attributes_from_dut(endpoint=self.common_cluster_endpoint,
cluster=Clusters.Objects.OperationalCredentials,
Expand Down Expand Up @@ -569,6 +572,8 @@ async def test_TC_DRLK_2_13(self):
endpoint=self.app_cluster_endpoint,
cluster=Clusters.Objects.DoorLock,
attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser)
logging.info(f"After reading attribute NumberOfCredentialsSupportedPerUser we get"
f" value {self.numberofcredentialsupportedperuser} ")
self.step("28b")
await self.clear_all_aliro_credential()
await self.send_clear_user_cmd(user_index=1)
Expand Down Expand Up @@ -600,7 +605,7 @@ async def test_TC_DRLK_2_13(self):
start_credential_index = 1
credentials_data = self.alirononevictableendpointkey
while 1:
if start_credential_index <= (self.max_aliro_keys_supported - 2):
if start_credential_index <= (self.max_aliro_keys_supported - 1):
if start_credential_index != 1:
credentials_data = self.generate_unique_octbytes()

Expand All @@ -613,38 +618,48 @@ async def test_TC_DRLK_2_13(self):
start_credential_index += 1
logging.info(f"The updated value of start_credential_index is {start_credential_index}")
else:
# we are adding these codes to improve readability
start_credential_index -= 1
break

# we are adding these codes to improve readability
start_credential_index_for_evictable_endpoint = start_credential_index + 1
start_credential_index_for_non_evictable_endpoint = start_credential_index + 2
# step 30
logging.info(f"the value of start_credential_index is {start_credential_index} for step 30")
logging.info(
f"the value of start_credential_index for evictable_endpoint is "
f"{start_credential_index_for_evictable_endpoint} of step 30")
self.step("30")
await self.set_credential_cmd(credentialData=self.alirononevictableendpointkey,
operationType=cluster.Enums.DataOperationTypeEnum.kAdd,
credential_enum=cluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey,
credentialIndex=start_credential_index, userIndex=1, userStatus=NullValue,
credentialIndex=start_credential_index_for_evictable_endpoint, userIndex=1, userStatus=NullValue,
userType=NullValue)
logging.info(
f"the value of start_credential_index for non_evictable_endpoint is "
f"{start_credential_index_for_non_evictable_endpoint} of step 31")
# step 31
self.step("31")
await self.set_credential_cmd(credentialData=self.alirononevictableendpointkey1,
operationType=cluster.Enums.DataOperationTypeEnum.kAdd,
credential_enum=cluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey,
credentialIndex=start_credential_index, userIndex=1, userStatus=NullValue,
userType=NullValue)
credentialIndex=start_credential_index_for_non_evictable_endpoint, userIndex=1, userStatus=NullValue,
userType=NullValue,
expected_status=[Status.InvalidCommand, Status.ResourceExhausted])
# step 32
dut_get_cred_response = await self.get_credentials_status(step="32",
credentialIndex=start_credential_index,
credentialType=cluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey,
credential_exists=False, userIndex=NullValue)
asserts.assert_equal(dut_get_cred_response.credentialExists, NullValue,
f"Error when comparing for {dut_get_cred_response} of null")
await self.get_credentials_status(step="32", credentialIndex=start_credential_index_for_evictable_endpoint,
credentialType=cluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey,
credential_exists=True, userIndex=1)

# step 33
await self.get_credentials_status(step="33", credentialIndex=start_credential_index,
await self.get_credentials_status(step="33", credentialIndex=start_credential_index_for_non_evictable_endpoint,
credentialType=cluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey,
credential_exists=True, userIndex=1)
credential_exists=False, userIndex=NullValue)
# step 34
self.step("34")
await self.clear_all_aliro_credential()
if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")):
await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=NullValue),
endpoint=self.app_cluster_endpoint,
timedRequestTimeoutMs=1000)

# step 35
self.step("35")
Expand Down

0 comments on commit 075dde0

Please sign in to comment.