From 30e930c2d6fd02350ddd063faa4d2119747810d2 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:30:51 +0000 Subject: [PATCH] Add support for configuring terms and conditions in device commissioning This commit introduces a new `enhanced_setup_flow` configuration property to the test harness backend, allowing device manufacturers to define the terms and conditions (T&C) that must be acknowledged and set during device commissioning. These values are critical for supporting the Terms and Conditions Certification Test Suite. Key changes include: - Added the `EnhancedSetupFlowConfig` class to `DutConfig`, which allows specifying the T&C version and user response required during commissioning. - Updated `generate_command_arguments` in `utils.py` to append the necessary arguments for T&C validation and the device's commissioning method. - Adjusted model validation to ensure the `enhanced_setup_flow` field is processed correctly within `DutConfig`. These changes ensure the test harness can enforce manufacturer-specific T&C values during the commissioning process, aligning with the broader requirements of T&C validation. --- .../support/python_testing/models/utils.py | 24 ++++++++++++------- .../matter/test_environment_config.py | 7 ++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/test_collections/matter/sdk_tests/support/python_testing/models/utils.py b/test_collections/matter/sdk_tests/support/python_testing/models/utils.py index e410f7b0..8b83a816 100644 --- a/test_collections/matter/sdk_tests/support/python_testing/models/utils.py +++ b/test_collections/matter/sdk_tests/support/python_testing/models/utils.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2023-2024 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. @@ -55,16 +55,24 @@ async def generate_command_arguments( if dut_config.trace_log: arguments.append("--trace-to json:log") - if not omit_commissioning_method: + if dut_config.enhanced_setup_flow: + arguments.append(f"--require-tc-acknowledgements 1") + arguments.append(f"--tc-acknowledgements {dut_config.enhanced_setup_flow.tc_user_response}") + arguments.append(f"--tc-acknowledgements-version {dut_config.enhanced_setup_flow.tc_version}") + + if omit_commissioning_method: + arguments.append(f"--in-test-commissioning-method {pairing_mode}") + + else: arguments.append(f"--commissioning-method {pairing_mode}") - if pairing_mode == DutPairingModeEnum.BLE_WIFI: - arguments.append(f"--wifi-ssid {config.network.wifi.ssid}") - arguments.append(f"--wifi-passphrase {config.network.wifi.password}") + if pairing_mode == DutPairingModeEnum.BLE_WIFI: + arguments.append(f"--wifi-ssid {config.network.wifi.ssid}") + arguments.append(f"--wifi-passphrase {config.network.wifi.password}") - if pairing_mode == DutPairingModeEnum.BLE_THREAD: - dataset_hex = await __thread_dataset_hex(config.network.thread) - arguments.append(f"--thread-dataset-hex {dataset_hex}") + if pairing_mode == DutPairingModeEnum.BLE_THREAD: + dataset_hex = await __thread_dataset_hex(config.network.thread) + arguments.append(f"--thread-dataset-hex {dataset_hex}") # Retrieve arguments from test_parameters if test_parameters: diff --git a/test_collections/matter/test_environment_config.py b/test_collections/matter/test_environment_config.py index 5e34a410..cbe88d84 100644 --- a/test_collections/matter/test_environment_config.py +++ b/test_collections/matter/test_environment_config.py @@ -46,6 +46,11 @@ class NetworkConfig(BaseModel): thread: Union[ThreadAutoConfig, ThreadExternalConfig] +class EnhancedSetupFlowConfig(BaseModel): + tc_version: int + tc_user_response: int + + class DutConfig(BaseModel): discriminator: str setup_code: str @@ -53,6 +58,7 @@ class DutConfig(BaseModel): chip_timeout: Optional[str] chip_use_paa_certs: bool = False trace_log: bool = True + enhanced_setup_flow: Optional[EnhancedSetupFlowConfig] = None class TestEnvironmentConfigMatter(TestEnvironmentConfig): @@ -99,6 +105,7 @@ def validate_model(self, dict_model: dict) -> None: # All DutConfig fields but chip_timeout are mandatory mandatory_fields = valid_properties.copy() mandatory_fields.remove("chip_timeout") + mandatory_fields.remove("enhanced_setup_flow") for field in mandatory_fields: if field not in dut_config: raise TestEnvironmentConfigMatterError(