Skip to content

Define new JF server variables for JF Admins only #39095

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions examples/jf-admin-app/linux/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ chip_enable_additional_data_advertising = true
chip_enable_rotating_device_id = true

chip_enable_read_client = false

chip_device_config_enable_joint_fabric = true
4 changes: 4 additions & 0 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ if (chip_build_tests) {
output_name = "libCHIP_tests"
output_dir = "${root_out_dir}/lib"
}

if (chip_device_config_enable_joint_fabric) {
tests += [ "${chip_root}/src/app/server/tests" ]
}
}

chip_test_group("example_tests") {
Expand Down
19 changes: 17 additions & 2 deletions src/app/server/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/src/access/access.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/app/icd/icd.gni")
import("${chip_root}/src/platform/device.gni")

config("server_config") {
defines = []
Expand All @@ -41,6 +42,18 @@ source_set("terms_and_conditions") {
]
}

source_set("joint_fabric_datastore") {
sources = [
"JointFabricDatastore.cpp",
"JointFabricDatastore.h",
]

public_deps = [
"${chip_root}/src/lib/core",
"${chip_root}/zzz_generated/app-common/clusters/JointFabricDatastore",
]
}

static_library("server") {
output_name = "libCHIPAppServer"

Expand All @@ -57,8 +70,6 @@ static_library("server") {
"Dnssd.h",
"EchoHandler.cpp",
"EchoHandler.h",
"JointFabricDatastore.cpp",
"JointFabricDatastore.h",
"Server.cpp",
"Server.h",
]
Expand Down Expand Up @@ -88,6 +99,10 @@ static_library("server") {
public_deps += [ ":terms_and_conditions" ]
}

if (chip_device_config_enable_joint_fabric) {
public_deps += [ ":joint_fabric_datastore" ]
}

# TODO: Server.cpp uses TestGroupData.h. Unsure why test code would be in such a central place
# This dependency is split since it should probably be removed (or naming should
# be updated if this is not really "testing" even though headers are Test*.h)
Expand Down
9 changes: 8 additions & 1 deletion src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <app/server/AppDelegate.h>
#include <app/server/CommissioningWindowManager.h>
#include <app/server/DefaultAclStorage.h>
#include <app/server/JointFabricDatastore.h>
#include <credentials/CertificateValidityPolicy.h>
#include <credentials/FabricTable.h>
#include <credentials/GroupDataProvider.h>
Expand Down Expand Up @@ -82,6 +81,10 @@
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

#if CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC
#include <app/server/JointFabricDatastore.h> //nogncheck
#endif // CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC

namespace chip {

inline constexpr size_t kMaxBlePendingPackets = 1;
Expand Down Expand Up @@ -419,7 +422,9 @@ class Server

app::reporting::ReportScheduler * GetReportScheduler() { return mReportScheduler; }

#if CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC
app::JointFabricDatastore & GetJointFabricDatastore() { return mJointFabricDatastore; }
#endif // CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC

#if CHIP_CONFIG_ENABLE_ICD_SERVER
app::ICDManager & GetICDManager() { return mICDManager; }
Expand Down Expand Up @@ -700,7 +705,9 @@ class Server
Access::AccessControl mAccessControl;
app::AclStorage * mAclStorage;

#if CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC
app::JointFabricDatastore mJointFabricDatastore;
#endif // CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC

TestEventTriggerDelegate * mTestEventTriggerDelegate;
Crypto::OperationalKeystore * mOperationalKeystore;
Expand Down
32 changes: 32 additions & 0 deletions src/app/server/tests/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2025 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")

chip_test_suite("tests") {
output_name = "jointFabricDatastoreTests"

test_sources = [ "TestJointFabricDatastore.cpp" ]

public_deps = [
"${chip_root}/src/app/server",
"${chip_root}/src/app/server:joint_fabric_datastore",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support:testing",
]
}
45 changes: 45 additions & 0 deletions src/app/server/tests/TestJointFabricDatastore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "app/server/JointFabricDatastore.h"
#include <pw_unit_test/framework.h>

using namespace chip;
using namespace chip::app;

namespace {

class DummyListener : public JointFabricDatastore::Listener
{
public:
void MarkNodeListChanged() override { mNotified = true; }
void Reset() { mNotified = false; }

bool mNotified = false;
};

TEST(JointFabricDatastoreTest, AddPendingNodeNotifiesListener)
{
JointFabricDatastore store;
DummyListener listener;

store.AddListener(listener);

// Add a pending node — should notify the listener via MarkNodeListChange
store.AddPendingNode(123, CharSpan::fromCharString("controller-a"));

EXPECT_TRUE(listener.mNotified);
}

TEST(JointFabricDatastoreTest, RemoveListenerPreventsNotification)
{
JointFabricDatastore store;
DummyListener listener;

store.AddListener(listener);
store.RemoveListener(listener);
listener.Reset();

store.AddPendingNode(456, CharSpan::fromCharString("controller-b"));

EXPECT_FALSE(listener.mNotified);
}

} // namespace
Loading