Skip to content

Commit 738a255

Browse files
jlatusekarkq
andauthored
Apply suggestions from code review
Co-authored-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
1 parent 3d5213f commit 738a255

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/credentials/tests/TestDeviceAttestationCredentials.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ static const ByteSpan kExpectedPaiPublicKey = DevelopmentCerts::kPaiPublicKey;
4949

5050
struct TestDeviceAttestationCredentials : public ::testing::Test
5151
{
52-
static void SetUpTestSuite()
53-
{
54-
CHIP_ERROR error = chip::Platform::MemoryInit();
55-
EXPECT_EQ(error, CHIP_NO_ERROR);
56-
}
52+
static void SetUpTestSuite() { ASSERT_EQ([error](chip::Platform::MemoryInit()), CHIP_NO_ERROR); }
5753
static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
5854
};
5955

@@ -71,7 +67,7 @@ TEST_F(TestDeviceAttestationCredentials, TestDACProvidersExample_Providers)
7167

7268
// Replace default provider with example provider
7369
DeviceAttestationCredentialsProvider * example_dac_provider = Examples::GetExampleDACProvider();
74-
EXPECT_NE(example_dac_provider, nullptr);
70+
ASSERT_NE(example_dac_provider, nullptr);
7571
EXPECT_NE(default_provider, example_dac_provider);
7672

7773
SetDeviceAttestationCredentialsProvider(example_dac_provider);
@@ -127,7 +123,7 @@ TEST_F(TestDeviceAttestationCredentials, TestDACProvidersExample_Signature)
127123
0x26, 0x27, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 };
128124

129125
DeviceAttestationCredentialsProvider * example_dac_provider = Examples::GetExampleDACProvider();
130-
EXPECT_NE(example_dac_provider, nullptr);
126+
ASSERT_NE(example_dac_provider, nullptr);
131127

132128
// Sign using the example attestation private key
133129
P256ECDSASignature da_signature;
@@ -200,15 +196,15 @@ TEST_F(TestDeviceAttestationCredentials, TestDACVerifierExample_AttestationInfoV
200196

201197
// Make sure default verifier exists and is not implemented on at least one method
202198
DeviceAttestationVerifier * default_verifier = GetDeviceAttestationVerifier();
203-
EXPECT_NE(default_verifier, nullptr);
199+
ASSERT_NE(default_verifier, nullptr);
204200

205201
AttestationVerificationResult attestationResult = AttestationVerificationResult::kSuccess;
206202
ByteSpan emptyByteSpan;
207203
attestationResult = default_verifier->ValidateCertificationDeclarationSignature(ByteSpan(), emptyByteSpan);
208204
EXPECT_EQ(attestationResult, AttestationVerificationResult::kNotImplemented);
209205

210206
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
211-
EXPECT_NE(example_dac_verifier, nullptr);
207+
ASSERT_NE(example_dac_verifier, nullptr);
212208
EXPECT_NE(default_verifier, example_dac_verifier);
213209

214210
SetDeviceAttestationVerifier(example_dac_verifier);
@@ -267,7 +263,7 @@ TEST_F(TestDeviceAttestationCredentials, TestDACVerifierExample_CertDeclarationV
267263

268264
// Replace default verifier with example verifier
269265
DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
270-
EXPECT_NE(example_dac_verifier, nullptr);
266+
ASSERT_NE(example_dac_verifier, nullptr);
271267

272268
SetDeviceAttestationVerifier(example_dac_verifier);
273269
DeviceAttestationVerifier * default_verifier = GetDeviceAttestationVerifier();
@@ -344,7 +340,7 @@ TEST_F(TestDeviceAttestationCredentials, TestDACVerifierExample_NocsrInformation
344340
0x8d, 0x85, 0xfb, 0xd7, 0xa0, 0x7c, 0x8e, 0x83, 0x7d, 0xa4, 0xd5, 0xa8, 0xb9 };
345341

346342
DeviceAttestationVerifier * exampleDacVerifier = GetDefaultDACVerifier(GetTestAttestationTrustStore());
347-
EXPECT_NE(exampleDacVerifier, nullptr);
343+
ASSERT_NE(exampleDacVerifier, nullptr);
348344

349345
P256PublicKey dacPubkey;
350346
EXPECT_EQ(sizeof(attestationPublicKey), dacPubkey.Length());
@@ -392,7 +388,7 @@ TEST_F(TestDeviceAttestationCredentials, TestAttestationTrustStore)
392388
};
393389

394390
const AttestationTrustStore * testAttestationTrustStore = GetTestAttestationTrustStore();
395-
EXPECT_NE(testAttestationTrustStore, nullptr);
391+
ASSERT_NE(testAttestationTrustStore, nullptr);
396392

397393
for (const auto & testCase : kTestCases)
398394
{

src/credentials/tests/TestFabricTable.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ struct TestFabricTable : public ::testing::Test
189189
static void SetUpTestSuite()
190190
{
191191
DeviceLayer::SetConfigurationMgr(&DeviceLayer::ConfigurationManagerImpl::GetDefaultInstance());
192-
auto error = chip::Platform::MemoryInit();
193-
EXPECT_EQ(error, CHIP_NO_ERROR);
192+
ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
194193
}
195194
static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
196195
};

0 commit comments

Comments
 (0)