summaryrefslogtreecommitdiff
path: root/redfish-core/lib/roles.hpp
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2018-03-06 05:20:01 +0300
committerEd Tanous <ed.tanous@intel.com>2018-03-28 00:02:27 +0300
commit3ebd75f75e769532bb5bfa53d1acc81655a26ef0 (patch)
tree6e7e3b08020da7e65b08dbb0c105fe165aa821e0 /redfish-core/lib/roles.hpp
parent4cbda89b8d59b4647dce6215dab8c683725e7c2d (diff)
downloadbmcweb-3ebd75f75e769532bb5bfa53d1acc81655a26ef0.tar.xz
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>
Diffstat (limited to 'redfish-core/lib/roles.hpp')
-rw-r--r--redfish-core/lib/roles.hpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index f1a1c61b84..fc804c204a 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -19,27 +19,10 @@
namespace redfish {
-static OperationMap roleOpMap = {
- {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 roleCollectionOpMap = {
- {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 Roles : public Node {
public:
Roles(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(roleOpMap)),
- "/redfish/v1/AccountService/Roles/Administrator/") {
+ : Node(app, "/redfish/v1/AccountService/Roles/Administrator/") {
Node::json["@odata.id"] = "/redfish/v1/AccountService/Roles/Administrator";
Node::json["@odata.type"] = "#Role.v1_0_2.Role";
Node::json["@odata.context"] = "/redfish/v1/$metadata#Role.Role";
@@ -51,6 +34,12 @@ class Roles : public Node {
"ConfigureUsers", "ConfigureSelf",
"ConfigureComponents"};
Node::json["OemPrivileges"] = 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, {{"ConfigureManager"}}}};
}
private:
@@ -64,8 +53,7 @@ class Roles : public Node {
class RoleCollection : public Node {
public:
RoleCollection(CrowApp& app)
- : Node(app, EntityPrivileges(std::move(roleCollectionOpMap)),
- "/redfish/v1/AccountService/Roles/") {
+ : Node(app, "/redfish/v1/AccountService/Roles/") {
Node::json["@odata.id"] = "/redfish/v1/AccountService/Roles";
Node::json["@odata.type"] = "#RoleCollection.RoleCollection";
Node::json["@odata.context"] =
@@ -75,6 +63,13 @@ class RoleCollection : public Node {
Node::json["Members@odata.count"] = 1;
Node::json["Members"] = {
{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}};
+
+ 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: