Skip to content

Commit

Permalink
More work towards CAT tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmelveilleux committed Aug 19, 2022
1 parent a94d069 commit 9c8c2aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/controller/python/OpCredsBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,10 @@ ChipError::StorageType pychip_OpCreds_AllocateController(OpCredsContext * contex

CATValues catValues;

if ((caseAuthTagLen + 1) > kMaxSubjectCATAttributeCount)
if (caseAuthTagLen > kMaxSubjectCATAttributeCount)
{
ChipLogError(Controller, "# of CASE Tags exceeds kMaxSubjectCATAttributeCount");
ChipLogError(Controller, "Too many of CASE Tags (%u) exceeds kMaxSubjectCATAttributeCount",
static_cast<unsigned>(caseAuthTagLen));
return CHIP_ERROR_INVALID_ARGUMENT.AsInteger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def GrantPrivilege(adminCtrl: ChipDeviceController, grantedCtrl: ChipDevic
await adminCtrl.WriteAttribute(targetNodeId, [(0, Clusters.AccessControl.Attributes.Acl(currentAcls))])


async def CreateControllersOnFabric(fabricAdmin: FabricAdmin, adminDevCtrl: ChipDeviceController, controllerNodeIds: typing.List[int], privilege: Clusters.AccessControl.Enums.Privilege, targetNodeId: int) -> typing.List[ChipDeviceController]:
async def CreateControllersOnFabric(fabricAdmin: FabricAdmin, adminDevCtrl: ChipDeviceController, controllerNodeIds: typing.List[int], privilege: Clusters.AccessControl.Enums.Privilege, targetNodeId: int, catTags: typing.List[int] = []) -> typing.List[ChipDeviceController]:
''' Create new ChipDeviceController instances on a given fabric with a specific privilege on a target node.
Args:
Expand All @@ -102,12 +102,13 @@ async def CreateControllersOnFabric(fabricAdmin: FabricAdmin, adminDevCtrl: Chip
controllerNodeIds: List of desired nodeIds for the controllers.
privilege: The specific ACL privilege to grant to the newly minted controllers.
targetNodeId: The Node ID of the target.
catTags: CAT Tags to include in the NOC of controller
'''

controllerList = []

for nodeId in controllerNodeIds:
newController = fabricAdmin.NewController(nodeId=nodeId)
newController = fabricAdmin.NewController(nodeId=nodeId, catTags=catTags)
await GrantPrivilege(adminDevCtrl, newController, privilege, targetNodeId)
controllerList.append(newController)

Expand Down
7 changes: 7 additions & 0 deletions src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class MatterTestConfig:
dut_node_id: int = _DEFAULT_DUT_NODE_ID
# Node ID to use for controller/commissioner
controller_node_id: int = _DEFAULT_CONTROLLER_NODE_ID
# CAT Tags for default controller/commissioner
controller_cat_tags: List[int] = None

# Fabric ID which to use
fabric_id: int = None
# "Alpha" by default
Expand Down Expand Up @@ -682,6 +685,10 @@ def default_matter_test_main(argv=None, **kwargs):
"""
matter_test_config = parse_matter_test_args(argv)

# Allow override of command line from optional arguments
if matter_test_config.controller_cat_tags is None and "controller_cat_tags" in kwargs:
matter_test_config.controller_cat_tags = kwargs["controller_cat_tags"]

# Find the test class in the test script.
test_class = _find_test_class()

Expand Down

0 comments on commit 9c8c2aa

Please sign in to comment.