2 * Copyright (c) 2014-2016 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.
19 * @author Marcin Lis (m.lis@samsung.com)
21 * @brief security-manager tests database record check functions
24 #ifndef SECURITY_MANAGER_TEST_DB_H_
25 #define SECURITY_MANAGER_TEST_DB_H_
28 #include "db_sqlite.h"
30 typedef std::vector<std::string> privileges_t;
33 * @class TestSecurityManagerDatabase
34 * @brief Class containing methods for testing libprivlege database.
36 class TestSecurityManagerDatabase
40 * @brief A usefull constant to indicate that app/pkg should be present in db
42 const static bool NOT_REMOVED;
44 * @brief A usefull constant to indicate that app/pkg should not be present in db
46 const static bool REMOVED;
48 * @brief A constructor
50 TestSecurityManagerDatabase();
55 ~TestSecurityManagerDatabase() = default;
58 * @brief Method for testing database after "security_manager_app_install" was run.
60 * It checks existence of proper: - app_name
63 * @param app_name name of the app previously used in security_manager_app_install.
64 * @param pkg_name name of the pkg previously used in security_manager_app_install.
66 void test_db_after__app_install(const std::string &app_name, const std::string &pkg_name);
69 * @brief Method for testing database after "security_manager_app_uninstall" was run.
71 * It checks absence of proper: - app_name
72 * - optionally pkg_name
74 * @param app_name name of the app previously used in security_manager_app_uninstall.
75 * @param pkg_name name of the pkg previously used in security_manager_app_uninstall.
76 * @param is_pkg_removed tells if pkg_id is expected to remain in db or not.
78 void test_db_after__app_uninstall(const std::string &app_name, const std::string &pkg_name,
79 const bool is_pkg_removed);
82 * @brief Method for setting privilege to groups mapping in security-manager database
84 * @param privilege name of the privilege
85 * @param groups vector of group names
87 void setup_privilege_groups(const std::string &privilege,
88 const std::vector<std::string> &groups);
91 * @brief Method for getting author id from database.
93 int64_t get_author_id(const std::string &authorName);
95 * @brief Method for path label from database.
97 std::string get_path_label(const std::string &path);
101 * @brief Sqlite3DBase object giving simple access to database
103 * Connection to database is open first time it is needed
104 * and closed in destructor of TestSecurityManagerDatabase.
109 * @brief Check db for [non]existence of given app_name in pkg_name
111 * @param app_name name of application
112 * @param pkg_name name of package
113 * @param is_app_removed tells if app is expected in db
115 void check_app_and_pkg(const std::string &app_name, const std::string &pkg_name,
116 const bool is_app_removed);
119 * @brief Check db for [non]existence of given pkg_name
121 * @param pkg_name name of the package
122 * @param is_pkg_removed tells if pkg is expected in db
124 void check_pkg(const std::string &pkg_name,
125 const bool is_pkg_removed);
128 #endif /* SECURITY_MANAGER_TEST_DB_H_ */