Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Script DRLK 2.13 is updated as per latest test-plan #35652

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 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 @@ -145,11 +146,11 @@ def steps_TC_DRLK_2_13(self) -> list[TestStep]:
"Verify that the DUT responds with SetCredentialResponse command and Status success. This step will fill the last slot with credentialType as AliroEvictableEndpointKey"),
TestStep("31",
"TH sends SetCredential Command to DUT with CredentialType as AliroNonEvictableEndpointKey and number of credentials for 'alirouser' exceeds the max_aliro_keys_supported",
"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",
"Verify DUT responds with GetCredentialStatusResponse having CredentialExists is true and UserIndex as 1"),
"Verify that the DUT responds with SetCredentialResponse command and Status ResourceExhausted"),
TestStep("32", "TH sends GetCredentialStatus Command with Credential as 7 1",
"DUT responds with GetCredentialStatusResponse Command and CredentialExists is True"),
TestStep("33", "TH sends GetCredentialStatus Command with Credential as 8 max_aliro_keys_supported",
"Verify DUT responds with GetCredentialStatusResponse having CredentialExists is false and UserIndex as 1"),
TestStep("34", "TH sends ClearCredential Command to DUT to clear the ALIRO CredentialType",
"Verify that the DUT sends SUCCESS response"),
TestStep("35", "TH sends ClearUser Command to DUT with the UserIndex as 1",
Expand Down Expand Up @@ -249,7 +250,7 @@ async def get_credentials_status(self, credentialIndex: int, credentialType: clu
self.step(step)
try:
flags = ["DRLK.S.F0d", "DRLK.S.C24.Rsp", "DRLK.S.C25.Tx"]
if not self.pics_guard(all([self.check_pics(p) for p in flags])):
if self.pics_guard(all([self.check_pics(p) for p in flags])):
credentials_struct = cluster.Structs.CredentialStruct(credentialIndex=credentialIndex,
credentialType=credentialType)
response = await self.send_single_cmd(endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000,
Expand All @@ -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: 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 == 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 @@ -614,37 +619,36 @@ async def test_TC_DRLK_2_13(self):
logging.info(f"The updated value of start_credential_index is {start_credential_index}")
else:
break

# step 30
logging.info(f"the value of start_credential_index is {start_credential_index} for 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=1, userIndex=1, userStatus=NullValue,
Harshith-GRL marked this conversation as resolved.
Show resolved Hide resolved
userType=NullValue)

# 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=self.max_aliro_keys_supported, userIndex=1, userStatus=NullValue,
userType=NullValue,
expected_status=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=1,
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=self.max_aliro_keys_supported,
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
Loading