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.
17 #ifndef SECURITY_MANAGER_TEST_INSTALLREQUEST
18 #define SECURITY_MANAGER_TEST_INSTALLREQUEST
22 #include <sys/types.h>
26 #include <security-manager.h>
28 namespace SecurityManagerTest {
30 void prepare_request(InstallRequest &request,
31 const char *const app_id,
32 const char *const pkg_id,
33 app_install_path_type pathType,
34 const char *const path,
40 InstallRequest(const InstallRequest&) = delete;
41 InstallRequest& operator=(const InstallRequest&) = delete;
42 InstallRequest(InstallRequest &&other)
43 : m_req(std::move(other.m_req)),
44 m_appId(std::move(other.m_appId)),
45 m_pkgId(std::move(other.m_pkgId)),
46 m_authorId(std::move(other.m_authorId)),
47 m_privileges(std::move(other.m_privileges)),
48 m_paths(std::move(other.m_paths)),
49 m_uid(std::move(other.m_uid))
51 other.m_req = nullptr;
52 other.m_uid.first = false;
53 other.m_uid.second = 0;
57 void setAppTizenVersion(std::string tizenVer,
58 lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
59 void setAppId(std::string appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
60 void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
61 void addPrivilege(const char *privilege, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
62 void addPath(std::string path, app_install_path_type pathType,
63 lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
64 void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
65 void setAuthorId(std::string authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS);
66 void setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
68 std::string getAppTizenVersion() const { return m_tizenVer; }
69 app_inst_req *get() { return m_req; }
70 const app_inst_req *get() const { return m_req; }
71 friend std::ostream& operator<<(std::ostream &, const InstallRequest&);
76 std::string m_tizenVer;
79 std::string m_authorId;
80 std::vector<std::string> m_privileges;
81 std::vector<std::pair<std::string, app_install_path_type> > m_paths;
82 std::pair<bool, uid_t> m_uid;
85 std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::InstallRequest &request);
91 PathsRequest(const PathsRequest&) = delete;
92 PathsRequest& operator=(const PathsRequest&) = delete;
95 void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
96 void addPath(std::string path, app_install_path_type pathType,
97 lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
98 void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
99 void setInstallType(const enum app_install_type &type, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
101 //app_inst_req *get() { return m_req; }
102 const path_req *get() const { return m_req; }
103 friend std::ostream& operator<<(std::ostream &, const PathsRequest&);
109 std::vector<std::pair<std::string, app_install_path_type> > m_paths;
110 std::pair<bool, uid_t> m_uid;
113 std::ostream& operator<<(std::ostream &os, const SecurityManagerTest::PathsRequest &request);
115 } // namespace SecurityManagerTest
117 #endif // SECURITY_MANAGER_TEST_INSTALLREQUEST