From 0fe4757d111d1e2e5127d55b6e64967c43ff4f85 Mon Sep 17 00:00:00 2001 From: ManjunathRA Date: Fri, 25 Mar 2022 19:45:30 +0530 Subject: [PATCH] Test added Mar 10 (#16073) * Added Secure channel test TC-SC-4.2 * Added auto generated files --- examples/chip-tool/templates/tests/tests.js | 5 + .../suites/certification/Test_TC_SC_4_2.yaml | 500 ++++++++++++++++++ .../chip-tool/zap-generated/test/Commands.h | 471 +++++++++++++++++ 3 files changed, 976 insertions(+) create mode 100644 src/app/tests/suites/certification/Test_TC_SC_4_2.yaml diff --git a/examples/chip-tool/templates/tests/tests.js b/examples/chip-tool/templates/tests/tests.js index 2ec09673855475..12d68973fef460 100644 --- a/examples/chip-tool/templates/tests/tests.js +++ b/examples/chip-tool/templates/tests/tests.js @@ -449,6 +449,10 @@ function getTests() 'Test_TC_RH_2_2', ]; + const SecureChannel = [ + 'Test_TC_SC_4_2', + ]; + const Switch = [ 'Test_TC_SWTCH_2_1', 'Test_TC_SWTCH_2_2', @@ -578,6 +582,7 @@ function getTests() PressureMeasurement, // PumpConfigurationControl, // RelativeHumidityMeasurement, // + SecureChannel, // Switch, // TemperatureMeasurement, // Thermostat, // diff --git a/src/app/tests/suites/certification/Test_TC_SC_4_2.yaml b/src/app/tests/suites/certification/Test_TC_SC_4_2.yaml new file mode 100644 index 00000000000000..693c7f0ec920ef --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_SC_4_2.yaml @@ -0,0 +1,500 @@ +# Copyright (c) 2021 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. + +name: + 13.4.2. [TC-SC-4.2] Commissionable Node Discovery - Commissioner Case [DUT - + Commissioner] + +config: + nodeId: 0x12344321 + cluster: "Secure Channel" + endpoint: 0 + discriminator: + type: INT16U + defaultValue: 3840 + vendorId: + type: INT16U + defaultValue: 65521 + productId: + type: INT16U + defaultValue: 32769 + deviceType: + type: INT16U + defaultValue: 5 + +tests: + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: + "TH is put in Commissioning Mode using Open Basic Commissioning Window + command and starts advertising Commissionable Node Discovery service + using DNS-SD" + cluster: "AdministratorCommissioning" + command: "OpenBasicCommissioningWindow" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "CommissioningTimeout" + value: 120 + + - label: "Check Instance Name" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "instanceName" + saveAs: deviceInstanceNameBeforeReboot1 + constraints: + minLength: 16 + maxLength: 16 + isUpperCase: true + isHexString: true + + #validate the service type and the service domain not implemented in CI + + - label: "Check Hostname" + # On macOS the hostname is the device name and because of it this test is disabled for now. + disabled: true + PICS: "(WIFI || ETH) && !THREAD" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "hostName" + constraints: + minLength: 12 + maxLength: 12 + isUpperCase: true + isHexString: true + + - label: "Check Hostname" + # On macOS the hostname is the device name and because of it this test is disabled for now. + disabled: true + PICS: "(!WIFI && !ETH) && THREAD" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "hostName" + constraints: + minLength: 16 + maxLength: 16 + isUpperCase: true + isHexString: true + + #subtype + - label: "Check Long Discriminator _L" + cluster: "DiscoveryCommands" + command: "FindCommissionableByLongDiscriminator" + arguments: + values: + - name: "value" + value: discriminator + + - label: "Check Short Discriminator (_S)" + cluster: "DiscoveryCommands" + command: "FindCommissionableByShortDiscriminator" + arguments: + values: + - name: "value" + value: discriminator + + - label: "Check Vendor ID (_V)" + PICS: VENDOR_SUBTYPE + cluster: "DiscoveryCommands" + command: "FindCommissionableByVendorId" + arguments: + values: + - name: "value" + value: vendorId + + - label: "Check Device Type ID (_T)" + disabled: true + PICS: DEVTYPE_SUBTYPE + cluster: "DiscoveryCommands" + command: "FindCommissionableByDeviceType" + arguments: + values: + - name: "value" + value: deviceType + + - label: "Check Commissioning Mode (_CM)" + cluster: "DiscoveryCommands" + command: "FindCommissionableByCommissioningMode" + + - label: "TXT key for Vendor ID and Product ID (VP)" + PICS: VP_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "vendorId" + value: vendorId + + - label: "TXT key for Vendor ID and Product ID (VP)" + PICS: VP_KEY + optional: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "productId" + value: productId + + - label: "Optional TXT key for MRP Retry Interval Idle (CRI)" + PICS: CRI_COMM_DISCOVERY_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "mrpRetryIntervalIdle" + constraints: + maxValue: 3600000 + + - label: "Optional TXT key for MRP Retry Interval Active (CRA)" + PICS: CRA_COMM_DISCOVERY_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "mrpRetryIntervalActive" + constraints: + maxValue: 3600000 + + - label: "TXT key for commissioning mode (CM)" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "commissioningMode" + value: 1 + + - label: "Optional TXT key for device type (DT)" + disabled: true + PICS: DT_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "deviceType" + value: deviceType + constraints: + maxValue: 999 + + - label: "Optional TXT key for device name (DN)" + PICS: DN_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "deviceName" + constraints: + maxLength: 32 + + - label: "Optional TXT key for rotating device identifier (RI)" + PICS: RI_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "rotatingIdLen" + constraints: + maxValue: 100 + + - label: "Optional TXT key for pairing hint (PH)" + PICS: PH_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "pairingHint" + notValue: 0 + + - label: "Optional TXT key for pairing instructions (PI)" + PICS: PI_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "pairingInstruction" + constraints: + maxLength: 128 + + - label: "Check IPs" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "numIPs" + constraints: + minValue: 1 + + # The testplan needs TH needs to be Rebooted so below steps disabled for now + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Open Commissioning Window" + disabled: true + cluster: "AdministratorCommissioning" + command: "OpenBasicCommissioningWindow" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "CommissioningTimeout" + value: 120 + + - label: "Check Instance Name" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "instanceName" + constraints: + minLength: 16 + maxLength: 16 + isUpperCase: true + isHexString: true + notValue: deviceInstanceNameBeforeReboot1 + + #validate the service type and the service domain not implemented in CI + + - label: "Check Hostname" + # On macOS the hostname is the device name and because of it this test is disabled for now. + disabled: true + PICS: "(WIFI || ETH) && !THREAD" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "hostName" + constraints: + minLength: 12 + maxLength: 12 + isUpperCase: true + isHexString: true + + - label: "Check Hostname" + # On macOS the hostname is the device name and because of it this test is disabled for now. + disabled: true + PICS: "(!WIFI && !ETH) && THREAD" + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "hostName" + constraints: + minLength: 16 + maxLength: 16 + isUpperCase: true + isHexString: true + + - label: "Check Long Discriminator _L" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionableByLongDiscriminator" + arguments: + values: + - name: "value" + value: discriminator + + - label: "Check Short Discriminator (_S)" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionableByShortDiscriminator" + arguments: + values: + - name: "value" + value: discriminator + + - label: "Check Vendor ID (_V)" + disabled: true + PICS: VENDOR_SUBTYPE + cluster: "DiscoveryCommands" + command: "FindCommissionableByVendorId" + arguments: + values: + - name: "value" + value: vendorId + + - label: "Check Device Type ID (_T)" + # The device type is not broadcasted by the accessory under CI. + disabled: true + PICS: DEVTYPE_SUBTYPE + cluster: "DiscoveryCommands" + command: "FindCommissionableByDeviceType" + arguments: + values: + - name: "value" + value: deviceType + + - label: "Check Commissioning Mode (_CM)" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionableByCommissioningMode" + + - label: "TXT key for Vendor ID and Product ID (VP)" + PICS: VP_KEY + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "vendorId" + value: vendorId + + - label: "TXT key for Vendor ID and Product ID (VP)" + PICS: VP_KEY + disabled: true + optional: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "productId" + value: productId + + - label: "Optional TXT key for MRP Retry Interval Idle (CRI)" + disabled: true + PICS: CRI_COMM_DISCOVERY_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "mrpRetryIntervalIdle" + constraints: + maxValue: 3600000 + + - label: "Optional TXT key for MRP Retry Interval Active (CRA)" + disabled: true + PICS: CRA_COMM_DISCOVERY_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "mrpRetryIntervalActive" + constraints: + maxValue: 3600000 + + - label: "TXT key for commissioning mode (CM)" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "commissioningMode" + value: 1 + + - label: "Optional TXT key for device type (DT)" + disabled: true + PICS: DT_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "deviceType" + value: deviceType + constraints: + maxValue: 49151 + + - label: "Optional TXT key for device name (DN)" + disabled: true + PICS: DN_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "deviceName" + constraints: + maxLength: 32 + + - label: "Optional TXT key for rotating device identifier (RI)" + disabled: true + PICS: RI_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "rotatingIdLen" + constraints: + maxValue: 100 + + - label: "Optional TXT key for pairing hint (PH)" + disabled: true + PICS: PH_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "pairingHint" + notValue: 0 + + - label: "Optional TXT key for pairing instructions (PI)" + disabled: true + PICS: PI_KEY + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "pairingInstruction" + constraints: + maxLength: 128 + + - label: "Check IPs" + disabled: true + cluster: "DiscoveryCommands" + command: "FindCommissionable" + response: + values: + - name: "numIPs" + constraints: + minValue: 1 + + #Negative scenarios not implemented in CI + - label: "Log commands" + cluster: "LogCommands" + command: "Log" + arguments: + values: + - name: "message" + value: + "TH adds an unknown key/value pair in the advertised data" + + #Negative scenarios not implemented in CI + - label: "Log commands" + cluster: "LogCommands" + command: "Log" + arguments: + values: + - name: "message" + value: "Scan for DNS-SD commissioner advertisements from TH" diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index a26056976c19c7..63a5a0958d43bb 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -136,6 +136,7 @@ class TestList : public Command printf("Test_TC_RH_1_1\n"); printf("Test_TC_RH_2_1\n"); printf("Test_TC_RH_2_2\n"); + printf("Test_TC_SC_4_2\n"); printf("Test_TC_SWTCH_2_1\n"); printf("Test_TC_SWTCH_2_2\n"); printf("Test_TC_TM_1_1\n"); @@ -40873,6 +40874,475 @@ class Test_TC_RH_2_2Suite : public TestCommand } }; +class Test_TC_SC_4_2Suite : public TestCommand +{ +public: + Test_TC_SC_4_2Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_SC_4_2", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("vendorId", 0, UINT16_MAX, &mVendorId); + AddArgument("productId", 0, UINT16_MAX, &mProductId); + AddArgument("deviceType", 0, UINT16_MAX, &mDeviceType); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_SC_4_2Suite() + { + if (deviceInstanceNameBeforeReboot1Buffer != nullptr) + { + chip::Platform::MemoryFree(deviceInstanceNameBeforeReboot1Buffer); + deviceInstanceNameBeforeReboot1Buffer = nullptr; + } + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_SC_4_2\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SC_4_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); + err = TestRebootTargetDevice_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_1(); + break; + case 2: + ChipLogProgress(chipTool, + " ***** Test Step 2 : TH is put in Commissioning Mode using Open Basic Commissioning Window command " + "and starts advertising Commissionable Node Discovery service using DNS-SD\n"); + err = + TestThIsPutInCommissioningModeUsingOpenBasicCommissioningWindowCommandAndStartsAdvertisingCommissionableNodeDiscoveryServiceUsingDnsSd_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Check Instance Name\n"); + err = TestCheckInstanceName_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Check Long Discriminator _L\n"); + err = TestCheckLongDiscriminatorL_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Check Short Discriminator (_S)\n"); + err = TestCheckShortDiscriminatorS_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Check Vendor ID (_V)\n"); + if (ShouldSkip("VENDOR_SUBTYPE")) + { + NextTest(); + return; + } + err = TestCheckVendorIdV_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Check Commissioning Mode (_CM)\n"); + err = TestCheckCommissioningModeCm_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : TXT key for Vendor ID and Product ID (VP)\n"); + if (ShouldSkip("VP_KEY")) + { + NextTest(); + return; + } + err = TestTxtKeyForVendorIdAndProductIdVp_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : TXT key for Vendor ID and Product ID (VP)\n"); + if (ShouldSkip("VP_KEY")) + { + NextTest(); + return; + } + err = TestTxtKeyForVendorIdAndProductIdVp_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Optional TXT key for MRP Retry Interval Idle (CRI)\n"); + if (ShouldSkip("CRI_COMM_DISCOVERY_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForMrpRetryIntervalIdleCri_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Optional TXT key for MRP Retry Interval Active (CRA)\n"); + if (ShouldSkip("CRA_COMM_DISCOVERY_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForMrpRetryIntervalActiveCra_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : TXT key for commissioning mode (CM)\n"); + err = TestTxtKeyForCommissioningModeCm_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Optional TXT key for device name (DN)\n"); + if (ShouldSkip("DN_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForDeviceNameDn_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Optional TXT key for rotating device identifier (RI)\n"); + if (ShouldSkip("RI_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForRotatingDeviceIdentifierRi_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Optional TXT key for pairing hint (PH)\n"); + if (ShouldSkip("PH_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForPairingHintPh_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Optional TXT key for pairing instructions (PI)\n"); + if (ShouldSkip("PI_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForPairingInstructionsPi_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Check IPs\n"); + err = TestCheckIPs_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Reboot target device\n"); + err = TestRebootTargetDevice_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Log commands\n"); + err = TestLogCommands_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Log commands\n"); + err = TestLogCommands_20(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mVendorId; + chip::Optional mProductId; + chip::Optional mDeviceType; + chip::Optional mTimeout; + + char * deviceInstanceNameBeforeReboot1Buffer = nullptr; + chip::CharSpan deviceInstanceNameBeforeReboot1; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override + { + bool isExpectedDnssdResult = false; + if ((mTestIndex - 1) == 3) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintIsUpperCase("value.instanceName", value.instanceName, true)); + VerifyOrReturn(CheckConstraintIsHexString("value.instanceName", value.instanceName, true)); + VerifyOrReturn(CheckConstraintMinLength("value.instanceName", value.instanceName.size(), 16)); + VerifyOrReturn(CheckConstraintMaxLength("value.instanceName", value.instanceName.size(), 16)); + if (deviceInstanceNameBeforeReboot1Buffer != nullptr) + { + chip::Platform::MemoryFree(deviceInstanceNameBeforeReboot1Buffer); + } + deviceInstanceNameBeforeReboot1Buffer = static_cast(chip::Platform::MemoryAlloc(value.instanceName.size())); + memcpy(deviceInstanceNameBeforeReboot1Buffer, value.instanceName.data(), value.instanceName.size()); + deviceInstanceNameBeforeReboot1 = chip::CharSpan(deviceInstanceNameBeforeReboot1Buffer, value.instanceName.size()); + } + if ((mTestIndex - 1) == 4) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 5) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 6) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 7) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 8) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("vendorId", value.vendorId, mVendorId.HasValue() ? mVendorId.Value() : 65521U)); + } + if ((mTestIndex - 1) == 9) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("productId", value.productId, mProductId.HasValue() ? mProductId.Value() : 32769U)); + } + if ((mTestIndex - 1) == 10) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalIdle", value.mrpRetryIntervalIdle)); + VerifyOrReturn( + CheckConstraintMaxValue("value.mrpRetryIntervalIdle.Value()", value.mrpRetryIntervalIdle.Value(), 3600000UL)); + } + if ((mTestIndex - 1) == 11) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalActive", value.mrpRetryIntervalActive)); + VerifyOrReturn( + CheckConstraintMaxValue("value.mrpRetryIntervalActive.Value()", value.mrpRetryIntervalActive.Value(), 3600000UL)); + } + if ((mTestIndex - 1) == 12) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("commissioningMode", value.commissioningMode, 1)); + } + if ((mTestIndex - 1) == 13) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxLength("value.deviceName", value.deviceName.size(), 32)); + } + if ((mTestIndex - 1) == 14) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxValue("value.rotatingIdLen", value.rotatingIdLen, 100ULL)); + } + if ((mTestIndex - 1) == 15) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 16) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxLength("value.pairingInstruction", value.pairingInstruction.size(), 128)); + } + if ((mTestIndex - 1) == 17) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMinValue("value.numIPs", value.numIPs, 1)); + } + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + // + // Tests methods + // + + CHIP_ERROR TestRebootTargetDevice_0() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_1() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR + TestThIsPutInCommissioningModeUsingOpenBasicCommissioningWindowCommandAndStartsAdvertisingCommissionableNodeDiscoveryServiceUsingDnsSd_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type; + + RequestType request; + request.commissioningTimeout = 120U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_2(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_2(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_2(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_2() { NextTest(); } + + CHIP_ERROR TestCheckInstanceName_3() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestCheckLongDiscriminatorL_4() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByLongDiscriminator(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestCheckShortDiscriminatorS_5() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByShortDiscriminator(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestCheckVendorIdV_6() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByVendorId(mVendorId.HasValue() ? mVendorId.Value() : 65521U); + } + + CHIP_ERROR TestCheckCommissioningModeCm_7() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByCommissioningMode(); + } + + CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_8() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_9() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalIdleCri_10() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalActiveCra_11() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestTxtKeyForCommissioningModeCm_12() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForDeviceNameDn_13() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForRotatingDeviceIdentifierRi_14() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForPairingHintPh_15() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForPairingInstructionsPi_16() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestCheckIPs_17() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestRebootTargetDevice_18() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestLogCommands_19() + { + SetIdentity(kIdentityAlpha); + return Log("TH adds an unknown key/value pair in the advertised data"); + } + + CHIP_ERROR TestLogCommands_20() + { + SetIdentity(kIdentityAlpha); + return Log("Scan for DNS-SD commissioner advertisements from TH"); + } +}; + class Test_TC_SWTCH_2_1Suite : public TestCommand { public: @@ -116315,6 +116785,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig),