Make set properties return 200 Success not 204
Both 200 and 204 are allowed by the Redfish specification. Table 11
states:
200 OK Success, and the action's schema definition does not contain an
action response.
204 No Content: Success, and the action's schema definition does not
contain an action response.
While both of these are allowed, we accidentally changed behavior in the
following commit:
87c4496 Move to Redfish setProperty call
When we transitioned these over to the common dbus calling methods.
This commit restores the old behavior of returning 200 success on
actions, which some implementations are expecting.
Tested: WIP.
Change-Id: I02e47585acf85bd04dcb9d428ef3e39a21d9c75f
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/src/utils/dbus_utils.cpp b/redfish-core/src/utils/dbus_utils.cpp
index f30e6ed..b59088a 100644
--- a/redfish-core/src/utils/dbus_utils.cpp
+++ b/redfish-core/src/utils/dbus_utils.cpp
@@ -83,10 +83,10 @@
messages::internalError(asyncResp->res);
return;
}
- // Only set 204 if another error hasn't already happened.
+ // Only set success if another error hasn't already happened.
if (asyncResp->res.result() == boost::beast::http::status::ok)
{
- asyncResp->res.result(boost::beast::http::status::no_content);
+ messages::success(asyncResp->res);
}
};
@@ -130,10 +130,10 @@
messages::internalError(asyncResp->res);
return;
}
- // Only set 204 if another error hasn't already happened.
+ // Only set success if another error hasn't already happened.
if (asyncResp->res.result() == boost::beast::http::status::ok)
{
- asyncResp->res.result(boost::beast::http::status::no_content);
+ messages::success(asyncResp->res);
}
};
} // namespace details
diff --git a/test/redfish-core/include/utils/dbus_utils.cpp b/test/redfish-core/include/utils/dbus_utils.cpp
index 744a1cd..bcd37da 100644
--- a/test/redfish-core/include/utils/dbus_utils.cpp
+++ b/test/redfish-core/include/utils/dbus_utils.cpp
@@ -29,8 +29,20 @@
afterSetProperty(asyncResp, "MyRedfishProperty",
nlohmann::json("MyRedfishValue"), ec, msg);
- EXPECT_EQ(asyncResp->res.result(), boost::beast::http::status::no_content);
- EXPECT_TRUE(asyncResp->res.jsonValue.empty());
+ EXPECT_EQ(asyncResp->res.result(), boost::beast::http::status::ok);
+ EXPECT_EQ(asyncResp->res.jsonValue,
+ R"({
+ "@Message.ExtendedInfo": [
+ {
+ "@odata.type": "#Message.v1_1_1.Message",
+ "Message": "The request completed successfully.",
+ "MessageArgs": [],
+ "MessageId": "Base.1.18.1.Success",
+ "MessageSeverity": "OK",
+ "Resolution": "None."
+ }
+ ]
+ })"_json);
}
TEST(DbusUtils, AfterPropertySetInternalError)