Skip to content

Commit 582e3fa

Browse files
committed
Restore missing if
1 parent 35bc71f commit 582e3fa

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

src/credentials/tests/TestGroupDataProvider.cpp

+24-21
Original file line numberDiff line numberDiff line change
@@ -1217,31 +1217,34 @@ TEST_F(TestGroupDataProvider, TestGroupDecryption)
12171217
size_t count = 0, total = 0;
12181218

12191219
EXPECT_TRUE(it);
1220-
total = it->Count();
1221-
EXPECT_EQ(expected.size(), total);
1222-
while (it->Next(session))
1220+
if (it)
12231221
{
1224-
std::pair<FabricIndex, GroupId> found(session.fabric_index, session.group_id);
1225-
EXPECT_GT(expected.count(found), 0u);
1226-
EXPECT_NE(session.keyContext, nullptr);
1227-
// Assert aboves doesn't actually exit, we call continue so that we can call it->Release() outside of
1228-
// loop.
1229-
if (session.keyContext == nullptr)
1222+
total = it->Count();
1223+
EXPECT_EQ(expected.size(), total);
1224+
while (it->Next(session))
12301225
{
1231-
continue;
1226+
std::pair<FabricIndex, GroupId> found(session.fabric_index, session.group_id);
1227+
EXPECT_GT(expected.count(found), 0u);
1228+
EXPECT_NE(session.keyContext, nullptr);
1229+
// Assert aboves doesn't actually exit, we call continue so that we can call it->Release() outside of
1230+
// loop.
1231+
if (session.keyContext == nullptr)
1232+
{
1233+
continue;
1234+
}
1235+
1236+
// Decrypt the ciphertext
1237+
EXPECT_EQ(session.keyContext->MessageDecrypt(ciphertext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)),
1238+
tag, plaintext),
1239+
CHIP_NO_ERROR);
1240+
1241+
// The new plaintext must match the original message
1242+
EXPECT_EQ(memcmp(plaintext.data(), kMessage, sizeof(kMessage)), 0);
1243+
count++;
12321244
}
1233-
1234-
// Decrypt the ciphertext
1235-
EXPECT_EQ(session.keyContext->MessageDecrypt(ciphertext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)), tag,
1236-
plaintext),
1237-
CHIP_NO_ERROR);
1238-
1239-
// The new plaintext must match the original message
1240-
EXPECT_EQ(memcmp(plaintext.data(), kMessage, sizeof(kMessage)), 0);
1241-
count++;
1245+
EXPECT_EQ(count, total);
1246+
it->Release();
12421247
}
1243-
EXPECT_EQ(count, total);
1244-
it->Release();
12451248
}
12461249

12471250
} // namespace TestGroups

0 commit comments

Comments
 (0)