Skip to content

Commit 9f2c629

Browse files
committed
Fix !
1 parent d92b610 commit 9f2c629

6 files changed

+173
-177
lines changed

src/credentials/tests/TestCertificationDeclaration.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
#include <credentials/CertificationDeclaration.h>
3030
#include <credentials/attestation_verifier/DefaultDeviceAttestationVerifier.h>
3131
#include <crypto/CHIPCryptoPAL.h>
32-
#include <gtest/gtest.h>
3332
#include <lib/support/Span.h>
3433

34+
#include <gtest/gtest.h>
35+
3536
using namespace chip;
3637
using namespace chip::ASN1;
3738
using namespace chip::Crypto;
@@ -416,7 +417,7 @@ TEST(TestCertificationDeclaration, TestCD_CertificationElementsDecoder)
416417
{
417418
EXPECT_TRUE(certificationElementsDecoder.IsProductIdIn(encodedCDPayload, testCase.cdElements.ProductIds[j]));
418419
// now test for an unexistent ProductId
419-
EXPECT_EQ(certificationElementsDecoder.IsProductIdIn(encodedCDPayload, 0x9000), false);
420+
EXPECT_FALSE(certificationElementsDecoder.IsProductIdIn(encodedCDPayload, 0x9000));
420421
}
421422
EXPECT_EQ(certificationDeclarationContent.deviceTypeId, testCase.cdElements.DeviceTypeId);
422423
EXPECT_EQ(memcmp(certificationDeclarationContent.certificateId, testCase.cdElements.CertificateId, kCertificateIdLength),
@@ -437,7 +438,7 @@ TEST(TestCertificationDeclaration, TestCD_CertificationElementsDecoder)
437438
}
438439
else
439440
{
440-
EXPECT_TRUE(!certificationDeclarationContent.authorizedPAAListPresent);
441+
EXPECT_FALSE(certificationDeclarationContent.authorizedPAAListPresent);
441442
}
442443
}
443444
}
@@ -515,7 +516,7 @@ TEST(TestCertificationDeclaration, TestCD_EncodeDecode_Random)
515516
{
516517
EXPECT_TRUE(cdElementsDecoder.IsProductIdIn(encodedCDPayload, randomElements.ProductIds[j]));
517518
// now test for an unexistent ProductId
518-
EXPECT_EQ(cdElementsDecoder.IsProductIdIn(encodedCDPayload, pid++), false);
519+
EXPECT_FALSE(cdElementsDecoder.IsProductIdIn(encodedCDPayload, pid++));
519520
}
520521
EXPECT_EQ(decodedElements2.deviceTypeId, randomElements.DeviceTypeId);
521522
EXPECT_EQ(memcmp(decodedElements2.certificateId, randomElements.CertificateId, kCertificateIdLength), 0);
@@ -535,7 +536,7 @@ TEST(TestCertificationDeclaration, TestCD_EncodeDecode_Random)
535536
EXPECT_TRUE(cdElementsDecoder.HasAuthorizedPAA(encodedCDPayload, ByteSpan(randomElements.AuthorizedPAAList[j])));
536537
// now test for an unexistent PAA
537538
kid[(kKeyIdentifierLength - 1 - j) % kKeyIdentifierLength] ^= 0x5A;
538-
EXPECT_EQ(cdElementsDecoder.HasAuthorizedPAA(encodedCDPayload, ByteSpan(kid)), false);
539+
EXPECT_FALSE(cdElementsDecoder.HasAuthorizedPAA(encodedCDPayload, ByteSpan(kid)));
539540
}
540541
}
541542

@@ -547,7 +548,7 @@ TEST(TestCertificationDeclaration, TestCD_DefaultCdTrustStore)
547548
{
548549
ByteSpan signerKeyIdOut;
549550
EXPECT_EQ(CMS_ExtractKeyId(ByteSpan(gUntrustedCd), signerKeyIdOut), CHIP_NO_ERROR);
550-
EXPECT_TRUE(!trustStore.IsCdTestKey(signerKeyIdOut));
551+
EXPECT_FALSE(trustStore.IsCdTestKey(signerKeyIdOut));
551552

552553
P256PublicKey pubKey;
553554
EXPECT_EQ(CHIP_ERROR_KEY_NOT_FOUND, trustStore.LookupVerifyingKey(signerKeyIdOut, pubKey));

src/credentials/tests/TestChipCert.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ TEST_F(TestChipCert, TestChipCert_ChipDN)
316316
EXPECT_TRUE(chip_dn.IsEmpty());
317317
EXPECT_EQ(chip_dn.RDNCount(), 0);
318318
EXPECT_EQ(chip_dn.GetCertType(certType), CHIP_NO_ERROR);
319-
EXPECT_EQ(chip_dn.IsEmpty(), true);
319+
EXPECT_TRUE(chip_dn.IsEmpty());
320320
EXPECT_EQ(certType, CertType::kNotSpecified);
321321

322322
EXPECT_EQ(chip_dn.AddAttribute_CommonName(CharSpan(noc_rdn, strlen(noc_rdn)), false), CHIP_NO_ERROR);
@@ -342,7 +342,7 @@ TEST_F(TestChipCert, TestChipCert_ChipDN)
342342

343343
chip_dn.Clear();
344344
EXPECT_EQ(chip_dn.GetCertType(certType), CHIP_NO_ERROR);
345-
EXPECT_EQ(chip_dn.IsEmpty(), true);
345+
EXPECT_TRUE(chip_dn.IsEmpty());
346346
EXPECT_EQ(certType, CertType::kNotSpecified);
347347

348348
CATValues noc_cats2;
@@ -1294,7 +1294,7 @@ TEST_F(TestChipCert, TestChipCert_DecodingOptions)
12941294
// Decode with default (null) options
12951295
err = DecodeChipCert(cert, certData);
12961296
EXPECT_EQ(err, CHIP_NO_ERROR);
1297-
EXPECT_TRUE(!certData.mCertFlags.Has(CertFlags::kIsTrustAnchor));
1297+
EXPECT_FALSE(certData.mCertFlags.Has(CertFlags::kIsTrustAnchor));
12981298

12991299
// Decode as trust anchor
13001300
err = DecodeChipCert(cert, certData, CertDecodeFlags::kIsTrustAnchor);

src/credentials/tests/TestDeviceAttestationCredentials.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ TEST_F(TestDeviceAttestationCredentials, TestDACProvidersExample_Signature)
151151
err = ExtractPubkeyFromX509Cert(dac_cert_span, dac_public_key);
152152
EXPECT_EQ(err, CHIP_NO_ERROR);
153153
EXPECT_EQ(dac_public_key.Length(), kExpectedDacPublicKey.size());
154-
EXPECT_EQ(0, memcmp(dac_public_key.ConstBytes(), kExpectedDacPublicKey.data(), kExpectedDacPublicKey.size()));
154+
EXPECT_EQ(memcmp(dac_public_key.ConstBytes(), kExpectedDacPublicKey.data(), kExpectedDacPublicKey.size()), 0);
155155

156156
// Verify round trip signature
157157
err = dac_public_key.ECDSA_validate_msg_signature(&kExampleMessage[0], sizeof(kExampleMessage), da_signature);
@@ -411,7 +411,7 @@ TEST_F(TestDeviceAttestationCredentials, TestAttestationTrustStore)
411411
// In success cases, make sure the cert matches expectation.
412412
if (testCase.expectedResult == CHIP_NO_ERROR)
413413
{
414-
EXPECT_EQ(paaCertSpan.data_equal(testCase.expectedCertSpan), true);
414+
EXPECT_TRUE(paaCertSpan.data_equal(testCase.expectedCertSpan));
415415
}
416416
}
417417
}

src/credentials/tests/TestFabricTable.cpp

+36-36
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
575575
}
576576

577577
EXPECT_EQ(numFabricsIterated, 0u);
578-
EXPECT_EQ(saw1, false);
578+
EXPECT_FALSE(saw1);
579579
}
580580

581581
uint8_t rcacBuf[Credentials::kMaxCHIPCertLength];
@@ -634,7 +634,7 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
634634
}
635635

636636
EXPECT_EQ(numFabricsIterated, 1u);
637-
EXPECT_EQ(saw1, true);
637+
EXPECT_TRUE(saw1);
638638
}
639639

640640
// Commit, now storage should have keys
@@ -692,7 +692,7 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
692692
}
693693

694694
EXPECT_EQ(numFabricsIterated, 1u);
695-
EXPECT_EQ(saw1, true);
695+
EXPECT_TRUE(saw1);
696696
}
697697
}
698698

@@ -808,8 +808,8 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
808808
}
809809

810810
EXPECT_EQ(numFabricsIterated, 2u);
811-
EXPECT_EQ(saw1, true);
812-
EXPECT_EQ(saw2, true);
811+
EXPECT_TRUE(saw1);
812+
EXPECT_TRUE(saw2);
813813
}
814814
}
815815

@@ -860,14 +860,14 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
860860
{
861861
EXPECT_EQ(iterFabricInfo.GetNodeId(), 1000u);
862862
EXPECT_EQ(iterFabricInfo.GetFabricId(), 44u);
863-
EXPECT_TRUE(!iterFabricInfo.ShouldAdvertiseIdentity());
863+
EXPECT_FALSE(iterFabricInfo.ShouldAdvertiseIdentity());
864864
saw2 = true;
865865
}
866866
}
867867

868868
EXPECT_EQ(numFabricsIterated, 2u);
869-
EXPECT_EQ(saw1, true);
870-
EXPECT_EQ(saw2, true);
869+
EXPECT_TRUE(saw1);
870+
EXPECT_TRUE(saw2);
871871
}
872872

873873
// Commit, now storage should have keys
@@ -932,8 +932,8 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
932932
}
933933

934934
EXPECT_EQ(numFabricsIterated, 2u);
935-
EXPECT_EQ(saw1, true);
936-
EXPECT_EQ(saw2, true);
935+
EXPECT_TRUE(saw1);
936+
EXPECT_TRUE(saw2);
937937
}
938938

939939
// Next fabric index has stayed the same.
@@ -1048,8 +1048,8 @@ TEST_F(TestFabricTable, TestBasicAddNocUpdateNocFlow)
10481048
}
10491049

10501050
EXPECT_EQ(numFabricsIterated, 1u);
1051-
EXPECT_EQ(saw1, false);
1052-
EXPECT_EQ(saw2, true);
1051+
EXPECT_FALSE(saw1);
1052+
EXPECT_TRUE(saw2);
10531053
}
10541054
}
10551055
}
@@ -1228,7 +1228,7 @@ TEST_F(TestFabricTable, TestAddMultipleSameFabricIdDifferentRoot)
12281228

12291229
EXPECT_EQ(fabricCertAuthority2.SetIncludeIcac(true).GenerateNocChain(fabricId, nodeId, csrSpan).GetStatus(), CHIP_NO_ERROR);
12301230
ByteSpan rcac2 = fabricCertAuthority2.GetRcac();
1231-
EXPECT_TRUE(!rcac2.data_equal(rcac1Span));
1231+
EXPECT_FALSE(rcac2.data_equal(rcac1Span));
12321232

12331233
ByteSpan icac = fabricCertAuthority2.GetIcac();
12341234
ByteSpan noc = fabricCertAuthority2.GetNoc();
@@ -1436,8 +1436,8 @@ TEST_F(TestFabricTable, TestPersistence)
14361436
}
14371437

14381438
EXPECT_EQ(numFabricsIterated, 2u);
1439-
EXPECT_EQ(saw1, true);
1440-
EXPECT_EQ(saw2, true);
1439+
EXPECT_TRUE(saw1);
1440+
EXPECT_TRUE(saw2);
14411441
}
14421442

14431443
// Next fabric index should now be 3, since we added 1 and 2 above.
@@ -1485,8 +1485,8 @@ TEST_F(TestFabricTable, TestPersistence)
14851485
}
14861486

14871487
EXPECT_EQ(numFabricsIterated, 2u);
1488-
EXPECT_EQ(saw1, true);
1489-
EXPECT_EQ(saw2, true);
1488+
EXPECT_TRUE(saw1);
1489+
EXPECT_TRUE(saw2);
14901490
}
14911491

14921492
// Validate contents of Fabric 2222
@@ -1653,7 +1653,7 @@ TEST_F(TestFabricTable, TestAddNocFailSafe)
16531653
}
16541654

16551655
EXPECT_EQ(numFabricsIterated, 1u);
1656-
EXPECT_EQ(saw1, true);
1656+
EXPECT_TRUE(saw1);
16571657
}
16581658

16591659
// Revert, should see nothing yet
@@ -1678,7 +1678,7 @@ TEST_F(TestFabricTable, TestAddNocFailSafe)
16781678
}
16791679

16801680
EXPECT_EQ(numFabricsIterated, 0u);
1681-
EXPECT_EQ(saw1, false);
1681+
EXPECT_FALSE(saw1);
16821682
}
16831683

16841684
// Validate next fabric index has not changed.
@@ -1773,7 +1773,7 @@ TEST_F(TestFabricTable, TestAddNocFailSafe)
17731773
}
17741774

17751775
EXPECT_EQ(numFabricsIterated, 1u);
1776-
EXPECT_EQ(saw1, true);
1776+
EXPECT_TRUE(saw1);
17771777
}
17781778
}
17791779

@@ -1805,7 +1805,7 @@ TEST_F(TestFabricTable, TestAddNocFailSafe)
18051805
}
18061806

18071807
EXPECT_EQ(numFabricsIterated, 1u);
1808-
EXPECT_EQ(saw1, true);
1808+
EXPECT_TRUE(saw1);
18091809
}
18101810
}
18111811
}
@@ -1917,7 +1917,7 @@ TEST_F(TestFabricTable, TestUpdateNocFailSafe)
19171917
}
19181918

19191919
EXPECT_EQ(numFabricsIterated, 1u);
1920-
EXPECT_EQ(saw1, true);
1920+
EXPECT_TRUE(saw1);
19211921
}
19221922
}
19231923

@@ -1965,7 +1965,7 @@ TEST_F(TestFabricTable, TestUpdateNocFailSafe)
19651965
}
19661966

19671967
EXPECT_EQ(numFabricsIterated, 1u);
1968-
EXPECT_EQ(saw1, true);
1968+
EXPECT_TRUE(saw1);
19691969
}
19701970

19711971
// Revert, should see Node ID 999 again
@@ -2029,7 +2029,7 @@ TEST_F(TestFabricTable, TestUpdateNocFailSafe)
20292029
}
20302030

20312031
EXPECT_EQ(numFabricsIterated, 1u);
2032-
EXPECT_EQ(saw1, true);
2032+
EXPECT_TRUE(saw1);
20332033
}
20342034
}
20352035

@@ -2075,7 +2075,7 @@ TEST_F(TestFabricTable, TestUpdateNocFailSafe)
20752075
}
20762076

20772077
EXPECT_EQ(numFabricsIterated, 1u);
2078-
EXPECT_EQ(saw1, true);
2078+
EXPECT_TRUE(saw1);
20792079
}
20802080

20812081
// Commit, should see Node ID 1001, and 1 less cert in the storage
@@ -2133,7 +2133,7 @@ TEST_F(TestFabricTable, TestUpdateNocFailSafe)
21332133
}
21342134

21352135
EXPECT_EQ(numFabricsIterated, 1u);
2136-
EXPECT_EQ(saw1, true);
2136+
EXPECT_TRUE(saw1);
21372137
}
21382138
}
21392139
}
@@ -2253,14 +2253,14 @@ TEST_F(TestFabricTable, TestFabricLabelChange)
22532253
// Set a valid name
22542254
EXPECT_EQ(fabricTable.SetFabricLabel(1, "acme fabric"_span), CHIP_NO_ERROR);
22552255
EXPECT_EQ(fabricTable.GetFabricLabel(1, fabricLabel), CHIP_NO_ERROR);
2256-
EXPECT_EQ(fabricLabel.data_equal("acme fabric"_span), true);
2256+
EXPECT_TRUE(fabricLabel.data_equal("acme fabric"_span));
22572257

22582258
// Revert pending fabric data. Should not revert name since nothing pending.
22592259
fabricTable.RevertPendingFabricData();
22602260

22612261
fabricLabel = "placeholder"_span;
22622262
EXPECT_EQ(fabricTable.GetFabricLabel(1, fabricLabel), CHIP_NO_ERROR);
2263-
EXPECT_EQ(fabricLabel.data_equal("acme fabric"_span), true);
2263+
EXPECT_TRUE(fabricLabel.data_equal("acme fabric"_span));
22642264

22652265
// Verify we fail to set too large a label (> kFabricLabelMaxLengthInBytes)
22662266
CharSpan fabricLabelTooBig = "012345678901234567890123456789123456"_span;
@@ -2270,7 +2270,7 @@ TEST_F(TestFabricTable, TestFabricLabelChange)
22702270

22712271
fabricLabel = "placeholder"_span;
22722272
EXPECT_EQ(fabricTable.GetFabricLabel(1, fabricLabel), CHIP_NO_ERROR);
2273-
EXPECT_EQ(fabricLabel.data_equal("acme fabric"_span), true);
2273+
EXPECT_TRUE(fabricLabel.data_equal("acme fabric"_span));
22742274
}
22752275

22762276
// Third scope: set fabric label after an update, it sticks, but then goes back after revert
@@ -2303,7 +2303,7 @@ TEST_F(TestFabricTable, TestFabricLabelChange)
23032303
EXPECT_EQ(fabricInfo->GetVendorId(), kVendorId);
23042304

23052305
CharSpan fabricLabel = fabricInfo->GetFabricLabel();
2306-
EXPECT_EQ(fabricLabel.data_equal("acme fabric"_span), true);
2306+
EXPECT_TRUE(fabricLabel.data_equal("acme fabric"_span));
23072307
}
23082308

23092309
// Update fabric label
@@ -2312,14 +2312,14 @@ TEST_F(TestFabricTable, TestFabricLabelChange)
23122312

23132313
fabricLabel = "placeholder"_span;
23142314
EXPECT_EQ(fabricTable.GetFabricLabel(1, fabricLabel), CHIP_NO_ERROR);
2315-
EXPECT_EQ(fabricLabel.data_equal("roboto fabric"_span), true);
2315+
EXPECT_TRUE(fabricLabel.data_equal("roboto fabric"_span));
23162316

23172317
// Revert pending fabric data. Should revert name to "acme fabric"
23182318
fabricTable.RevertPendingFabricData();
23192319

23202320
fabricLabel = "placeholder"_span;
23212321
EXPECT_EQ(fabricTable.GetFabricLabel(1, fabricLabel), CHIP_NO_ERROR);
2322-
EXPECT_EQ(fabricLabel.data_equal("acme fabric"_span), true);
2322+
EXPECT_TRUE(fabricLabel.data_equal("acme fabric"_span));
23232323
}
23242324
}
23252325

@@ -2373,7 +2373,7 @@ TEST_F(TestFabricTable, TestFabricLookup)
23732373
return;
23742374
}
23752375
EXPECT_EQ(fabricInfo->GetFabricIndex(), 2);
2376-
EXPECT_TRUE(!fabricInfo->ShouldAdvertiseIdentity());
2376+
EXPECT_FALSE(fabricInfo->ShouldAdvertiseIdentity());
23772377
}
23782378

23792379
// Attempt lookup of FabricIndex 0 --> should always fail.
@@ -2458,7 +2458,7 @@ TEST_F(TestFabricTable, TestAddNocRootCollision)
24582458
EXPECT_NE(fabricInfo, nullptr);
24592459
if (fabricInfo != nullptr)
24602460
{
2461-
EXPECT_TRUE(!fabricInfo->ShouldAdvertiseIdentity());
2461+
EXPECT_FALSE(fabricInfo->ShouldAdvertiseIdentity());
24622462

24632463
Credentials::ChipCertificateSet certificates;
24642464
EXPECT_EQ(certificates.Init(1), CHIP_NO_ERROR);
@@ -2957,8 +2957,8 @@ TEST_F(TestFabricTable, TestCommitMarker)
29572957
}
29582958

29592959
EXPECT_EQ(numFabricsIterated, 1u);
2960-
EXPECT_EQ(saw1, true);
2961-
EXPECT_EQ(saw2, false);
2960+
EXPECT_TRUE(saw1);
2961+
EXPECT_FALSE(saw2);
29622962
}
29632963
}
29642964
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST

0 commit comments

Comments
 (0)