1 #include "ipmi.hpp" 2 3 #include <blobs-ipmid/test/manager_mock.hpp> 4 #include <vector> 5 6 #include <gtest/gtest.h> 7 8 namespace blobs 9 { 10 11 TEST(IpmiValidateTest, VerifyCommandMinimumLengths) 12 { 13 14 struct TestCase 15 { 16 BlobOEMCommands cmd; 17 size_t len; 18 bool expect; 19 }; 20 21 std::vector<TestCase> tests = { 22 {BlobOEMCommands::bmcBlobClose, sizeof(struct BmcBlobCloseTx) - 1, 23 false}, 24 {BlobOEMCommands::bmcBlobCommit, sizeof(struct BmcBlobCommitTx) - 1, 25 false}, 26 {BlobOEMCommands::bmcBlobDelete, sizeof(struct BmcBlobDeleteTx) + 1, 27 false}, 28 {BlobOEMCommands::bmcBlobEnumerate, 29 sizeof(struct BmcBlobEnumerateTx) - 1, false}, 30 {BlobOEMCommands::bmcBlobOpen, sizeof(struct BmcBlobOpenTx) + 1, false}, 31 {BlobOEMCommands::bmcBlobRead, sizeof(struct BmcBlobReadTx) - 1, false}, 32 {BlobOEMCommands::bmcBlobSessionStat, 33 sizeof(struct BmcBlobSessionStatTx) - 1, false}, 34 {BlobOEMCommands::bmcBlobStat, sizeof(struct BmcBlobStatTx) + 1, false}, 35 {BlobOEMCommands::bmcBlobWrite, sizeof(struct BmcBlobWriteTx), false}, 36 }; 37 38 for (const auto& test : tests) 39 { 40 bool result = validateRequestLength(test.cmd, test.len); 41 EXPECT_EQ(result, test.expect); 42 } 43 } 44 } // namespace blobs 45