| #ifndef THIRD_PARTY_GBMCWEB_TEST_REDFISH_CORE_LIB_SNAPSHOT_FIXTURE_H_ |
| #define THIRD_PARTY_GBMCWEB_TEST_REDFISH_CORE_LIB_SNAPSHOT_FIXTURE_H_ |
| |
| #include <memory> |
| #include <string> |
| #include <system_error> // NOLINT |
| |
| #include <gtest/gtest.h> |
| #include "app.hpp" |
| #include "http_request.hpp" |
| #include "async_resp.hpp" |
| #include "managed_store.hpp" |
| #include "test/g3/mock_managed_store_test.hpp" |
| |
| // In g3, we get the snapshots from source code to run blaze tests. |
| // In GoB, we get the snapshot path from meson_options.txt for meson tests. |
| // The SNAPSHOT_FIXTURE_G3 macro is used to determine which path to use. |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| #include "devtools/build/runtime/get_runfiles_dir.h" |
| #else |
| #include "bmcweb_config.h" |
| #endif // SNAPSHOT_FIXTURE_G3 |
| |
| namespace redfish { |
| |
| class SnapshotFixture : public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath = ::devtools_build::GetDataDependencyFilepath( |
| "google3/third_party/openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform11_0_2024_08_22.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& body = "") { |
| boost::beast::http::request<boost::beast::http::string_body> reqIn; |
| reqIn.set(boost::beast::http::field::content_type, "application/json"); |
| std::error_code ec; |
| crow::Request req(reqIn, ec); |
| req.req.body() = body; |
| return req; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform22 : public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform22() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform22 = |
| ::devtools_build::GetDataDependencyFilepath("google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform22_0_2024_08_13.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform22)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& reqIn = "") { |
| // Dont need this error code ever |
| std::error_code ec; |
| return {reqIn, ec}; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform23 : public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform23() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform23 = |
| ::devtools_build::GetDataDependencyFilepath("google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform23_0_2025_06_11.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform23)); |
| } |
| |
| static crow::Request CreateRequest(const std::string& body = "") { |
| boost::beast::http::request<boost::beast::http::string_body> reqIn; |
| reqIn.set(boost::beast::http::field::content_type, "application/json"); |
| std::error_code ec; |
| crow::Request req(reqIn, ec); |
| req.req.body() = body; |
| return req; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform11_Config4 : |
| public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform11_Config4() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform11_config4 = |
| ::devtools_build::GetDataDependencyFilepath( "google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform11_4_2024_09_20.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform11_config4)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& reqIn = "") { |
| // Dont need this error code ever |
| std::error_code ec; |
| return {reqIn, ec}; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform5_Config7 : |
| public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform5_Config7() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform5_config7 = |
| ::devtools_build::GetDataDependencyFilepath("google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform5_7_2024_11_26.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform5_config7)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& reqIn = "") { |
| // Dont need this error code ever |
| std::error_code ec; |
| return {reqIn, ec}; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform5_Config0 : |
| public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform5_Config0() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| }; |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform5_config0 = |
| ::devtools_build::GetDataDependencyFilepath("google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform5_0_2025_05_13.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform5_config0)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& reqIn = ""){ |
| // Dont need this error code ever |
| std::error_code ec; |
| return {reqIn, ec}; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| class SnapshotFixture_Platform11_Config8 : |
| public ::managedStore::MockManagedStoreTest { |
| protected: |
| SnapshotFixture_Platform11_Config8() : app_(false) { |
| share_async_resp_ = std::make_shared<bmcweb::AsyncResp>(); |
| } |
| |
| static void SetUpTestSuite() { |
| // Have to manually call this as defining this current function prevents |
| // its parent's Setup from being called |
| ::managedStore::MockManagedStoreTest::SetUpTestSuite(); |
| #ifdef SNAPSHOT_FIXTURE_G3 |
| std::string snapshotFilepath_platform11_config8 = |
| ::devtools_build::GetDataDependencyFilepath("google3/third_party/" |
| "openbmc_build_scripts/additional/" |
| "scrubbed_gBMCwebManagedStore_platform11_0_2025_11_27.json"); |
| #endif // SNAPSHOT_FIXTURE_G3 |
| EXPECT_TRUE(managedStore::GetManagedObjectStore()->deserialize( |
| snapshotFilepath_platform11_config8)); |
| } |
| |
| // Use this to create a crow request for use in handlers |
| static crow::Request CreateRequest(const std::string& reqIn = "") { |
| // Dont need this error code ever |
| std::error_code ec; |
| return {reqIn, ec}; |
| } |
| |
| std::shared_ptr<bmcweb::AsyncResp> share_async_resp_; |
| App app_; |
| }; |
| |
| } // namespace redfish |
| |
| #endif // THIRD_PARTY_GBMCWEB_TEST_REDFISH_CORE_LIB_SNAPSHOT_FIXTURE_H_ |