2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef SECURITY_MANAGER_TEST_POLICYREQUEST
18 #define SECURITY_MANAGER_TEST_POLICYREQUEST
21 #include <sys/types.h>
25 #include <security-manager.h>
27 namespace SecurityManagerTest {
34 PolicyEntry(const std::string &appId,
35 const std::string &user,
36 const std::string &privilege
40 PolicyEntry(policy_entry &entry);
42 policy_entry *get() const { return m_entry; }
43 std::string getUser() const { return m_user.second; }
44 std::string getAppId() const { return m_appId.second; }
45 std::string getPrivilege() const { return m_privilege.second; }
46 std::string getCurrentLevel() const { return m_currentLevel.second; }
47 std::string getMaxLevel() const { return m_maxLevel.second; }
48 void setLevel(const std::string &level);
49 void setMaxLevel(const std::string &level);
52 friend std::ostream& operator<<(std::ostream &, const PolicyEntry&);
53 bool operator==(const PolicyEntry &) const;
54 std::string toString() const;
57 policy_entry *m_entry;
58 std::pair<bool, std::string> m_appId;
59 std::pair<bool, std::string> m_user;
60 std::pair<bool, std::string> m_privilege;
61 std::pair<bool, std::string> m_currentLevel;
62 std::pair<bool, std::string> m_maxLevel;
65 std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyEntry &request);
71 PolicyRequest(const PolicyRequest&) = delete;
72 PolicyRequest& operator=(const PolicyRequest&) = delete;
75 void addEntry(PolicyEntry &entry, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
77 policy_update_req *get() const { return m_req; }
78 friend std::ostream& operator<<(std::ostream &, const PolicyRequest&);
81 policy_update_req *m_req;
82 std::vector<PolicyEntry> m_entries;
85 std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PolicyRequest &request);
87 } // namespace SecurityManagerTest
92 struct hash<SecurityManagerTest::PolicyEntry> {
93 size_t operator()(const SecurityManagerTest::PolicyEntry &x) const { return hash<string>()(x.toString()); }
98 #endif // SECURITY_MANAGER_TEST_USERREQUEST