Skip to content

Commit

Permalink
[MatterYamlTests][darwin-framework-tool] Get GetCommissionerNodeId me…
Browse files Browse the repository at this point in the history
…thod to work and update TestAccessControlConstraints.yaml to use it
  • Loading branch information
vivien-apple committed Sep 21, 2023
1 parent 82a3e3d commit 1752381
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ CHIP_ERROR LogAttributeAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNum
CHIP_ERROR LogCommandAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * commandId, id result);
CHIP_ERROR LogAttributeErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * attributeId, NSError * error);
CHIP_ERROR LogCommandErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NSNumber * commandId, NSError * error);
CHIP_ERROR LogGetCommissionerNodeId(NSNumber * nodeId);
void SetDelegate(RemoteDataModelLoggerDelegate * delegate);
}; // namespace RemoteDataModelLogger
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
constexpr const char * kErrorIdKey = "error";
constexpr const char * kClusterErrorIdKey = "clusterError";
constexpr const char * kValueKey = "value";
constexpr const char * kNodeIdKey = "nodeId";

constexpr const char kBase64Header[] = "base64:";

Expand Down Expand Up @@ -191,5 +192,17 @@ CHIP_ERROR LogCommandErrorAsJSON(NSNumber * endpointId, NSNumber * clusterId, NS
return LogError(value, status);
}

CHIP_ERROR LogGetCommissionerNodeId(NSNumber * value)
{
VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR);

Json::Value rootValue;
rootValue[kValueKey] = Json::Value();
rootValue[kValueKey][kNodeIdKey] = [value unsignedLongLongValue];

auto valueStr = JsonToString(rootValue);
return gDelegate->LogJSON(valueStr.c_str());
}

void SetDelegate(RemoteDataModelLoggerDelegate * delegate) { gDelegate = delegate; }
}; // namespace RemoteDataModelLogger
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
#import <Matter/Matter.h>

#include "GetCommissionerNodeIdCommand.h"
#include "RemoteDataModelLogger.h"

CHIP_ERROR GetCommissionerNodeIdCommand::RunCommand()
{
auto * controller = CurrentCommissioner();
VerifyOrReturnError(nil != controller, CHIP_ERROR_INCORRECT_STATE);

ChipLogProgress(
chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(controller.controllerNodeId.unsignedLongLongValue));
auto controllerNodeId = controller.controllerNodeId;
ChipLogProgress(chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(controllerNodeId.unsignedLongLongValue));

ReturnErrorOnFailure(RemoteDataModelLogger::LogGetCommissionerNodeId(controllerNodeId));
SetCommandExitStatus(CHIP_NO_ERROR);
return CHIP_NO_ERROR;
}
81 changes: 48 additions & 33 deletions src/app/tests/suites/TestAccessControlConstraints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,36 @@ tests:
- name: "nodeId"
value: nodeId

- label: "Read the fabric index from the alpha fabric"
cluster: "Operational Credentials"
command: "readAttribute"
attribute: "CurrentFabricIndex"
response:
saveAs: alphaIndex

- label: "Read the commissioner node ID from the alpha fabric"
cluster: "CommissionerCommands"
command: "GetCommissionerNodeId"
response:
values:
- name: "nodeId"
saveAs: commissionerNodeIdAlpha

- label: "Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)"
cluster: "Access Control"
command: "writeAttribute"
attribute: "ACL"
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3,
AuthMode: 1, # PASE
Subjects: [],
Expand All @@ -61,14 +76,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 3, # Group
Subjects: [],
Expand All @@ -89,14 +104,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 6,
AuthMode: 2,
Subjects: null,
Expand All @@ -113,14 +128,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3,
AuthMode: 4, # INVALID
Subjects: [],
Expand All @@ -137,14 +152,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3,
AuthMode: 2,
Subjects: [0],
Expand All @@ -161,14 +176,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3,
AuthMode: 2,
Subjects: null,
Expand All @@ -189,14 +204,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3,
AuthMode: 2,
Subjects: null,
Expand All @@ -215,14 +230,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 6, # INVALID
AuthMode: 2, # CASE
Subjects: null,
Expand All @@ -241,14 +256,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3, # Operate
AuthMode: 2, # CASE
Subjects: ["18446744073709551615"],
Expand All @@ -269,14 +284,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3, # Operate
AuthMode: 2, # CASE
Subjects: ["18446744060824649728"],
Expand All @@ -295,14 +310,14 @@ tests:
arguments:
value: [
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 5, # Administer
AuthMode: 2, # CASE
Subjects: [112233],
Subjects: [commissionerNodeIdAlpha],
Targets: null,
},
{
FabricIndex: 1,
FabricIndex: alphaIndex,
Privilege: 3, # Operate
AuthMode: 2, # CASE
Subjects: ["18446744073709486080"],
Expand Down

0 comments on commit 1752381

Please sign in to comment.