Skip to content

Commit 7c5ee84

Browse files
committed
MACL followup: addressing review comments in last PR
project-chip#35413 (comment)
1 parent 17b1a38 commit 7c5ee84

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

src/python_testing/TC_ACL_2_11.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ async def test_TC_ACL_2_11(self):
105105
self.step(1)
106106

107107
wildcard_read = (await dev_ctrl.Read(self.dut_node_id, [()]))
108-
has_arl, has_carl = arls_populated(wildcard_read.tlvAttributes)
108+
arl_data = arls_populated(wildcard_read.tlvAttributes)
109109
asserts.assert_true(
110-
has_arl, "ARL attribute must contain at least one restriction to run this test. Please follow manufacturer-specific steps to add access restrictions and re-run this test")
110+
arl_data.have_arl, "ARL attribute must contain at least one restriction to run this test. Please follow manufacturer-specific steps to add access restrictions and re-run this test")
111111
asserts.assert_true(
112-
has_carl, "CommissioningARL attribute must contain at least one restriction to run this test. Please follow manufacturer-specific steps to add access restrictions and re-run this test")
112+
arl_data.have_carl, "CommissioningARL attribute must contain at least one restriction to run this test. Please follow manufacturer-specific steps to add access restrictions and re-run this test")
113113

114114
self.step(2)
115115
await self.read_single_attribute_check_success(

src/python_testing/TestConformanceTest.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -251,33 +251,33 @@ async def test_macl_restrictions(self):
251251
self.endpoints_tlv = {0: root, 1: nim}
252252

253253
# device with no macl
254-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
255-
asserts.assert_false(have_arl, "Unexpected ARL found")
256-
asserts.assert_false(have_carl, "Unexpected CommissioningARL found")
254+
arl_data = arls_populated(self.endpoints_tlv)
255+
asserts.assert_false(arl_data.have_arl, "Unexpected ARL found")
256+
asserts.assert_false(arl_data.have_carl, "Unexpected CommissioningARL found")
257257

258258
# device with unpopulated macl
259259
self.add_macl(root)
260-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
261-
asserts.assert_false(have_arl, "Unexpected ARL found")
262-
asserts.assert_false(have_carl, "Unexpected CommissioningARL found")
260+
arl_data = arls_populated(self.endpoints_tlv)
261+
asserts.assert_false(arl_data.have_arl, "Unexpected ARL found")
262+
asserts.assert_false(arl_data.have_carl, "Unexpected CommissioningARL found")
263263

264264
# device with populated ARL
265265
self.add_macl(root, populate_arl=True)
266-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
267-
asserts.assert_true(have_arl, "Did not find expected ARL")
268-
asserts.assert_false(have_carl, "Unexpected CommissioningARL found")
266+
arl_data = arls_populated(self.endpoints_tlv)
267+
asserts.assert_true(arl_data.have_arl, "Did not find expected ARL")
268+
asserts.assert_false(arl_data.have_carl, "Unexpected CommissioningARL found")
269269

270270
# device with populated commissioning ARL
271271
self.add_macl(root, populate_commissioning_arl=True)
272-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
273-
asserts.assert_false(have_arl, "Unexpected ARL found")
274-
asserts.assert_true(have_carl, "Did not find expected Commissioning ARL")
272+
arl_data = arls_populated(self.endpoints_tlv)
273+
asserts.assert_false(arl_data.have_arl, "Unexpected ARL found")
274+
asserts.assert_true(arl_data.have_carl, "Did not find expected Commissioning ARL")
275275

276276
# device with both
277277
self.add_macl(root, populate_arl=True, populate_commissioning_arl=True)
278-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
279-
asserts.assert_true(have_arl, "Did not find expected ARL")
280-
asserts.assert_true(have_carl, "Did not find expected Commissioning ARL")
278+
arl_data = arls_populated(self.endpoints_tlv)
279+
asserts.assert_true(arl_data.have_arl, "Did not find expected ARL")
280+
asserts.assert_true(arl_data.have_carl, "Did not find expected Commissioning ARL")
281281

282282

283283
if __name__ == "__main__":

src/python_testing/basic_composition_support.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pathlib
2424
import sys
2525
import typing
26+
from dataclasses import dataclass
2627
from pprint import pformat, pprint
2728
from typing import Any, Optional
2829

@@ -33,21 +34,27 @@
3334
from mobly import asserts
3435

3536

36-
def arls_populated(tlv_data: dict[int, Any]) -> tuple[bool, bool]:
37+
@dataclass
38+
class ArlData:
39+
have_arl: bool
40+
have_carl: bool
41+
42+
43+
def arls_populated(tlv_data: dict[int, Any]) -> ArlData:
3744
""" Returns a tuple indicating if the ARL and CommissioningARL are populated.
3845
Requires a wildcard read of the device TLV.
3946
"""
4047
# ACL is always on endpoint 0
4148
if 0 not in tlv_data or Clusters.AccessControl.id not in tlv_data[0]:
42-
return (False, False)
49+
return ArlData(have_arl=False, have_carl=False)
4350
# Both attributes are mandatory for this feature, so if one doesn't exist, neither should the other.
4451
if Clusters.AccessControl.Attributes.Arl.attribute_id not in tlv_data[0][Clusters.AccessControl.id][Clusters.AccessControl.Attributes.AttributeList.attribute_id]:
45-
return (False, False)
52+
return ArlData(have_arl=False, have_carl=False)
4653

4754
have_arl = tlv_data[0][Clusters.AccessControl.id][Clusters.AccessControl.Attributes.Arl.attribute_id]
4855
have_carl = tlv_data[0][Clusters.AccessControl.id][Clusters.AccessControl.Attributes.CommissioningARL.attribute_id]
4956

50-
return (have_arl, have_carl)
57+
return ArlData(have_arl=have_arl, have_carl=have_carl)
5158

5259

5360
def MatterTlvToJson(tlv_data: dict[int, Any]) -> dict[str, Any]:
@@ -187,11 +194,11 @@ async def setup_class_helper(self, allow_pase: bool = True):
187194
logging.info("Start of actual tests")
188195
logging.info("###########################################################")
189196

190-
have_arl, have_carl = arls_populated(self.endpoints_tlv)
197+
arl_data = arls_populated(self.endpoints_tlv)
191198
asserts.assert_false(
192-
have_arl, "ARL cannot be populated for this test - Please follow manufacturer-specific steps to remove the access restrictions and re-run this test")
199+
arl_data.have_arl, "ARL cannot be populated for this test - Please follow manufacturer-specific steps to remove the access restrictions and re-run this test")
193200
asserts.assert_false(
194-
have_carl, "CommissioningARL cannot be populated for this test - Please follow manufacturer-specific steps to remove the access restrictions and re-run this test")
201+
arl_data.have_carl, "CommissioningARL cannot be populated for this test - Please follow manufacturer-specific steps to remove the access restrictions and re-run this test")
195202

196203
def get_test_name(self) -> str:
197204
"""Return the function name of the caller. Used to create logging entries."""

0 commit comments

Comments
 (0)