From 9bf0fe6c63979701b4344d2fce1a54ca8bdbf0a3 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 12 Jul 2023 02:11:48 -0400 Subject: [PATCH] Add Darwin test for commissioning with an origin VID in the CD. (#27878) This uses the pieces put in place in https://github.com/project-chip/connectedhomeip/pull/27616 --- .github/workflows/darwin.yaml | 1 + .../CHIPTests/MTRCommissionableBrowserTests.m | 10 ++++++---- src/darwin/Framework/CHIPTests/MTRPairingTests.m | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 4be2929cabf731..1db7aa8a082846 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -113,6 +113,7 @@ jobs: run: | mkdir -p /tmp/darwin/framework-tests ../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) & + ../../../out/debug/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) & # Make sure each ota-requestor is using a different port, discriminator, and KVS from # all-clusters-app and from other requestors. # diff --git a/src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m b/src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m index 9c542b6a996ea7..b2648b2956b3ee 100644 --- a/src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m +++ b/src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m @@ -25,12 +25,14 @@ static const uint16_t kLocalPort = 5541; static const uint16_t kTestVendorId = 0xFFF1u; -static const uint16_t kTestProductId = 0x8001u; +static const uint16_t kTestProductId1 = 0x8000u; +static const uint16_t kTestProductId2 = 0x8001u; static const uint16_t kTestDiscriminator1 = 1111u; static const uint16_t kTestDiscriminator2 = 1112u; static const uint16_t kTestDiscriminator3 = 3840u; +static const uint16_t kTestDiscriminator4 = 3839u; static const uint16_t kDiscoverDeviceTimeoutInSeconds = 10; -static const uint16_t kExpectedDiscoveredDevicesCount = 3; +static const uint16_t kExpectedDiscoveredDevicesCount = 4; // Singleton controller we use. static MTRDeviceController * sController = nil; @@ -73,9 +75,9 @@ - (void)controller:(MTRDeviceController *)controller didFindCommissionableDevice XCTAssertEqual(instanceName.length, 16); // The instance name is random, so just ensure the len is right. XCTAssertEqualObjects(vendorId, @(kTestVendorId)); - XCTAssertEqualObjects(productId, @(kTestProductId)); + XCTAssertTrue([productId isEqual:@(kTestProductId1)] || [productId isEqual:@(kTestProductId2)]); XCTAssertTrue([discriminator isEqual:@(kTestDiscriminator1)] || [discriminator isEqual:@(kTestDiscriminator2)] || - [discriminator isEqual:@(kTestDiscriminator3)]); + [discriminator isEqual:@(kTestDiscriminator3)] || [discriminator isEqual:@(kTestDiscriminator4)]); XCTAssertEqual(commissioningMode, YES); NSLog(@"Found Device (%@) with discriminator: %@ (vendor: %@, product: %@)", instanceName, discriminator, vendorId, productId); diff --git a/src/darwin/Framework/CHIPTests/MTRPairingTests.m b/src/darwin/Framework/CHIPTests/MTRPairingTests.m index 5043744286486a..94ce4e93131169 100644 --- a/src/darwin/Framework/CHIPTests/MTRPairingTests.m +++ b/src/darwin/Framework/CHIPTests/MTRPairingTests.m @@ -29,7 +29,7 @@ static const uint16_t kPairingTimeoutInSeconds = 10; static const uint16_t kTimeoutInSeconds = 3; static uint64_t sDeviceId = 0x12344321; -static NSString * kOnboardingPayload = @"MT:-24J0AFN00KA0648G00"; +static NSString * kOnboardingPayload = @"MT:Y.K90SO527JA0648G00"; static const uint16_t kLocalPort = 5541; static const uint16_t kTestVendorId = 0xFFF1u; @@ -65,10 +65,10 @@ - (void)deviceAttestationCompletedForController:(MTRDeviceController *)controlle { [self.expectation fulfill]; // Hard-coded to what our example server app uses for now. - // TODO: Build an example that uses the "origin" bits that allow a DAC and - // CD to have different vendor IDs, and verify things here. + XCTAssertEqualObjects(attestationDeviceInfo.vendorID, @(0xFFF2)); + XCTAssertEqualObjects(attestationDeviceInfo.productID, @(0x8001)); XCTAssertEqualObjects(attestationDeviceInfo.basicInformationVendorID, @(0xFFF1)); - XCTAssertEqualObjects(attestationDeviceInfo.basicInformationProductID, @(0x8001)); + XCTAssertEqualObjects(attestationDeviceInfo.basicInformationProductID, @(0x8000)); [controller continueCommissioningDevice:opaqueDeviceHandle ignoreAttestationFailure:NO error:nil]; }