Skip to content

Commit 987a894

Browse files
committed
Restyle
1 parent 4bebf61 commit 987a894

File tree

4 files changed

+38
-45
lines changed

4 files changed

+38
-45
lines changed

src/protocols/secure_channel/tests/TestCASESession.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ TEST_F(TestCASESession, DestinationIdTest)
681681
EXPECT_FALSE(destinationIdSpan.data_equal(ByteSpan(kExpectedDestinationIdFromSpec)));
682682
}
683683

684-
685684
template <typename Params>
686685
static CHIP_ERROR EncodeSigma1(MutableByteSpan & buf)
687686
{
@@ -1002,9 +1001,9 @@ TEST_F(TestCASESession, SessionResumptionStorage)
10021001
CHIP_NO_ERROR);
10031002
ExchangeContext * contextCommissioner = NewUnauthenticatedExchangeToBob(pairingCommissioner);
10041003
auto establishmentReturnVal = pairingCommissioner->EstablishSession(
1005-
GetSecureSessionManager(), &gCommissionerFabrics, ScopedNodeId{ Node01_01, gCommissionerFabricIndex },
1006-
contextCommissioner, &testVectors[i].initiatorStorage, nullptr, &delegateCommissioner,
1007-
Optional<ReliableMessageProtocolConfig>::Missing());
1004+
GetSecureSessionManager(), &gCommissionerFabrics, ScopedNodeId{ Node01_01, gCommissionerFabricIndex },
1005+
contextCommissioner, &testVectors[i].initiatorStorage, nullptr, &delegateCommissioner,
1006+
Optional<ReliableMessageProtocolConfig>::Missing());
10081007
ServiceEvents();
10091008
EXPECT_EQ(establishmentReturnVal, CHIP_NO_ERROR);
10101009
EXPECT_EQ(loopback.mSentMessageCount, testVectors[i].expectedSentMessageCount);
@@ -1016,7 +1015,7 @@ TEST_F(TestCASESession, SessionResumptionStorage)
10161015
gPairingServer.Shutdown();
10171016
}
10181017
}
1019-
// #endif
1018+
10201019
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
10211020
TEST_F_FROM_FIXTURE(TestCASESession, SimulateUpdateNOCInvalidatePendingEstablishment)
10221021
{

src/protocols/secure_channel/tests/TestCheckinMsg.cpp

+19-25
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include <crypto/DefaultSessionKeystore.h>
2020
#include <crypto/RandUtils.h>
21+
#include <gtest/gtest.h>
2122
#include <lib/support/BufferWriter.h>
2223
#include <lib/support/CHIPMem.h>
23-
#include <gtest/gtest.h>
2424
#include <protocols/Protocols.h>
2525
#include <protocols/secure_channel/CheckinMessage.h>
2626
#include <protocols/secure_channel/Constants.h>
@@ -34,9 +34,7 @@ using namespace chip::Protocols::SecureChannel;
3434
using namespace chip::Crypto;
3535
using TestSessionKeystoreImpl = Crypto::DefaultSessionKeystore;
3636

37-
namespace chip {
38-
namespace Protocols {
39-
namespace SecureChannel {
37+
namespace {
4038

4139
class TestCheckInMsg : public ::testing::Test
4240
{
@@ -75,7 +73,6 @@ CHIP_ERROR TestCheckInMsg::GenerateAndVerifyPayload(MutableByteSpan & output, co
7573
memcpy(hmacKeyMaterial, vector.key, vector.key_len);
7674

7775
Aes128KeyHandle aes128KeyHandle;
78-
7976
EXPECT_EQ(keystore.CreateKey(aesKeyMaterial, aes128KeyHandle), CHIP_NO_ERROR);
8077

8178
Hmac128KeyHandle hmac128KeyHandle;
@@ -237,7 +234,6 @@ TEST_F(TestCheckInMsg, TestCheckinMessageGenerate_ValidInputsTooSmallOutput)
237234

238235
// Create output buffer with 0 size
239236
MutableByteSpan output;
240-
241237
EXPECT_EQ(CHIP_ERROR_BUFFER_TOO_SMALL, GenerateAndVerifyPayload(output, vector));
242238
}
243239

@@ -268,10 +264,10 @@ TEST_F(TestCheckInMsg, TestCheckInMessageGenerate_EmptyAesKeyHandle)
268264
// Create application data ByteSpan
269265
ByteSpan applicationData(vector.application_data, vector.application_data_len);
270266

271-
/*
272-
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
273-
When using OpenSSL this same test result in a success.
274-
*/
267+
/*
268+
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
269+
When using OpenSSL this same test result in a success.
270+
*/
275271
#if 0
276272
// Verify that the generation fails with an empty key handle
277273
NL_TEST_ASSERT_(inSuite,
@@ -310,10 +306,10 @@ TEST_F(TestCheckInMsg, TestCheckInMessageGenerate_EmptyHmacKeyHandle)
310306
// Create application data ByteSpan
311307
ByteSpan applicationData(vector.application_data, vector.application_data_len);
312308

313-
/*
314-
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
315-
When using OpenSSL this same test result in a success.
316-
*/
309+
/*
310+
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
311+
When using OpenSSL this same test result in a success.
312+
*/
317313
#if 0
318314
// Verify that the generation fails with an empty key handle
319315
NL_TEST_ASSERT_(inSuite,
@@ -403,10 +399,10 @@ TEST_F(TestCheckInMsg, TestCheckInMessageParse_EmptyAesKeyHandle)
403399
Hmac128KeyHandle hmac128KeyHandle;
404400
EXPECT_EQ(keystore.CreateKey(hmacKeyMaterial, hmac128KeyHandle), CHIP_NO_ERROR);
405401

406-
/*
407-
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
408-
When using OpenSSL this same test result in a success.
409-
*/
402+
/*
403+
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
404+
When using OpenSSL this same test result in a success.
405+
*/
410406
#if 0
411407
// Verify that the generation fails with an empty key handle
412408
EXPECT_EQ(
@@ -447,10 +443,10 @@ TEST_F(TestCheckInMsg, TestCheckInMessageParse_EmptyHmacKeyHandle)
447443
Aes128KeyHandle aes128KeyHandle;
448444
EXPECT_EQ(keystore.CreateKey(aesKeyMaterial, aes128KeyHandle), CHIP_NO_ERROR);
449445

450-
/*
451-
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
452-
When using OpenSSL this same test result in a success.
453-
*/
446+
/*
447+
TODO(#28986): Passing an empty key handle while using PSA crypto will result in a failure.
448+
When using OpenSSL this same test result in a success.
449+
*/
454450
#if 0
455451
// Verify that the generation fails with an empty key handle
456452
EXPECT_EQ(
@@ -525,6 +521,4 @@ TEST_F(TestCheckInMsg, TestCheckInMessagePayloadSizeNullBuffer)
525521
EXPECT_EQ(calculated_size, 0u);
526522
}
527523

528-
} // namespace SecureChannel
529-
} // namespace Protocols
530-
} // namespace chip
524+
} // namespace

src/protocols/secure_channel/tests/TestDefaultSessionResumptionStorage.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include <gtest/gtest.h>
1819
#include <lib/support/CodeUtils.h>
1920
#include <lib/support/TestPersistentStorageDelegate.h>
2021

21-
#include <gtest/gtest.h>
22-
2322
// DefaultSessionResumptionStorage is a partial implementation.
2423
// Use SimpleSessionResumptionStorage, which extends it, to test.
2524
#include <protocols/secure_channel/SimpleSessionResumptionStorage.h>

src/protocols/secure_channel/tests/TestSimpleSessionResumptionStorage.cpp

+14-13
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ TEST(TestSimpleSessionResumptionStorage, TestLink)
3232
sessionStorage.Init(&storage);
3333

3434
chip::SimpleSessionResumptionStorage::ResumptionIdStorage resumptionId;
35-
EXPECT_EQ( chip::Crypto::DRBG_get_bytes(resumptionId.data(), resumptionId.size()), CHIP_NO_ERROR);
35+
EXPECT_EQ(chip::Crypto::DRBG_get_bytes(resumptionId.data(), resumptionId.size()), CHIP_NO_ERROR);
3636

37-
EXPECT_EQ( sessionStorage.SaveLink(resumptionId, chip::ScopedNodeId(node1, fabric1)), CHIP_NO_ERROR);
37+
EXPECT_EQ(sessionStorage.SaveLink(resumptionId, chip::ScopedNodeId(node1, fabric1)), CHIP_NO_ERROR);
3838

3939
chip::ScopedNodeId node;
40-
EXPECT_EQ( sessionStorage.LoadLink(resumptionId, node), CHIP_NO_ERROR);
40+
EXPECT_EQ(sessionStorage.LoadLink(resumptionId, node), CHIP_NO_ERROR);
4141
EXPECT_EQ(node, chip::ScopedNodeId(node1, fabric1));
4242

43-
EXPECT_EQ( sessionStorage.DeleteLink(resumptionId), CHIP_NO_ERROR);
43+
EXPECT_EQ(sessionStorage.DeleteLink(resumptionId), CHIP_NO_ERROR);
4444

4545
EXPECT_EQ(sessionStorage.LoadLink(resumptionId, node), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND);
4646
}
@@ -54,26 +54,27 @@ TEST(TestSimpleSessionResumptionStorage, TestState)
5454
chip::ScopedNodeId node(node1, fabric1);
5555

5656
chip::SimpleSessionResumptionStorage::ResumptionIdStorage resumptionId;
57-
EXPECT_EQ( chip::Crypto::DRBG_get_bytes(resumptionId.data(), resumptionId.size()), CHIP_NO_ERROR);
57+
EXPECT_EQ(chip::Crypto::DRBG_get_bytes(resumptionId.data(), resumptionId.size()), CHIP_NO_ERROR);
5858

5959
chip::Crypto::P256ECDHDerivedSecret sharedSecret;
6060
sharedSecret.SetLength(sharedSecret.Capacity());
61-
EXPECT_EQ( chip::Crypto::DRBG_get_bytes(sharedSecret.Bytes(), sharedSecret.Length()), CHIP_NO_ERROR);
61+
EXPECT_EQ(chip::Crypto::DRBG_get_bytes(sharedSecret.Bytes(), sharedSecret.Length()), CHIP_NO_ERROR);
6262

6363
chip::CATValues peerCATs;
6464

65-
EXPECT_EQ( sessionStorage.SaveState(node, resumptionId, sharedSecret, peerCATs), CHIP_NO_ERROR);
65+
EXPECT_EQ(sessionStorage.SaveState(node, resumptionId, sharedSecret, peerCATs), CHIP_NO_ERROR);
6666

6767
chip::SimpleSessionResumptionStorage::ResumptionIdStorage resumptionId2;
6868
chip::Crypto::P256ECDHDerivedSecret sharedSecret2;
6969
chip::CATValues peerCATs2;
70-
EXPECT_EQ( sessionStorage.LoadState(node, resumptionId2, sharedSecret2, peerCATs2), CHIP_NO_ERROR);
70+
EXPECT_EQ(sessionStorage.LoadState(node, resumptionId2, sharedSecret2, peerCATs2), CHIP_NO_ERROR);
7171
EXPECT_EQ(resumptionId, resumptionId2);
7272
EXPECT_EQ(memcmp(sharedSecret.Bytes(), sharedSecret2.Bytes(), sharedSecret.Length()), 0);
7373

74-
EXPECT_EQ( sessionStorage.DeleteState(node), CHIP_NO_ERROR);
74+
EXPECT_EQ(sessionStorage.DeleteState(node), CHIP_NO_ERROR);
7575

76-
EXPECT_EQ( sessionStorage.LoadState(node, resumptionId2, sharedSecret2, peerCATs2), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND);
76+
EXPECT_EQ(sessionStorage.LoadState(node, resumptionId2, sharedSecret2, peerCATs2),
77+
CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND);
7778
}
7879

7980
TEST(TestSimpleSessionResumptionStorage, TestIndex)
@@ -85,14 +86,14 @@ TEST(TestSimpleSessionResumptionStorage, TestIndex)
8586
chip::ScopedNodeId node(node1, fabric1);
8687

8788
chip::DefaultSessionResumptionStorage::SessionIndex index0o;
88-
EXPECT_EQ( sessionStorage.LoadIndex(index0o), CHIP_NO_ERROR);
89+
EXPECT_EQ(sessionStorage.LoadIndex(index0o), CHIP_NO_ERROR);
8990
EXPECT_EQ(index0o.mSize, 0u);
9091

9192
chip::DefaultSessionResumptionStorage::SessionIndex index1;
9293
index1.mSize = 0;
93-
EXPECT_EQ( sessionStorage.SaveIndex(index1), CHIP_NO_ERROR);
94+
EXPECT_EQ(sessionStorage.SaveIndex(index1), CHIP_NO_ERROR);
9495
chip::DefaultSessionResumptionStorage::SessionIndex index1o;
95-
EXPECT_EQ( sessionStorage.LoadIndex(index1o), CHIP_NO_ERROR);
96+
EXPECT_EQ(sessionStorage.LoadIndex(index1o), CHIP_NO_ERROR);
9697
EXPECT_EQ(index1o.mSize, 0u);
9798

9899
chip::DefaultSessionResumptionStorage::SessionIndex index2;

0 commit comments

Comments
 (0)