3e62c1fe875967376ddec15f1420839a6a815da9
[platform/core/test/security-tests.git] / tests / common / temp_test_user.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15 */
16
17 #ifndef TEMP_TEST_USER_H
18 #define TEMP_TEST_USER_H
19
20 #include <string>
21 #include <sys/types.h>
22 #include <gum-user.h>
23 #include <common/gum-user-types.h>
24
25 class TemporaryTestUser {
26 public:
27     TemporaryTestUser() = delete;
28     TemporaryTestUser(std::string userName, GumUserType userType, bool offline) :
29             m_uid(0),
30             m_gid(0),
31             m_userName(userName),
32             m_userType(userType),
33             m_guser(nullptr),
34             m_offline(offline)
35             {};
36     ~TemporaryTestUser();
37     void remove(void);
38     uid_t getUid() const {return m_uid;}
39     uid_t getGid() const {return m_gid;}
40     void create(void);
41     const std::string& getUserName() const {return m_userName;}
42     GumUserType getUserType() const {return m_userType;}
43 private:
44     uid_t m_uid;
45     uid_t m_gid;
46     std::string m_userName;
47     GumUserType m_userType;
48     GumUser *m_guser;
49     bool m_offline;
50 };
51
52 #endif