Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 1 | #include "data_mock.hpp" |
| 2 | #include "firmware_handler.hpp" |
| 3 | #include "image_mock.hpp" |
| 4 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 5 | #include <sdbusplus/test/sdbus_mock.hpp> |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 6 | #include <vector> |
| 7 | |
| 8 | #include <gmock/gmock.h> |
| 9 | #include <gtest/gtest.h> |
| 10 | |
| 11 | namespace blobs |
| 12 | { |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 13 | using ::testing::Eq; |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 14 | using ::testing::Return; |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 15 | using ::testing::StrEq; |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 16 | |
| 17 | TEST(FirmwareHandlerOpenTest, OpenWithEverythingValid) |
| 18 | { |
| 19 | /* The client passes write set, and a transport that's supported, and a |
| 20 | * firmware image blob_id that's supported. */ |
| 21 | |
| 22 | ImageHandlerMock imageMock; |
| 23 | |
| 24 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 25 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 26 | {"asdf", &imageMock}, |
| 27 | }; |
| 28 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 29 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 30 | }; |
| 31 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 32 | sdbusplus::SdBusMock sdbus_mock; |
| 33 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 34 | |
| 35 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 36 | std::move(bus_mock), blobs, data); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 37 | |
| 38 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true)); |
| 39 | |
| 40 | EXPECT_TRUE(handler->open( |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 41 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 42 | |
| 43 | /* The active image blob_id was added. */ |
| 44 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 45 | EXPECT_EQ(4, currentBlobs.size()); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 46 | EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(), |
| 47 | FirmwareBlobHandler::activeImageBlobID)); |
| 48 | } |
| 49 | |
| 50 | TEST(FirmwareHandlerOpenTest, OpenWithEverythingValidHashFile) |
| 51 | { |
| 52 | /* Open the hash file by blob_id. */ |
| 53 | ImageHandlerMock imageMock; |
| 54 | |
| 55 | std::vector<HandlerPack> blobs = { |
| 56 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
| 57 | {"asdf", &imageMock}, |
| 58 | }; |
| 59 | std::vector<DataHandlerPack> data = { |
| 60 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 61 | }; |
| 62 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 63 | sdbusplus::SdBusMock sdbus_mock; |
| 64 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 65 | |
| 66 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 67 | std::move(bus_mock), blobs, data); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 68 | |
| 69 | EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID))) |
| 70 | .WillOnce(Return(true)); |
| 71 | |
| 72 | EXPECT_TRUE(handler->open( |
| 73 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, |
| 74 | FirmwareBlobHandler::hashBlobID)); |
| 75 | |
| 76 | /* The active hash blob_id was added. */ |
| 77 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 78 | EXPECT_EQ(4, currentBlobs.size()); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 79 | EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(), |
| 80 | FirmwareBlobHandler::activeHashBlobID)); |
| 81 | } |
| 82 | |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 83 | TEST(FirmwareHandlerOpenTest, OpenWithDataHandlerAllSucceeds) |
| 84 | { |
| 85 | /* Attempting to open a file that has an active handler, and use that active |
| 86 | * handler method. |
| 87 | */ |
| 88 | DataHandlerMock dataMock; |
| 89 | ImageHandlerMock imageMock; |
| 90 | |
| 91 | std::vector<HandlerPack> blobs = { |
| 92 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
| 93 | {"asdf", &imageMock}, |
| 94 | }; |
| 95 | std::vector<DataHandlerPack> data = { |
| 96 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 97 | {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock}, |
| 98 | }; |
| 99 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 100 | sdbusplus::SdBusMock sdbus_mock; |
| 101 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 102 | |
| 103 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 104 | std::move(bus_mock), blobs, data); |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 105 | |
| 106 | EXPECT_CALL(dataMock, open()).WillOnce(Return(true)); |
| 107 | EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID))) |
| 108 | .WillOnce(Return(true)); |
| 109 | |
| 110 | EXPECT_TRUE(handler->open( |
| 111 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc, |
| 112 | FirmwareBlobHandler::hashBlobID)); |
| 113 | |
| 114 | /* The active hash blob_id was added. */ |
| 115 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 116 | EXPECT_EQ(4, currentBlobs.size()); |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 117 | EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(), |
| 118 | FirmwareBlobHandler::activeHashBlobID)); |
| 119 | } |
| 120 | |
| 121 | TEST(FirmwareHandlerOpenTest, OpenWithDataHandlerReturnsFailure) |
| 122 | { |
| 123 | /* The data handler call returns failure on open, therefore open fails. */ |
| 124 | DataHandlerMock dataMock; |
| 125 | ImageHandlerMock imageMock; |
| 126 | |
| 127 | std::vector<HandlerPack> blobs = { |
| 128 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
| 129 | {"asdf", &imageMock}, |
| 130 | }; |
| 131 | std::vector<DataHandlerPack> data = { |
| 132 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 133 | {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock}, |
| 134 | }; |
| 135 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 136 | sdbusplus::SdBusMock sdbus_mock; |
| 137 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 138 | |
| 139 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 140 | std::move(bus_mock), blobs, data); |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 141 | |
| 142 | EXPECT_CALL(dataMock, open()).WillOnce(Return(false)); |
| 143 | |
| 144 | EXPECT_FALSE(handler->open( |
| 145 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc, |
| 146 | FirmwareBlobHandler::hashBlobID)); |
| 147 | |
| 148 | /* The active hash blob_id was added. */ |
| 149 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 150 | EXPECT_EQ(3, currentBlobs.size()); |
Patrick Venture | 6e307a7 | 2018-11-09 18:21:17 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 153 | TEST(FirmwareHandlerOpenTest, OpenEverythingSucceedsVerifyOpenFileCheck) |
| 154 | { |
| 155 | /* Verify only one file can be open at a time by opening a file, trying |
| 156 | * again, then closing, and trying again. |
| 157 | */ |
| 158 | ImageHandlerMock imageMock1, imageMock2; |
| 159 | |
| 160 | std::vector<HandlerPack> blobs = { |
| 161 | {FirmwareBlobHandler::hashBlobID, &imageMock1}, |
| 162 | {"asdf", &imageMock2}, |
| 163 | }; |
| 164 | std::vector<DataHandlerPack> data = { |
| 165 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 166 | }; |
| 167 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 168 | sdbusplus::SdBusMock sdbus_mock; |
| 169 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 170 | |
| 171 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 172 | std::move(bus_mock), blobs, data); |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 173 | |
| 174 | EXPECT_CALL(imageMock2, open("asdf")).WillOnce(Return(true)); |
| 175 | |
| 176 | EXPECT_TRUE(handler->open( |
| 177 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
| 178 | |
| 179 | /* The active image blob_id was added. */ |
| 180 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 181 | EXPECT_EQ(4, currentBlobs.size()); |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 182 | EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(), |
| 183 | FirmwareBlobHandler::activeImageBlobID)); |
| 184 | |
| 185 | /* Open the hash file (since we opened an image file). */ |
| 186 | EXPECT_FALSE(handler->open( |
| 187 | 1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, |
| 188 | FirmwareBlobHandler::hashBlobID)); |
| 189 | |
Patrick Venture | 68bb143 | 2018-11-09 20:08:48 -0800 | [diff] [blame] | 190 | EXPECT_TRUE(handler->close(0)); |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 191 | |
| 192 | EXPECT_CALL(imageMock1, open(StrEq(FirmwareBlobHandler::hashBlobID))) |
| 193 | .WillOnce(Return(true)); |
| 194 | |
| 195 | EXPECT_TRUE(handler->open( |
| 196 | 1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, |
| 197 | FirmwareBlobHandler::hashBlobID)); |
| 198 | } |
| 199 | |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 200 | TEST(FirmwareHandlerOpenTest, OpenEverythingSucceedsOpenActiveFails) |
| 201 | { |
| 202 | /* Attempting to open the active image blob, when it's present will fail. |
| 203 | * |
| 204 | * TODO: We'll need another test that closes first because you can only have |
| 205 | * one file open at a time. |
| 206 | */ |
| 207 | ImageHandlerMock imageMock; |
| 208 | |
| 209 | std::vector<HandlerPack> blobs = { |
| 210 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
| 211 | {"asdf", &imageMock}, |
| 212 | }; |
| 213 | std::vector<DataHandlerPack> data = { |
| 214 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
| 215 | }; |
| 216 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 217 | sdbusplus::SdBusMock sdbus_mock; |
| 218 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 219 | |
| 220 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 221 | std::move(bus_mock), blobs, data); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 222 | |
| 223 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true)); |
| 224 | |
| 225 | EXPECT_TRUE(handler->open( |
| 226 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
| 227 | |
| 228 | /* The active image blob_id was added. */ |
| 229 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 230 | EXPECT_EQ(4, currentBlobs.size()); |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 231 | EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(), |
| 232 | FirmwareBlobHandler::activeImageBlobID)); |
| 233 | |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 234 | /* Close only active session, to verify it's failing on attempt to open a |
| 235 | * specific blob_id. |
| 236 | */ |
Patrick Venture | 68bb143 | 2018-11-09 20:08:48 -0800 | [diff] [blame] | 237 | EXPECT_TRUE(handler->close(0)); |
Patrick Venture | 991910a | 2018-11-09 19:43:48 -0800 | [diff] [blame] | 238 | |
Patrick Venture | 21c62c1 | 2018-11-09 17:46:58 -0800 | [diff] [blame] | 239 | EXPECT_FALSE(handler->open( |
| 240 | 1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, |
| 241 | FirmwareBlobHandler::activeImageBlobID)); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | TEST(FirmwareHandlerOpenTest, OpenWithEverythingValidImageHandlerFails) |
| 245 | { |
| 246 | /* The image handler for a specific type of image is allowed to return |
| 247 | * failure on open. let's simulate that. */ |
| 248 | |
| 249 | ImageHandlerMock imageMock; |
| 250 | |
| 251 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 252 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 253 | {"asdf", &imageMock}, |
| 254 | }; |
| 255 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 256 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 257 | }; |
| 258 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 259 | sdbusplus::SdBusMock sdbus_mock; |
| 260 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 261 | |
| 262 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 263 | std::move(bus_mock), blobs, data); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 264 | |
| 265 | EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(false)); |
| 266 | |
| 267 | EXPECT_FALSE(handler->open( |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 268 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
Patrick Venture | db253bf | 2018-11-09 19:36:03 -0800 | [diff] [blame] | 269 | |
| 270 | /* Verify blob_id list doesn't grow. */ |
| 271 | auto currentBlobs = handler->getBlobIds(); |
Patrick Venture | ffcc550 | 2018-11-16 12:32:38 -0800 | [diff] [blame] | 272 | EXPECT_EQ(3, currentBlobs.size()); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | TEST(FirmwareHandlerOpenTest, OpenWithoutWriteFails) |
| 276 | { |
| 277 | /* The client must set the file write bit. */ |
| 278 | |
| 279 | ImageHandlerMock imageMock; |
| 280 | |
| 281 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 282 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 283 | {"asdf", &imageMock}, |
| 284 | }; |
| 285 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 286 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 287 | }; |
| 288 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 289 | sdbusplus::SdBusMock sdbus_mock; |
| 290 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 291 | |
| 292 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 293 | std::move(bus_mock), blobs, data); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 294 | |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 295 | EXPECT_FALSE( |
| 296 | handler->open(0, FirmwareBlobHandler::UpdateFlags::ipmi, "asdf")); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | TEST(FirmwareHandlerOpenTest, OpenWithInvalidTransportBit) |
| 300 | { |
| 301 | /* The client sends a request with a transport mechanism not supported. */ |
| 302 | |
| 303 | ImageHandlerMock imageMock; |
| 304 | |
| 305 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 306 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 307 | {"asdf", &imageMock}, |
| 308 | }; |
| 309 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 310 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 311 | }; |
| 312 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 313 | sdbusplus::SdBusMock sdbus_mock; |
| 314 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 315 | |
| 316 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 317 | std::move(bus_mock), blobs, data); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 318 | |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 319 | EXPECT_FALSE( |
| 320 | handler->open(0, FirmwareBlobHandler::UpdateFlags::lpc, "asdf")); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | TEST(FirmwareHandlerOpenTest, OpenWithInvalidImageBlobId) |
| 324 | { |
| 325 | /* The client sends a request with an invalid image blob_id. */ |
| 326 | |
| 327 | ImageHandlerMock imageMock; |
| 328 | |
| 329 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 330 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 331 | {"asdf", &imageMock}, |
| 332 | }; |
| 333 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 334 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 335 | }; |
| 336 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 337 | sdbusplus::SdBusMock sdbus_mock; |
| 338 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 339 | |
| 340 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 341 | std::move(bus_mock), blobs, data); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 342 | |
| 343 | EXPECT_FALSE(handler->open( |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 344 | 0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "bcdf")); |
Patrick Venture | 72388d7 | 2018-11-07 15:06:36 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | /* TODO: The client sends a request during verification. */ |
| 348 | /* TODO: The client sends a second request to open when there is already an open |
| 349 | * file. |
| 350 | */ |
| 351 | /* TODO: The client sends a request to open active image. */ |
| 352 | /* TODO: The client sends a request to open active hash. */ |
| 353 | |
| 354 | } // namespace blobs |