Add security_manager_app_inst_req_set_author_id tests 59/57159/5
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 15 Jan 2016 12:38:45 +0000 (13:38 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 29 Jan 2016 14:56:55 +0000 (15:56 +0100)
[Verification] Run security-manager-tests --regexp=security_manager_27

Change-Id: Idd9705f8328cb352039821804dd961bf68a25b49

src/security-manager-tests/common/sm_request.cpp
src/security-manager-tests/common/sm_request.h
src/security-manager-tests/security_manager_tests.cpp

index 7db63b1..65087af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2016 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.
@@ -106,6 +106,21 @@ void InstallRequest::setUid(const uid_t uid, lib_retcode expectedResult)
     m_uid.second = uid;
 }
 
+void InstallRequest::setAuthorId(const char *authorId, lib_retcode expectedResult)
+{
+    m_authorId.clear();
+    if(authorId)
+        m_authorId.assign(authorId);
+
+    int result = security_manager_app_inst_req_set_author_id(m_req, authorId);
+    RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+                      "setting author id returned wrong value."
+                          << " Author id: " << m_authorId << ";"
+                          << " Result: " << result << ";"
+                          << " Expected result: " << expectedResult);
+
+}
+
 std::ostream& operator<<(std::ostream &os, const InstallRequest &request)
 {
     if (request.m_appId != nullptr)
@@ -130,6 +145,9 @@ std::ostream& operator<<(std::ostream &os, const InstallRequest &request)
     }
     if (request.m_uid.first)
         os << "uid: " << request.m_uid.second << "; ";
+    if (!request.m_authorId.empty()) {
+        os << "author id: " << request.m_authorId << "; ";
+    }
     return os;
 }
 
index 52c4d46..9ad4204 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2016 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.
@@ -43,6 +43,7 @@ public:
     void addPath(const char *path, app_install_path_type pathType,
                  lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
     void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+    void setAuthorId(const char *authorId, lib_retcode expectedResult= SECURITY_MANAGER_SUCCESS);
 
     std::string getAppTizenVersion() const { return m_tizenVer; }
     const app_inst_req *get() const { return m_req; }
@@ -54,6 +55,7 @@ private:
     std::string m_tizenVer;
     const char *m_appId;
     const char *m_pkgId;
+    std::string m_authorId;
     std::vector<std::string> m_privileges;
     std::vector<std::pair<std::string, app_install_path_type> > m_paths;
     std::pair<bool, uid_t> m_uid;
index e61b5b7..efc6a85 100644 (file)
@@ -2731,6 +2731,23 @@ RUNNER_TEST(security_manager_27p_API30_app_uninstall)
     };
 }
 
+RUNNER_TEST(security_manager_27a_set_wrong_author_id)
+{
+    InstallRequest requestInst;
+    requestInst.setAuthorId(NULL, SECURITY_MANAGER_ERROR_INPUT_PARAM);
+    requestInst.setAuthorId("", SECURITY_MANAGER_ERROR_INPUT_PARAM);
+}
+
+RUNNER_TEST(security_manager_27b_set_author_id_multiple_times)
+{
+    for(unsigned int i=0; i<10; ++i) {
+        std::string authorId = "some-author-id" + std::to_string(i);
+
+        InstallRequest requestInst;
+        requestInst.setAuthorId(authorId.c_str());
+    }
+}
+
 int main(int argc, char *argv[])
 {
     return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);