diff --git a/examples/chip-tool/templates/tests/tests.js b/examples/chip-tool/templates/tests/tests.js index c0688f917737be..721574e02bf112 100644 --- a/examples/chip-tool/templates/tests/tests.js +++ b/examples/chip-tool/templates/tests/tests.js @@ -18,7 +18,6 @@ function getManualTests() { const DeviceDiscovery = [ - 'TestDiscovery', 'Test_TC_DD_1_5', 'Test_TC_DD_1_6', 'Test_TC_DD_1_7', @@ -449,6 +448,7 @@ function getTests() 'TestClusterComplexTypes', 'TestConstraints', 'TestDelayCommands', + 'TestDiscovery', 'TestLogCommands', 'TestSaveAs', 'TestConfigVariables', diff --git a/src/app/tests/suites/TestDiscovery.yaml b/src/app/tests/suites/TestDiscovery.yaml index ad43438f437dce..cac57065f4b5ff 100644 --- a/src/app/tests/suites/TestDiscovery.yaml +++ b/src/app/tests/suites/TestDiscovery.yaml @@ -56,10 +56,6 @@ tests: - name: "CommissioningTimeout" value: 120 - - label: "Wait Commissionable advertisement" - cluster: "DelayCommands" - command: "WaitForCommissionableAdvertisement" - - label: "Check Instance Name" cluster: "DiscoveryCommands" command: "FindCommissionable" @@ -297,10 +293,6 @@ tests: - name: "CommissioningTimeout" value: 120 - - label: "Wait Commissionable advertisement" - cluster: "DelayCommands" - command: "WaitForCommissionableAdvertisement" - - label: "Check Instance Name" cluster: "DiscoveryCommands" command: "FindCommissionable" diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index ec97705dce6427..8496466d845d32 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -163,6 +163,7 @@ class TestList : public Command printf("TestClusterComplexTypes\n"); printf("TestConstraints\n"); printf("TestDelayCommands\n"); + printf("TestDiscovery\n"); printf("TestLogCommands\n"); printf("TestSaveAs\n"); printf("TestConfigVariables\n"); @@ -194,7 +195,6 @@ class ManualTestList : public Command ManualTestList() : Command("list-manual"){}; CHIP_ERROR Run() override { - printf("TestDiscovery\n"); printf("Test_TC_DD_1_5\n"); printf("Test_TC_DD_1_6\n"); printf("Test_TC_DD_1_7\n"); @@ -74973,6 +74973,525 @@ class TestDelayCommandsSuite : public TestCommand } }; +class TestDiscoverySuite : public TestCommand +{ +public: + TestDiscoverySuite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("TestDiscovery", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + 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); + } + + ~TestDiscoverySuite() + { + if (deviceInstanceNameBeforeRebootBuffer != nullptr) + { + chip::Platform::MemoryFree(deviceInstanceNameBeforeRebootBuffer); + deviceInstanceNameBeforeRebootBuffer = nullptr; + } + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: TestDiscovery\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: TestDiscovery\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 : Open Commissioning Window\n"); + err = TestOpenCommissioningWindow_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 Commissioning Mode (_CM)\n"); + err = TestCheckCommissioningModeCm_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Check Vendor ID (_V)\n"); + if (ShouldSkip("VENDOR_SUBTYPE")) + { + NextTest(); + return; + } + err = TestCheckVendorIdV_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : TXT key for discriminator (D)\n"); + err = TestTxtKeyForDiscriminatorD_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 : TXT key for Vendor ID and Product ID (VP)\n"); + if (ShouldSkip("VP_KEY")) + { + NextTest(); + return; + } + err = TestTxtKeyForVendorIdAndProductIdVp_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Optional TXT key for MRP Retry Interval Idle (CRI)\n"); + if (ShouldSkip("CRI_COMM_DISCOVERY_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForMrpRetryIntervalIdleCri_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Optional TXT key for MRP Retry Interval Active (CRA)\n"); + if (ShouldSkip("CRA_COMM_DISCOVERY_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForMrpRetryIntervalActiveCra_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : TXT key for commissioning mode (CM)\n"); + err = TestTxtKeyForCommissioningModeCm_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Optional TXT key for device name (DN)\n"); + if (ShouldSkip("DN_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForDeviceNameDn_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Optional TXT key for rotating device identifier (RI)\n"); + if (ShouldSkip("RI_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForRotatingDeviceIdentifierRi_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Optional TXT key for pairing hint (PH)\n"); + if (ShouldSkip("PH_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForPairingHintPh_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Optional TXT key for pairing instructions (PI)\n"); + if (ShouldSkip("PI_KEY")) + { + NextTest(); + return; + } + err = TestOptionalTxtKeyForPairingInstructionsPi_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Check IPs\n"); + err = TestCheckIPs_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Reboot target device\n"); + err = TestRebootTargetDevice_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Open Commissioning Window\n"); + err = TestOpenCommissioningWindow_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Check Instance Name\n"); + err = TestCheckInstanceName_22(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mVendorId; + chip::Optional mProductId; + chip::Optional mDeviceType; + + char * deviceInstanceNameBeforeRebootBuffer = nullptr; + chip::CharSpan deviceInstanceNameBeforeReboot; + + 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 (deviceInstanceNameBeforeRebootBuffer != nullptr) + { + chip::Platform::MemoryFree(deviceInstanceNameBeforeRebootBuffer); + } + deviceInstanceNameBeforeRebootBuffer = static_cast(chip::Platform::MemoryAlloc(value.instanceName.size())); + memcpy(deviceInstanceNameBeforeRebootBuffer, value.instanceName.data(), value.instanceName.size()); + deviceInstanceNameBeforeReboot = chip::CharSpan(deviceInstanceNameBeforeRebootBuffer, 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("longDiscriminator", value.longDiscriminator, + mDiscriminator.HasValue() ? mDiscriminator.Value() : GetUniqueDiscriminator())); + VerifyOrReturn(CheckConstraintMinValue("value.longDiscriminator", value.longDiscriminator, 0U)); + VerifyOrReturn(CheckConstraintMaxValue("value.longDiscriminator", value.longDiscriminator, 4096U)); + } + if ((mTestIndex - 1) == 9) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("vendorId", value.vendorId, mVendorId.HasValue() ? mVendorId.Value() : 65521U)); + } + if ((mTestIndex - 1) == 10) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("productId", value.productId, mProductId.HasValue() ? mProductId.Value() : 32769U)); + } + if ((mTestIndex - 1) == 11) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalIdle", value.mrpRetryIntervalIdle)); + VerifyOrReturn(CheckConstraintMaxValue("value.mrpRetryIntervalIdle.Value()", + value.mrpRetryIntervalIdle.Value(), 3600000UL)); + } + if ((mTestIndex - 1) == 12) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalActive", value.mrpRetryIntervalActive)); + VerifyOrReturn(CheckConstraintMaxValue("value.mrpRetryIntervalActive.Value()", + value.mrpRetryIntervalActive.Value(), 3600000UL)); + } + if ((mTestIndex - 1) == 13) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckValue("commissioningMode", value.commissioningMode, 1)); + } + if ((mTestIndex - 1) == 14) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxLength("value.deviceName", value.deviceName.size(), 32)); + } + if ((mTestIndex - 1) == 15) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxValue("value.rotatingIdLen", value.rotatingIdLen, 100ULL)); + } + if ((mTestIndex - 1) == 16) + { + isExpectedDnssdResult = true; + } + if ((mTestIndex - 1) == 17) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMaxLength("value.pairingInstruction", value.pairingInstruction.size(), 128)); + } + if ((mTestIndex - 1) == 18) + { + isExpectedDnssdResult = true; + + VerifyOrReturn(CheckConstraintMinValue("value.numIPs", value.numIPs, 1)); + } + if ((mTestIndex - 1) == 22) + { + 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)); + VerifyOrReturn(CheckConstraintNotValue("value.instanceName", value.instanceName, deviceInstanceNameBeforeReboot)); + } + + 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() : GetUniqueDiscriminator()); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_1() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestOpenCommissioningWindow_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() : GetUniqueDiscriminator()); + } + + CHIP_ERROR TestCheckShortDiscriminatorS_5() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByShortDiscriminator(mDiscriminator.HasValue() ? mDiscriminator.Value() + : GetUniqueDiscriminator()); + } + + CHIP_ERROR TestCheckCommissioningModeCm_6() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByCommissioningMode(); + } + + CHIP_ERROR TestCheckVendorIdV_7() + { + SetIdentity(kIdentityAlpha); + return FindCommissionableByVendorId(mVendorId.HasValue() ? mVendorId.Value() : 65521U); + } + + CHIP_ERROR TestTxtKeyForDiscriminatorD_8() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_9() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_10() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalIdleCri_11() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalActiveCra_12() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestTxtKeyForCommissioningModeCm_13() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForDeviceNameDn_14() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForRotatingDeviceIdentifierRi_15() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForPairingHintPh_16() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestOptionalTxtKeyForPairingInstructionsPi_17() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestCheckIPs_18() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } + + CHIP_ERROR TestRebootTargetDevice_19() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : GetUniqueDiscriminator()); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_20() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestOpenCommissioningWindow_21() + { + 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_21(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_21(error); + }; + + ReturnErrorOnFailure( + chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_21(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_21() { NextTest(); } + + CHIP_ERROR TestCheckInstanceName_22() + { + SetIdentity(kIdentityAlpha); + return FindCommissionable(); + } +}; + class TestLogCommandsSuite : public TestCommand { public: @@ -93769,545 +94288,6 @@ class TestGroupKeyManagementClusterSuite : public TestCommand } }; -class TestDiscoverySuite : public TestCommand -{ -public: - TestDiscoverySuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestDiscovery", credsIssuerConfig), mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - 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); - } - - ~TestDiscoverySuite() - { - if (deviceInstanceNameBeforeRebootBuffer != nullptr) - { - chip::Platform::MemoryFree(deviceInstanceNameBeforeRebootBuffer); - deviceInstanceNameBeforeRebootBuffer = nullptr; - } - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: TestDiscovery\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: TestDiscovery\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 : Open Commissioning Window\n"); - err = TestOpenCommissioningWindow_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait Commissionable advertisement\n"); - err = TestWaitCommissionableAdvertisement_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Check Instance Name\n"); - err = TestCheckInstanceName_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check Long Discriminator _L\n"); - err = TestCheckLongDiscriminatorL_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check Short Discriminator (_S)\n"); - err = TestCheckShortDiscriminatorS_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 : Check Vendor ID (_V)\n"); - if (ShouldSkip("VENDOR_SUBTYPE")) - { - NextTest(); - return; - } - err = TestCheckVendorIdV_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TXT key for discriminator (D)\n"); - err = TestTxtKeyForDiscriminatorD_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TXT key for Vendor ID and Product ID (VP)\n"); - if (ShouldSkip("VP_KEY")) - { - NextTest(); - return; - } - err = TestTxtKeyForVendorIdAndProductIdVp_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : TXT key for Vendor ID and Product ID (VP)\n"); - if (ShouldSkip("VP_KEY")) - { - NextTest(); - return; - } - err = TestTxtKeyForVendorIdAndProductIdVp_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Optional TXT key for MRP Retry Interval Idle (CRI)\n"); - if (ShouldSkip("CRI_COMM_DISCOVERY_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForMrpRetryIntervalIdleCri_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Optional TXT key for MRP Retry Interval Active (CRA)\n"); - if (ShouldSkip("CRA_COMM_DISCOVERY_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForMrpRetryIntervalActiveCra_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TXT key for commissioning mode (CM)\n"); - err = TestTxtKeyForCommissioningModeCm_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Optional TXT key for device name (DN)\n"); - if (ShouldSkip("DN_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForDeviceNameDn_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Optional TXT key for rotating device identifier (RI)\n"); - if (ShouldSkip("RI_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForRotatingDeviceIdentifierRi_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Optional TXT key for pairing hint (PH)\n"); - if (ShouldSkip("PH_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForPairingHintPh_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Optional TXT key for pairing instructions (PI)\n"); - if (ShouldSkip("PI_KEY")) - { - NextTest(); - return; - } - err = TestOptionalTxtKeyForPairingInstructionsPi_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check IPs\n"); - err = TestCheckIPs_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Reboot target device\n"); - err = TestRebootTargetDevice_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Open Commissioning Window\n"); - err = TestOpenCommissioningWindow_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait Commissionable advertisement\n"); - err = TestWaitCommissionableAdvertisement_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Check Instance Name\n"); - err = TestCheckInstanceName_24(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mVendorId; - chip::Optional mProductId; - chip::Optional mDeviceType; - - char * deviceInstanceNameBeforeRebootBuffer = nullptr; - chip::CharSpan deviceInstanceNameBeforeReboot; - - void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override - { - bool isExpectedDnssdResult = false; - if ((mTestIndex - 1) == 4) - { - 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 (deviceInstanceNameBeforeRebootBuffer != nullptr) - { - chip::Platform::MemoryFree(deviceInstanceNameBeforeRebootBuffer); - } - deviceInstanceNameBeforeRebootBuffer = static_cast(chip::Platform::MemoryAlloc(value.instanceName.size())); - memcpy(deviceInstanceNameBeforeRebootBuffer, value.instanceName.data(), value.instanceName.size()); - deviceInstanceNameBeforeReboot = chip::CharSpan(deviceInstanceNameBeforeRebootBuffer, value.instanceName.size()); - } - if ((mTestIndex - 1) == 5) - { - isExpectedDnssdResult = true; - } - if ((mTestIndex - 1) == 6) - { - isExpectedDnssdResult = true; - } - if ((mTestIndex - 1) == 7) - { - isExpectedDnssdResult = true; - } - if ((mTestIndex - 1) == 8) - { - isExpectedDnssdResult = true; - } - if ((mTestIndex - 1) == 9) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValue("longDiscriminator", value.longDiscriminator, - mDiscriminator.HasValue() ? mDiscriminator.Value() : GetUniqueDiscriminator())); - VerifyOrReturn(CheckConstraintMinValue("value.longDiscriminator", value.longDiscriminator, 0U)); - VerifyOrReturn(CheckConstraintMaxValue("value.longDiscriminator", value.longDiscriminator, 4096U)); - } - if ((mTestIndex - 1) == 10) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValue("vendorId", value.vendorId, mVendorId.HasValue() ? mVendorId.Value() : 65521U)); - } - if ((mTestIndex - 1) == 11) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValue("productId", value.productId, mProductId.HasValue() ? mProductId.Value() : 32769U)); - } - if ((mTestIndex - 1) == 12) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalIdle", value.mrpRetryIntervalIdle)); - VerifyOrReturn(CheckConstraintMaxValue("value.mrpRetryIntervalIdle.Value()", - value.mrpRetryIntervalIdle.Value(), 3600000UL)); - } - if ((mTestIndex - 1) == 13) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValuePresent("value.mrpRetryIntervalActive", value.mrpRetryIntervalActive)); - VerifyOrReturn(CheckConstraintMaxValue("value.mrpRetryIntervalActive.Value()", - value.mrpRetryIntervalActive.Value(), 3600000UL)); - } - if ((mTestIndex - 1) == 14) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckValue("commissioningMode", value.commissioningMode, 1)); - } - if ((mTestIndex - 1) == 15) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckConstraintMaxLength("value.deviceName", value.deviceName.size(), 32)); - } - if ((mTestIndex - 1) == 16) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckConstraintMaxValue("value.rotatingIdLen", value.rotatingIdLen, 100ULL)); - } - if ((mTestIndex - 1) == 17) - { - isExpectedDnssdResult = true; - } - if ((mTestIndex - 1) == 18) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckConstraintMaxLength("value.pairingInstruction", value.pairingInstruction.size(), 128)); - } - if ((mTestIndex - 1) == 19) - { - isExpectedDnssdResult = true; - - VerifyOrReturn(CheckConstraintMinValue("value.numIPs", value.numIPs, 1)); - } - if ((mTestIndex - 1) == 24) - { - 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)); - VerifyOrReturn(CheckConstraintNotValue("value.instanceName", value.instanceName, deviceInstanceNameBeforeReboot)); - } - - 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() : GetUniqueDiscriminator()); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_1() - { - SetIdentity(kIdentityAlpha); - return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); - } - - CHIP_ERROR TestOpenCommissioningWindow_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 TestWaitCommissionableAdvertisement_3() - { - SetIdentity(kIdentityAlpha); - return WaitForCommissionableAdvertisement(); - } - - CHIP_ERROR TestCheckInstanceName_4() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestCheckLongDiscriminatorL_5() - { - SetIdentity(kIdentityAlpha); - return FindCommissionableByLongDiscriminator(mDiscriminator.HasValue() ? mDiscriminator.Value() : GetUniqueDiscriminator()); - } - - CHIP_ERROR TestCheckShortDiscriminatorS_6() - { - SetIdentity(kIdentityAlpha); - return FindCommissionableByShortDiscriminator(mDiscriminator.HasValue() ? mDiscriminator.Value() - : GetUniqueDiscriminator()); - } - - CHIP_ERROR TestCheckCommissioningModeCm_7() - { - SetIdentity(kIdentityAlpha); - return FindCommissionableByCommissioningMode(); - } - - CHIP_ERROR TestCheckVendorIdV_8() - { - SetIdentity(kIdentityAlpha); - return FindCommissionableByVendorId(mVendorId.HasValue() ? mVendorId.Value() : 65521U); - } - - CHIP_ERROR TestTxtKeyForDiscriminatorD_9() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_10() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestTxtKeyForVendorIdAndProductIdVp_11() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalIdleCri_12() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForMrpRetryIntervalActiveCra_13() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestTxtKeyForCommissioningModeCm_14() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForDeviceNameDn_15() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForRotatingDeviceIdentifierRi_16() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForPairingHintPh_17() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestOptionalTxtKeyForPairingInstructionsPi_18() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestCheckIPs_19() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } - - CHIP_ERROR TestRebootTargetDevice_20() - { - SetIdentity(kIdentityAlpha); - return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : GetUniqueDiscriminator()); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_21() - { - SetIdentity(kIdentityAlpha); - return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); - } - - CHIP_ERROR TestOpenCommissioningWindow_22() - { - 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_22(); - }; - - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_22(error); - }; - - ReturnErrorOnFailure( - chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request, 10000)); - return CHIP_NO_ERROR; - } - - void OnFailureResponse_22(CHIP_ERROR error) - { - chip::app::StatusIB status(error); - ThrowFailureResponse(); - } - - void OnSuccessResponse_22() { NextTest(); } - - CHIP_ERROR TestWaitCommissionableAdvertisement_23() - { - SetIdentity(kIdentityAlpha); - return WaitForCommissionableAdvertisement(); - } - - CHIP_ERROR TestCheckInstanceName_24() - { - SetIdentity(kIdentityAlpha); - return FindCommissionable(); - } -}; - class Test_TC_DD_1_5Suite : public TestCommand { public: @@ -103476,6 +103456,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), @@ -103496,7 +103477,6 @@ 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),