| #include "update_service.hpp" |
| |
| #include <unordered_set> |
| #include <string_view> |
| |
| #include "snapshot_fixture.hpp" |
| |
| #include <gmock/gmock.h> |
| #include <gtest/gtest.h> |
| |
| namespace redfish |
| { |
| |
| using ::testing::Contains; |
| using ::testing::NotNull; |
| |
| |
| TEST_F(SnapshotFixture_Platform11_Config4, |
| UpdateServiceCollectionReturnsExpectedResponse) |
| { |
| handleSoftwareInventoryCollectionGet( |
| app_, CreateRequest(), share_async_resp_); |
| |
| RunIoUntilDone(); |
| |
| nlohmann::json& json = share_async_resp_->res.jsonValue; |
| EXPECT_EQ(json["@odata.id"], "/redfish/v1/UpdateService/FirmwareInventory"); |
| EXPECT_EQ(json["@odata.type"], "#SoftwareInventoryCollection.SoftwareInventoryCollection"); |
| EXPECT_EQ(json["Name"], "Software Inventory Collection"); |
| EXPECT_EQ(json["Members"].size(), json["Members@odata.count"]); |
| |
| const std::unordered_set<std::string> firmware_members {{ |
| "/redfish/v1/UpdateService/FirmwareInventory/bios_active", |
| "/redfish/v1/UpdateService/FirmwareInventory/cpld_1", |
| "/redfish/v1/UpdateService/FirmwareInventory/cpld_2", |
| "/redfish/v1/UpdateService/FirmwareInventory/cpld_3", |
| "/redfish/v1/UpdateService/FirmwareInventory/cpld_4", |
| "/redfish/v1/UpdateService/FirmwareInventory/fru_eeprom_1", |
| "/redfish/v1/UpdateService/FirmwareInventory/fru_eeprom_2", |
| "/redfish/v1/UpdateService/FirmwareInventory/fru_eeprom_3", |
| "/redfish/v1/UpdateService/FirmwareInventory/fru_eeprom_4", |
| "/redfish/v1/UpdateService/FirmwareInventory/morristown_1", |
| "/redfish/v1/UpdateService/FirmwareInventory/morristown_2", |
| "/redfish/v1/UpdateService/FirmwareInventory/morristown_3", |
| "/redfish/v1/UpdateService/FirmwareInventory/morristown_4", |
| "/redfish/v1/UpdateService/FirmwareInventory/config1_temporary_efuse_enable_1", |
| "/redfish/v1/UpdateService/FirmwareInventory/config1_temporary_efuse_enable_2", |
| "/redfish/v1/UpdateService/FirmwareInventory/config1_temporary_efuse_enable_3", |
| "/redfish/v1/UpdateService/FirmwareInventory/config1_temporary_efuse_enable_4", |
| "/redfish/v1/UpdateService/FirmwareInventory/f203a9c8", |
| "/redfish/v1/UpdateService/FirmwareInventory/hoth_ro", |
| "/redfish/v1/UpdateService/FirmwareInventory/hoth_rw" |
| }}; |
| |
| EXPECT_EQ(json["Members@odata.count"], firmware_members.size()); |
| for (const auto& member : json["Members"]) |
| { |
| ASSERT_TRUE(member.contains("@odata.id")); |
| const std::string* firmware = member["@odata.id"].get_ptr<const std::string*>(); |
| ASSERT_THAT(firmware, NotNull()); |
| EXPECT_THAT(firmware_members, Contains(*firmware)); |
| } |
| } |
| |
| TEST_F(SnapshotFixture_Platform11_Config4, |
| CpldUpdateServiceReturnsExpectedResponse) |
| { |
| handleSoftwareInventoryGet(app_, |
| CreateRequest(), share_async_resp_, |
| "cpld_1"); |
| |
| RunIoUntilDone(); |
| |
| nlohmann::json& json = share_async_resp_->res.jsonValue; |
| EXPECT_EQ(json["@odata.id"], "/redfish/v1/UpdateService/FirmwareInventory/cpld_1"); |
| EXPECT_EQ(json["@odata.type"], "#SoftwareInventory.v1_3_0.SoftwareInventory"); |
| EXPECT_EQ(json["Description"], "Other image"); |
| EXPECT_EQ(json["Id"], "cpld_1"); |
| EXPECT_EQ(json["Name"], "Software Inventory"); |
| EXPECT_EQ(json["RelatedItem"].size(), json["RelatedItem@odata.count"]); |
| EXPECT_EQ(json["RelatedItem"][0]["@odata.id"], "/redfish/v1/Systems/system/Storage/config1_storage_1/Controllers/cpld"); |
| EXPECT_EQ(json["Status"]["HealthRollup"], "OK"); |
| EXPECT_FALSE(json["Updateable"]); |
| EXPECT_EQ(json["Version"], "Version"); |
| } |
| |
| TEST_F(SnapshotFixture_Platform11_Config4, |
| FruEepromUpdateServiceReturnsExpectedResponse) |
| { |
| handleSoftwareInventoryGet(app_, |
| CreateRequest(), share_async_resp_, |
| "fru_eeprom_1"); |
| |
| RunIoUntilDone(); |
| |
| nlohmann::json& json = share_async_resp_->res.jsonValue; |
| EXPECT_EQ(json["@odata.id"], "/redfish/v1/UpdateService/FirmwareInventory/fru_eeprom_1"); |
| EXPECT_EQ(json["@odata.type"], "#SoftwareInventory.v1_3_0.SoftwareInventory"); |
| EXPECT_EQ(json["Description"], "Other image"); |
| EXPECT_EQ(json["Id"], "fru_eeprom_1"); |
| EXPECT_EQ(json["Name"], "Software Inventory"); |
| EXPECT_EQ(json["RelatedItem"].size(), json["RelatedItem@odata.count"]); |
| EXPECT_EQ(json["RelatedItem"][0]["@odata.id"], "/redfish/v1/Chassis/config1_1/Drives/config1_1"); |
| EXPECT_EQ(json["Status"]["HealthRollup"], "OK"); |
| EXPECT_FALSE(json["Updateable"]); |
| EXPECT_EQ(json["Version"], "Version"); |
| EXPECT_TRUE(json["WriteProtected"]); |
| } |
| |
| } |
| |