blob: 43cc17dc2fe1c3642ec4d9e90ccf13461b5e4b87 [file] [edit]
#include "libbej/bej_decoder_json.hpp"
#include "libbej/bej_encoder_json.hpp"
#include "nlohmann/json.hpp"
#include "rded/helper/rde_operation/rde_update_utils.hpp"
#include <array>
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
#include <gmock/gmock-matchers.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
using ::testing::_;
using ::testing::Eq;
using ::testing::MatcherCast;
using ::testing::Pointee;
using ::testing::Return;
using ::testing::SafeMatcherCast;
using ::testing::StrEq;
std::vector<uint8_t> redfish_annotation_dictionary = {
0x0, 0x0, 0x4a, 0x0, 0x0, 0xf0, 0xf0, 0xf1, 0xf0, 0x6, 0x0, 0x0,
0x0, 0x0, 0x0, 0x16, 0x0, 0x13, 0x0, 0xc, 0xf0, 0x2, 0x10, 0x0,
0x0, 0xd4, 0x0, 0x1, 0x0, 0x16, 0xfc, 0x2, 0x50, 0x1, 0x0, 0x0,
0x0, 0x0, 0x0, 0x14, 0x12, 0x3, 0x10, 0x2, 0x0, 0x2e, 0x1, 0x1,
0x0, 0x19, 0x26, 0x3, 0x0, 0x3, 0x0, 0x38, 0x1, 0x2, 0x0, 0x20,
0x3f, 0x3, 0x0, 0x4, 0x0, 0x4c, 0x1, 0x2, 0x0, 0x1b, 0x5f, 0x3,
0x40, 0x5, 0x0, 0x60, 0x1, 0x5, 0x0, 0x1c, 0x7a, 0x3, 0x0, 0x6,
0x0, 0x92, 0x1, 0x4, 0x0, 0x23, 0x96, 0x3, 0x70, 0x7, 0x0, 0x0,
0x0, 0x0, 0x0, 0x1a, 0xb9, 0x3, 0x70, 0x8, 0x0, 0x0, 0x0, 0x0,
0x0, 0x1a, 0xd3, 0x3, 0x70, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x19,
0xed, 0x3, 0x0, 0xa, 0x0, 0xba, 0x1, 0x6, 0x0, 0x12, 0x6, 0x4,
0x0, 0xb, 0x0, 0xf6, 0x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6, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x41, 0x6e, 0x6e, 0x6f,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0, 0x40, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65,
0x64, 0x49, 0x6e, 0x66, 0x6f, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69,
0x73, 0x68, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66,
0x6f, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x41,
0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75,
0x65, 0x73, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69, 0x73, 0x68, 0x2e,
0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61,
0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x0, 0x40,
0x52, 0x65, 0x64, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x4d, 0x61, 0x69, 0x6e,
0x74, 0x65, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f,
0x77, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x4f,
0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x70, 0x70, 0x6c,
0x79, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69,
0x73, 0x68, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x75, 0x70,
0x70, 0x6f, 0x72, 0x74, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69, 0x73,
0x68, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4f, 0x6e,
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66,
0x69, 0x73, 0x68, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64,
0x4f, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x40, 0x52, 0x65,
0x64, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x6e, 0x6c,
0x79, 0x4f, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x40, 0x52,
0x65, 0x64, 0x66, 0x69, 0x73, 0x68, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69,
0x6e, 0x67, 0x73, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66, 0x69, 0x73, 0x68,
0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x41, 0x70, 0x70,
0x6c, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x40, 0x52, 0x65, 0x64, 0x66,
0x69, 0x73, 0x68, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c,
0x65, 0x41, 0x66, 0x74, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x0, 0x40, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x63, 0x6f, 0x6e, 0x74,
0x65, 0x78, 0x74, 0x0, 0x40, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x0, 0x40, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e,
0x65, 0x74, 0x61, 0x67, 0x0, 0x40, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e,
0x69, 0x64, 0x0, 0x40, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x6e, 0x65,
0x78, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x0, 0x40, 0x6f, 0x64, 0x61, 0x74,
0x61, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x0, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x0, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72,
0x67, 0x73, 0x0, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64,
0x0, 0x4f, 0x65, 0x6d, 0x0, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x0, 0x52,
0x65, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x53, 0x65,
0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x0, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x0, 0x43,
0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x0,
0x4d, 0x61, 0x78, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x0, 0x4d,
0x61, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x57, 0x69,
0x6e, 0x64, 0x6f, 0x77, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x49, 0x6e, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x0, 0x4d, 0x61,
0x69, 0x6e, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x57, 0x69, 0x6e,
0x64, 0x6f, 0x77, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65,
0x0, 0x41, 0x74, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x61, 0x6e,
0x63, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x53, 0x74, 0x61, 0x72,
0x74, 0x0, 0x49, 0x6d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x0,
0x49, 0x6e, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x63,
0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x4f, 0x6e, 0x52, 0x65, 0x73,
0x65, 0x74, 0x0, 0x4f, 0x6e, 0x52, 0x65, 0x73, 0x65, 0x74, 0x0, 0x4f,
0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x0, 0x4d, 0x61, 0x69, 0x6e,
0x74, 0x65, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f,
0x77, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x0, 0x53, 0x75,
0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65,
0x73, 0x0, 0x45, 0x54, 0x61, 0x67, 0x0, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x73, 0x0, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73,
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x0, 0x54, 0x69, 0x6d, 0x65, 0x0,
0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x41, 0x70, 0x70,
0x6c, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x0, 0x41, 0x70, 0x70, 0x6c,
0x79, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63,
0x61, 0x6c, 0x0, 0x4f, 0x4b, 0x0, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e,
0x67, 0x0, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69,
0x65, 0x73, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x0, 0x4c, 0x69, 0x6e,
0x6b, 0x73, 0x0, 0x55, 0x73, 0x65, 0x43, 0x61, 0x73, 0x65, 0x0, 0x52,
0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x0, 0x54,
0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x0, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x72,
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65,
0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x43, 0x6f, 0x6d,
0x70, 0x75, 0x74, 0x65, 0x72, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x43,
0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x65, 0x64, 0x43, 0x6f,
0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x52, 0x65,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x6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0x64, 0x0, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65,
0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x4e, 0x61, 0x6d, 0x65,
0x0, 0x53, 0x65, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x0, 0x53, 0x65,
0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x0, 0x53,
0x65, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x73,
0x0, 0x43, 0x6f, 0x65, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x0, 0x44,
0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x0,
0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x0, 0x50, 0x72, 0x6f,
0x70, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x0, 0x41, 0x75,
0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x0, 0x44, 0x69, 0x73, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x0, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x0,
0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x0, 0x46, 0x72, 0x65,
0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x0, 0x50, 0x6f, 0x77, 0x65, 0x72,
0x0, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65,
0x0, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x0, 0x4d, 0x6f, 0x6e, 0x69,
0x74, 0x6f, 0x72, 0x65, 0x64, 0x0, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61,
0x6d, 0x6d, 0x61, 0x62, 0x6c, 0x65, 0x0, 0x52, 0x61, 0x6e, 0x67, 0x65,
0x0, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x0, 0x0};
std::vector<uint8_t> redfish_update_service_dictionary = {
0x0, 0x1, 0x6, 0x0, 0x0, 0xf0, 0x10, 0xf1, 0x92, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x16, 0x0, 0x5, 0x0, 0xe, 0x48, 0x0, 0x2, 0x2,
0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x56, 0x0, 0x52, 0x3, 0x0, 0x0,
0x0, 0x0, 0x0, 0x3, 0x68, 0x0, 0x52, 0x4, 0x0, 0x0, 0x0, 0x0,
0x0, 0x5, 0x6b, 0x0, 0x74, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf,
0x70, 0x0, 0x36, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x7f, 0x0,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x0, 0x46, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x49, 0x6e,
0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x0, 0x49, 0x64, 0x0, 0x4e,
0x61, 0x6d, 0x65, 0x0, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x0, 0x4d, 0x61, 0x78, 0x49, 0x6d,
0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73,
0x0, 0x0};
class TestRdeUpdateUtils : public ::testing::Test
{
public:
TestRdeUpdateUtils() {}
~TestRdeUpdateUtils() {}
BejDictionaries makeBejDictionaries(const std::vector<uint8_t>& schemaDict)
{
BejDictionaries bejDictionaries{};
bejDictionaries.schemaDictionary = schemaDict.data();
bejDictionaries.schemaDictionarySize = schemaDict.size();
bejDictionaries.annotationDictionary =
redfish_annotation_dictionary.data();
bejDictionaries.annotationDictionarySize =
redfish_annotation_dictionary.size();
bejDictionaries.errorDictionary = nullptr;
bejDictionaries.errorDictionarySize = 0;
return bejDictionaries;
}
};
TEST_F(TestRdeUpdateUtils, inputValidationTest)
{
const std::string redfishReqPayload = "";
std::vector<uint8_t> encodedPayload;
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
// Pass an empty request payload and verify that the API returns error
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqPayload, &control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
-1);
const std::string redfishReqControlPayload = "\"Id\": \"HDD_Setpoint\"";
// Pass a NULL argument for schema dictionary
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlPayload, NULL,
&annotation_dict_ptr, encodedPayload),
-1);
uint8_t* schemaDict = NULL;
// Pass a pointer to NULL pointer of uint8_t type for schemaDict
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlPayload, &schemaDict,
&annotation_dict_ptr, encodedPayload),
-1);
// Pass a NULL argument for annotation dictionary
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlPayload,
&control_dict_ptr, NULL,
encodedPayload),
-1);
uint8_t* annotationDict = NULL;
// Pass a pointer to NULL pointer of uint8_t type for annotationDict
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlPayload,
&control_dict_ptr, &annotationDict,
encodedPayload),
-1);
}
// Try encoding a root level property of type bejString
TEST_F(TestRdeUpdateUtils, encodeBejStringDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_control_dictionary);
std::string redfishReqControlStringPayload = "{\"Id\":\"HDD_Setpoint\"}";
nlohmann::json redfishReqControlStringPayloadJson =
nlohmann::json::parse(redfishReqControlStringPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlStringPayload,
&control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("Id") != decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("Id").value(), "HDD_Setpoint");
}
// Try encoding a property of type bejReal one level above root
TEST_F(TestRdeUpdateUtils, encodeBejRealDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_control_dictionary);
std::string redfishReqControlRealPayload =
"{\"ControlLoop\" : {\"Differential\" : 10.2}}";
nlohmann::json redfishReqControlRealPayloadJson =
nlohmann::json::parse(redfishReqControlRealPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlRealPayload,
&control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("ControlLoop") !=
decodedPayloadJson.end());
nlohmann::json controlLoopJson =
decodedPayloadJson.find("ControlLoop").value();
EXPECT_EQ(controlLoopJson.size(), 1);
EXPECT_EQ(controlLoopJson.find("Differential").value(), 10.2);
}
// Try encoding a property of type bejEnum one level above root
TEST_F(TestRdeUpdateUtils, encodeBejEnumDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_control_dictionary);
std::string redfishReqControlEnumPayload =
"{\"ControlMode\" : \"Automatic\"}";
nlohmann::json redfishReqControlEnumPayloadJson =
nlohmann::json::parse(redfishReqControlEnumPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlEnumPayload,
&control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("ControlMode") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("ControlMode").value(), "Automatic");
}
// Try encoding a property of type bejString, bejRel and bejEnum on multiple
// levels in json
TEST_F(TestRdeUpdateUtils, encodeBejEnumStringRealDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_control_dictionary);
std::string redfishReqControlPayload =
"{\"Id\":\"HDD_Setpoint\", \"ControlMode\" : \"Automatic\", \"ControlLoop\" : {\"Differential\" : 10.2}}";
nlohmann::json redfishReqControlPayloadJson =
nlohmann::json::parse(redfishReqControlPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlPayload,
&control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 3);
EXPECT_TRUE(decodedPayloadJson.find("Id") != decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("Id").value(), "HDD_Setpoint");
EXPECT_TRUE(decodedPayloadJson.find("ControlMode") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("ControlMode").value(), "Automatic");
EXPECT_TRUE(decodedPayloadJson.find("ControlLoop") !=
decodedPayloadJson.end());
nlohmann::json controlLoopJson =
decodedPayloadJson.find("ControlLoop").value();
EXPECT_EQ(controlLoopJson.size(), 1);
EXPECT_EQ(controlLoopJson.find("Differential").value(), 10.2);
}
// Try encoding a root level property of type bejInt
TEST_F(TestRdeUpdateUtils, encodeBejIntDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* update_service_dict_ptr = redfish_update_service_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_update_service_dictionary);
std::string redfishReqUpdateServiceIntPayload =
"{\"MaxImageSizeBytes\": 4536754}";
nlohmann::json redfishReqUpdateServiceIntPayloadJson =
nlohmann::json::parse(redfishReqUpdateServiceIntPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqUpdateServiceIntPayload,
&update_service_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("MaxImageSizeBytes") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("MaxImageSizeBytes").value(), 4536754);
}
// Try encoding a root level property of type bejBool
TEST_F(TestRdeUpdateUtils, encodeBejBoolDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* update_service_dict_ptr = redfish_update_service_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_update_service_dictionary);
std::string redfishReqUpdateServiceBoolPayload =
"{\"ServiceEnabled\": true}";
nlohmann::json redfishReqUpdateServiceBoolPayloadJson =
nlohmann::json::parse(redfishReqUpdateServiceBoolPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqUpdateServiceBoolPayload,
&update_service_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("ServiceEnabled") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("ServiceEnabled").value(), true);
}
// Try encoding a root level property of type bejInt and bejBool
TEST_F(TestRdeUpdateUtils, encodeBejIntBoolDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* update_service_dict_ptr = redfish_update_service_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_update_service_dictionary);
std::string redfishReqUpdateServicePayload =
"{\"MaxImageSizeBytes\": 4536754, \"ServiceEnabled\": true}";
nlohmann::json redfishReqUpdateServicePayloadJson =
nlohmann::json::parse(redfishReqUpdateServicePayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqUpdateServicePayload,
&update_service_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 2);
EXPECT_TRUE(decodedPayloadJson.find("MaxImageSizeBytes") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("MaxImageSizeBytes").value(), 4536754);
EXPECT_TRUE(decodedPayloadJson.find("ServiceEnabled") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("ServiceEnabled").value(), true);
}
// Try encoding a property of type bejNull
TEST_F(TestRdeUpdateUtils, encodeBejNullDataTypeTest)
{
uint8_t* annotation_dict_ptr = redfish_annotation_dictionary.data();
uint8_t* control_dict_ptr = redfish_control_dictionary.data();
BejDictionaries bejDictionaries =
makeBejDictionaries(redfish_control_dictionary);
std::string redfishReqControlNullPayload = "{\"ControlMode\" : null}";
nlohmann::json redfishReqControlNullPayloadJson =
nlohmann::json::parse(redfishReqControlNullPayload);
std::vector<uint8_t> encodedPayload;
EXPECT_THAT(encodePayloadForUpdateOp(redfishReqControlNullPayload,
&control_dict_ptr,
&annotation_dict_ptr, encodedPayload),
0);
libbej::BejDecoderJson decoder;
decoder.decode(bejDictionaries, encodedPayload);
std::string decodedString = decoder.getOutput();
std::cerr << "decodedString : " << decodedString << std::endl;
nlohmann::json decodedPayloadJson = nlohmann::json::parse(decodedString);
EXPECT_EQ(decodedPayloadJson.size(), 1);
EXPECT_TRUE(decodedPayloadJson.find("ControlMode") !=
decodedPayloadJson.end());
EXPECT_EQ(decodedPayloadJson.find("ControlMode").value(), nullptr);
}