firmware: tie implementation of session into write

To demonstrate how session will work, implement the write command.
Everything isn't wired up with open(), therefore this code itself will
only work in isolation.

This requires wiring up the open command to verify write will use the
handler we specify.

Change-Id: Icf5cfad4ddb531bc271642e24d505cbb9abf8f22
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/firmware_handler_unittest.cpp b/test/firmware_handler_unittest.cpp
index 6a1ffe6..e6998c1 100644
--- a/test/firmware_handler_unittest.cpp
+++ b/test/firmware_handler_unittest.cpp
@@ -24,14 +24,16 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
+        {FirmwareBlobHandler::hashBlobID, &imageMock},
         {"asdf", &imageMock},
     };
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, {});
     EXPECT_EQ(handler, nullptr);
 }
-TEST(FirmwareHandlerTest, CreateEmptyListVerifyHasHash)
+TEST(FirmwareHandlerTest, VerifyHashRequiredForHappiness)
 {
+    /* This works fine only if you also pass in the hash handler. */
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
@@ -42,6 +44,11 @@
     };
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
+    EXPECT_EQ(handler, nullptr);
+
+    blobs.push_back({FirmwareBlobHandler::hashBlobID, &imageMock});
+
+    handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
     auto result = handler->getBlobIds();
     EXPECT_EQ(2, result.size());
     EXPECT_EQ(2, std::count(result.begin(), result.end(), "asdf") +