--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/*
+ * @file temp_test_user.cpp
+ * @author Jan Cybulski (j.cybulski@partner.samsung.com)
+ * @version 1.0
+ * @brief File with class for users management
+ */
+
+
+#include <temp_test_user.h>
+#include <glib-object.h>
+#include <dpl/test/test_runner.h>
+
+TemporaryTestUser::TemporaryTestUser(std::string userName, GumUserType userType, bool offline) {
+ m_userName = userName;
+ m_id = 0;
+ m_userType = userType;
+ m_guser = gum_user_create_sync (offline);
+ RUNNER_ASSERT_MSG(m_guser != nullptr, "Failed to create gumd user object");
+ g_object_set(G_OBJECT(m_guser), "usertype", userType, NULL);
+ g_object_set(G_OBJECT(m_guser), "username", userName.c_str(), NULL);
+ gboolean added = gum_user_add_sync(m_guser);
+ RUNNER_ASSERT_MSG(added, "Failed to add user");
+ g_object_get(G_OBJECT(m_guser), "uid", &m_id, NULL);
+ RUNNER_ASSERT_MSG(m_id != 0, "Something strange happened during user creation");
+}
+
+void TemporaryTestUser::remove(void) {
+ if(m_guser){
+ gum_user_delete_sync(m_guser, TRUE);
+ g_object_unref(m_guser);
+ m_guser = nullptr;
+ }
+}
+
+TemporaryTestUser::~TemporaryTestUser() {
+ this->remove();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef TEMP_TEST_USER_H
+#define TEMP_TEST_USER_H
+
+#include <string>
+#include <sys/types.h>
+#include <gum-user.h>
+#include <common/gum-user-types.h>
+
+class TemporaryTestUser {
+public:
+ TemporaryTestUser(std::string userName, GumUserType userType, bool offline);
+ ~TemporaryTestUser();
+ void remove(void);
+ uid_t getUid() const {return m_id;}
+ const std::string& getUserName() const {return m_userName;}
+ GumUserType getUserType() const {return m_userType;}
+private:
+ uid_t m_id;
+ std::string m_userName;
+ GumUserType m_userType;
+ GumUser *m_guser;
+
+};
+
+#endif