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/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 4225cc1..326d5e0 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -20,41 +20,23 @@
namespace redfish {
-static OperationMap sessionOpMap = {
- {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 sessionCollectionOpMap = {
- {crow::HTTPMethod::GET, {{"Login"}}},
- {crow::HTTPMethod::HEAD, {{"Login"}}},
- {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
- {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
- {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
- {crow::HTTPMethod::POST, {{}}}};
-
-static OperationMap sessionServiceOpMap = {
- {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 SessionCollection;
class Sessions : public Node {
public:
Sessions(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(sessionOpMap)),
- "/redfish/v1/SessionService/Sessions/<str>", std::string()) {
+ : Node(app, "/redfish/v1/SessionService/Sessions/<str>", std::string()) {
Node::json["@odata.type"] = "#Session.v1_0_2.Session";
Node::json["@odata.context"] = "/redfish/v1/$metadata#Session.Session";
Node::json["Name"] = "User Session";
Node::json["Description"] = "Manager User Session";
+
+ 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:
@@ -112,9 +94,7 @@
class SessionCollection : public Node {
public:
SessionCollection(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(sessionCollectionOpMap)),
- "/redfish/v1/SessionService/Sessions/"),
- memberSession(app) {
+ : Node(app, "/redfish/v1/SessionService/Sessions/"), memberSession(app) {
Node::json["@odata.type"] = "#SessionCollection.SessionCollection";
Node::json["@odata.id"] = "/redfish/v1/SessionService/Sessions/";
Node::json["@odata.context"] =
@@ -123,6 +103,13 @@
Node::json["Description"] = "Session Collection";
Node::json["Members@odata.count"] = 0;
Node::json["Members"] = nlohmann::json::array();
+
+ entityPrivileges = {{crow::HTTPMethod::GET, {{"Login"}}},
+ {crow::HTTPMethod::HEAD, {{"Login"}}},
+ {crow::HTTPMethod::PATCH, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::PUT, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::DELETE, {{"ConfigureManager"}}},
+ {crow::HTTPMethod::POST, {}}};
}
private:
@@ -243,9 +230,7 @@
class SessionService : public Node {
public:
- SessionService(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(sessionServiceOpMap)),
- "/redfish/v1/SessionService/") {
+ SessionService(CrowApp& app) : Node(app, "/redfish/v1/SessionService/") {
Node::json["@odata.type"] = "#SessionService.v1_0_2.SessionService";
Node::json["@odata.id"] = "/redfish/v1/SessionService/";
Node::json["@odata.context"] =
@@ -258,6 +243,13 @@
Node::json["Status"]["Health"] = "OK";
Node::json["Status"]["HealthRollup"] = "OK";
Node::json["ServiceEnabled"] = true;
+
+ 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: