diff options
author | Carson Labrado <clabrado@google.com> | 2023-03-17 23:27:00 +0300 |
---|---|---|
committer | Carson Labrado <clabrado@google.com> | 2023-03-28 02:16:43 +0300 |
commit | b27e1cbefc2a12a838de209decb7e22b5ba1b2c0 (patch) | |
tree | bb4eadf383f4e988c297d90bccec0d487931f77a /test/redfish-core | |
parent | 0ed80c8ce93a38eca6951ffad5c3143a3a720053 (diff) | |
download | bmcweb-b27e1cbefc2a12a838de209decb7e22b5ba1b2c0.tar.xz |
Aggregation: Prefix fix HttpHeaders property
The "HttpHeaders" property in a response is an array of HTTP headers. We
perform prefix fixing on the "Location" header from responses so we
should also fix any "Location" headers which are contained by
"HttpHeaders" in an aggregated response. This requires special handling
since each header is represented as a single string in the response.
Added testcase for HttpHeaders property
Tested:
All unit tests pass
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: I3040c4ea52b2bebcb6e206bb50585c6a75538f0a
Diffstat (limited to 'test/redfish-core')
-rw-r--r-- | test/redfish-core/include/redfish_aggregator_test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/redfish-core/include/redfish_aggregator_test.cpp b/test/redfish-core/include/redfish_aggregator_test.cpp index 838e5edf6b..2fdd784d3b 100644 --- a/test/redfish-core/include/redfish_aggregator_test.cpp +++ b/test/redfish-core/include/redfish_aggregator_test.cpp @@ -206,6 +206,39 @@ TEST(addPrefixes, ParseJsonObjectNestedArray) "/redfish/v1/Chassis/5B42_TestChassis"); } +TEST(addPrefixes, FixHttpHeadersInResponseBody) +{ + nlohmann::json taskResp = nlohmann::json::parse(R"( + { + "@odata.id": "/redfish/v1/TaskService/Tasks/0", + "Name": "Task 0", + "Payload": { + "HttpHeaders": [ + "User-Agent: curl/7.87.0", + "Accept: */*", + "Host: 127.127.12.7", + "Content-Length: 33", + "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/0" + ] + }, + "PercentComplete": 100, + "TaskMonitor": "/redfish/v1/TaskService/Tasks/0/Monitor", + "TaskState": "Completed", + "TaskStatus": "OK" + } + )", + nullptr, false); + + addPrefixes(taskResp, "5B247A"); + EXPECT_EQ(taskResp["@odata.id"], "/redfish/v1/TaskService/Tasks/5B247A_0"); + EXPECT_EQ(taskResp["TaskMonitor"], + "/redfish/v1/TaskService/Tasks/5B247A_0/Monitor"); + nlohmann::json& httpHeaders = taskResp["Payload"]["HttpHeaders"]; + EXPECT_EQ( + httpHeaders[4], + "Location: /redfish/v1/Managers/5B247A_bmc/LogServices/Dump/Entries/0"); +} + // Attempts to perform prefix fixing on a response with response code "result". // Fixing should always occur void assertProcessResponse(unsigned result) |