1 #include "create_action_map.hpp"
2 #include "firmware_handler.hpp"
3 #include "flags.hpp"
4 #include "image_mock.hpp"
5 #include "util.hpp"
6 
7 #include <memory>
8 #include <vector>
9 
10 #include <gtest/gtest.h>
11 
12 namespace ipmi_flash
13 {
14 namespace
15 {
16 
17 /* This test ensures the stat() method preserves compatibility with older host
18  * tools by reporting that all transports are supported. */
19 TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsAllTransports)
20 {
21     /* Test that the metadata information returned matches expectations for this
22      * case.
23      *
24      * canHandle has already been called at this point, so we don't need to test
25      * the input for this function.
26      */
27 
28     std::vector<HandlerPack> blobs;
29     blobs.emplace_back(hashBlobId, std::make_unique<ImageHandlerMock>());
30     blobs.emplace_back("asdf", std::make_unique<ImageHandlerMock>());
31 
32     std::vector<DataHandlerPack> data;
33     data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
34 
35     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
36         std::move(blobs), std::move(data), CreateActionMap("asdf"));
37 
38     blobs::BlobMeta meta;
39     EXPECT_TRUE(handler->stat("asdf", &meta));
40     /* All transport flags are set */
41     EXPECT_EQ(0xff00, meta.blobState);
42 }
43 
44 } // namespace
45 } // namespace ipmi_flash
46