Make a few changes to privileges commit
1. Create char* overloads for the things that need it.
2. Fix up a couple errant moves
3. Use the gtest APIs for testing container membership, rather than sort
4. Move the index management to vector rather than map to avoid a lookup
5. Remove errant use of .at()
6. Move privilege comparison into the privilege class, in order to keep
the bitset implementation private. This removes the requirment on the
forward declaration of PrivilegeProvider, and the use of friend class
7. Remove unimplemented override strcutures. Feel free to add them
back once implemented
8. Make setSignlePrivilege return a code if the set failed
9. Remove the need for an extra construction of a blank privileges
object for things that require no privileges.
Tested by: updating unit tests with the appropriate APIs. Relevant
unit tests pass
Change-Id: Ie9cde003b6c865979b4cac086379d0a3473896ce
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 0a56da7..ad042cb 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -19,27 +19,9 @@
namespace redfish {
-static OperationMap managerOpMap = {
- {crow::HTTPMethod::GET, {{"Login"}}},
- {crow::HTTPMethod::HEAD, {{"Login"}}},
- {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
- {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
- {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
- {crow::HTTPMethod::POST, {{"ConfigureManager"}}}};
-
-static OperationMap managerCollectionOpMap = {
- {crow::HTTPMethod::GET, {{"Login"}}},
- {crow::HTTPMethod::HEAD, {{"Login"}}},
- {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
- {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
- {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
- {crow::HTTPMethod::POST, {{"ConfigureManager"}}}};
-
class Manager : public Node {
public:
- Manager(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(managerOpMap)),
- "/redfish/v1/Managers/openbmc/") {
+ Manager(CrowApp& app) : Node(app, "/redfish/v1/Managers/openbmc/") {
Node::json["@odata.id"] = "/redfish/v1/Managers/openbmc";
Node::json["@odata.type"] = "#Manager.v1_3_0.Manager";
Node::json["@odata.context"] = "/redfish/v1/$metadata#Manager.Manager";
@@ -55,6 +37,13 @@
.system_uuid;
Node::json["Model"] = "OpenBmc"; // TODO(ed), get model
Node::json["FirmwareVersion"] = "1234456789"; // TODO(ed), get fwversion
+
+ entityPrivileges = {{crow::HTTPMethod::GET, {{"Login"}}},
+ {crow::HTTPMethod::HEAD, {{"Login"}}},
+ {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::POST, {{"ConfigureManager"}}}};
}
private:
@@ -84,9 +73,7 @@
class ManagerCollection : public Node {
public:
ManagerCollection(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(managerCollectionOpMap)),
- "/redfish/v1/Managers/"),
- memberManager(app) {
+ : Node(app, "/redfish/v1/Managers/"), memberManager(app) {
Node::json["@odata.id"] = "/redfish/v1/Managers";
Node::json["@odata.type"] = "#ManagerCollection.ManagerCollection";
Node::json["@odata.context"] =
@@ -94,6 +81,13 @@
Node::json["Name"] = "Manager Collection";
Node::json["Members@odata.count"] = 1;
Node::json["Members"] = {{"@odata.id", "/redfish/v1/Managers/openbmc"}};
+
+ entityPrivileges = {{crow::HTTPMethod::GET, {{"Login"}}},
+ {crow::HTTPMethod::HEAD, {{"Login"}}},
+ {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::POST, {{"ConfigureManager"}}}};
}
private: