Skip to content

Commit

Permalink
Fix the optional write step, don't test unknown enum
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Jan 17, 2024
1 parent 6abeeb1 commit 3f6d9b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/python_testing/TC_AccessChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ async def _run_write_access_test_for_cluster_privilege(self, endpoint_id, cluste
self.record_error(test_name=test_name, location=location,
problem=f"Unexpected error writing non-writeable attribute - expected Unsupported Write, got {resp[0].Status}")
self.success = False
elif is_optional_write and resp[0].Status == Status.UnsupportedWrite:
# unsupported optional writeable attribute - this is fine, no error
continue
elif operation_allowed(spec_requires, privilege):
# Write the default attribute. We don't care if this fails, as long as it fails with a DIFFERENT error than the access
# This is OK because access is required to be checked BEFORE any other thing to avoid leaking device information.
Expand All @@ -180,8 +183,7 @@ async def _run_write_access_test_for_cluster_privilege(self, endpoint_id, cluste
problem="Unexpected UnsupportedAccess writing attribute")
self.success = False
else:
ok = (is_optional_write and resp[0].Status == Status.UnsupportedWrite) or resp[0].Status == Status.UnsupportedAccess
if not ok:
if resp[0].Status != Status.UnsupportedAccess:
self.record_error(test_name=test_name, location=location,
problem=f"Unexpected error writing attribute - expected Unsupported Access, got {resp[0].Status}")
self.success = False
Expand All @@ -192,7 +194,8 @@ async def run_access_test(self, test_type: AccessTestType):
await self._setup_acl(privilege=Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum.kAdminister)
wildcard_read = await self.TH2.Read(self.dut_node_id, [()])

privilege_enum = Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum
enum = Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum
privilege_enum = [p for p in enum if p != enum.kUnknownEnumValue]
for privilege in privilege_enum:
logging.info(f"Testing for {privilege}")
await self._setup_acl(privilege=privilege)
Expand Down

0 comments on commit 3f6d9b9

Please sign in to comment.