Add convenience method for getting users's uid converted to string 78/34578/10
authorJan Cybulski <j.cybulski@samsung.com>
Thu, 29 Jan 2015 08:24:19 +0000 (09:24 +0100)
committerRafal Krypa <r.krypa@samsung.com>
Mon, 2 Mar 2015 14:49:11 +0000 (15:49 +0100)
Change-Id: I7229a746d3ddfa28f93aef3bb21c6bc56b8d9ccf
Signed-off-by: Jan Cybulski <j.cybulski@samsung.com>
tests/common/temp_test_user.h
tests/security-manager-tests/security_manager_tests.cpp

index 3e62c1fe875967376ddec15f1420839a6a815da9..120b21b883212c462a6cc2c11f69553c07c36a79 100644 (file)
@@ -38,6 +38,7 @@ public:
     uid_t getUid() const {return m_uid;}
     uid_t getGid() const {return m_gid;}
     void create(void);
+    void getUidString(std::string& uidstr) const {uidstr =  std::to_string(static_cast<unsigned int>(m_uid));}
     const std::string& getUserName() const {return m_userName;}
     GumUserType getUserType() const {return m_userType;}
 private:
index b5af58c1ee364664453457ddc94dcfc9f2cf301a..0478491920843c221bfe373c5e99082f2adf9fb7 100644 (file)
@@ -826,7 +826,7 @@ RUNNER_CHILD_TEST(security_manager_07_user_add_app_install)
     std::string uid_string;
     TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
     test_user.create();
-    uid_string =  std::to_string(static_cast<unsigned int>(test_user.getUid()));
+    test_user.getUidString(uid_string);
 
     install_app(sm_app_id, sm_pkg_id, test_user.getUid());
 
@@ -851,7 +851,7 @@ RUNNER_CHILD_TEST(security_manager_08_user_double_add_double_remove)
     // gumd user add
     TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
     test_user.create();
-    uid_string =  std::to_string(static_cast<unsigned int>(test_user.getUid()));
+    test_user.getUidString(uid_string);
 
     addUserRequest.setUid(test_user.getUid());
     addUserRequest.setUserType(SM_USER_TYPE_NORMAL);
@@ -2069,9 +2069,10 @@ RUNNER_CHILD_TEST(security_manager_10_user_cynara_policy)
     const char *const USER_TYPE_NORMAL_BUCKET = "USER_TYPE_NORMAL";
     const std::string username("sm_test_10_user_cynara_policy");
     CynaraTestAdmin::Admin admin;
+    std::string uid_string;
     TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, true);
     user.create();
-    std::string uid_string =  std::to_string(static_cast<unsigned int>(user.getUid()));
+    user.getUidString(uid_string);
 
     CynaraTestAdmin::CynaraPoliciesContainer nonemptyContainer;
     nonemptyContainer.add(MAIN_BUCKET,CYNARA_ADMIN_WILDCARD, uid_string.c_str(), CYNARA_ADMIN_WILDCARD, CYNARA_ADMIN_BUCKET, USER_TYPE_NORMAL_BUCKET);
@@ -2094,13 +2095,15 @@ RUNNER_CHILD_TEST(security_manager_11_security_manager_cmd_install)
     const std::string app_id = "security_manager_10_app";
     const std::string pkg_id = "security_manager_10_pkg";
     const std::string username("sm_test_10_user_name");
+    std::string uid_string;
     TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, true);
     user.create();
+    user.getUidString(uid_string);
     const std::string path1 = "/home/" + username + "/p1";
     const std::string path2 = "/home/" + username + "/p2";
     const std::string pkgopt = " --pkg=" + pkg_id;
     const std::string appopt = " --app=" + app_id;
-    const std::string uidopt = " --uid=" + std::to_string(static_cast<unsigned int>(user.getUid()));
+    const std::string uidopt = " --uid=" + uid_string;
 
     mkdir(path1.c_str(), 0);
     mkdir(path2.c_str(), 0);
@@ -2141,9 +2144,11 @@ RUNNER_CHILD_TEST(security_manager_12_security_manager_cmd_users)
     const int SUCCESS = 0;
     const int FAILURE = 256;
     const std::string username("sm_test_11_user_name");
+    std::string uid_string;
     TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, true);
     user.create();
-    const std::string uidopt = " --uid=" + std::to_string(static_cast<unsigned int>(user.getUid()));
+    user.getUidString(uid_string);
+    const std::string uidopt = " --uid=" + uid_string;
 
     struct operation {
         std::string command;