Merge branch 'tizen' into security-manager 66/34766/2
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 2 Feb 2015 14:09:41 +0000 (15:09 +0100)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 2 Feb 2015 16:15:15 +0000 (17:15 +0100)
Change-Id: I9f922b5d7269e5020b78f91b726bef444cb1697a

1  2 
packaging/security-tests.spec
tests/common/CMakeLists.txt
tests/security-manager-tests/security_manager_tests.cpp

Simple merge
Simple merge
  #include <tests_common.h>
  
  #include <security-manager.h>
 +#include <sm_api.h>
  #include <sm_db.h>
 +#include <sm_request.h>
 +#include <sm_user_request.h>
 +#include <temp_test_user.h>
  #include <cynara_test_client.h>
- #include <dbus_access.h>
++#include <service_manager.h>
  
 -DEFINE_SMARTPTR(security_manager_app_inst_req_free, app_inst_req, AppInstReqUniquePtr);
 -DEFINE_SMARTPTR(cap_free, _cap_struct, CapsSetsUniquePtr);
 -
 -static const char *const SM_APP_ID1 = "sm_test_app_id_double";
 -static const char *const SM_PKG_ID1 = "sm_test_pkg_id_double";
 +using namespace SecurityManagerTest;
  
 -static const char *const SM_APP_ID2 = "sm_test_app_id_full";
 -static const char *const SM_PKG_ID2 = "sm_test_pkg_id_full";
 -
 -static const char *const SM_APP_ID3 = "sm_test_app_id_uid";
 -static const char *const SM_PKG_ID3 = "sm_test_pkg_id_uid";
 +DEFINE_SMARTPTR(cap_free, _cap_struct, CapsSetsUniquePtr);
  
  static const privileges_t SM_ALLOWED_PRIVILEGES = {
      "security_manager_test_rules2_r",
@@@ -606,102 -616,6 +606,102 @@@ RUNNER_CHILD_TEST(security_manager_05_d
          "capabilities not dropped. Current: " << cap_to_text(caps.get(), NULL));
  }
  
-     DBusAccess dbusAccess("security-manager.service");
 +RUNNER_CHILD_TEST(security_manager_06_install_app_offline)
 +{
 +    const char *const app_id = "sm_test_06_app_id_install_app_offline";
 +    const char *const pkg_id = "sm_test_06_pkg_id_install_app_offline";
-     dbusAccess.maskService();
-     dbusAccess.stopService();
++    ServiceManager serviceManager("security-manager.service");
 +
 +    uninstall_app(app_id, pkg_id, true);
-     dbusAccess.unmaskService();
-     dbusAccess.startService();
++    serviceManager.maskService();
++    serviceManager.stopService();
 +
 +    install_app(app_id, pkg_id);
 +
-     DBusAccess dbusAccess("security-manager.service");
-     dbusAccess.maskService();
-     dbusAccess.stopService();
++    serviceManager.unmaskService();
++    serviceManager.startService();
 +
 +    uninstall_app(app_id, pkg_id, true);
 +}
 +
 +RUNNER_CHILD_TEST(security_manager_07_user_add_app_install)
 +{
 +    const char *const sm_app_id = "sm_test_07_app_id_user";
 +    const char *const sm_pkg_id = "sm_test_07_pkg_id_user";
 +    const std::string new_user_name = "sm_test_07_user_name";
 +    std::string uid_string;
 +    TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
 +    uid_string =  std::to_string(static_cast<unsigned int>(test_user.getUid()));
 +
 +    install_app(sm_app_id, sm_pkg_id, test_user.getUid());
 +
 +    check_app_after_install(sm_app_id, sm_pkg_id);
 +
 +    test_user.remove();
 +
 +    check_app_permissions(sm_app_id, sm_pkg_id, uid_string.c_str(), SM_NO_PRIVILEGES, SM_ALLOWED_PRIVILEGES);
 +
 +    check_app_after_uninstall(sm_app_id, sm_pkg_id, true);
 +}
 +
 +RUNNER_CHILD_TEST(security_manager_08_user_double_add_double_remove)
 +{
 +    UserRequest addUserRequest;
 +
 +    const char *const sm_app_id = "sm_test_08_app_id_user";
 +    const char *const sm_pkg_id = "sm_test_08_pkg_id_user";
 +    const char *const new_user_name = "sm_test_08_user_name";
 +    std::string uid_string;
 +
 +    // gumd user add
 +    TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
 +    uid_string =  std::to_string(static_cast<unsigned int>(test_user.getUid()));
 +
 +    addUserRequest.setUid(test_user.getUid());
 +    addUserRequest.setUserType(SM_USER_TYPE_NORMAL);
 +
 +    //sm user add
 +    Api::addUser(addUserRequest);
 +
 +    install_app(sm_app_id, sm_pkg_id, test_user.getUid());
 +
 +    check_app_after_install(sm_app_id, sm_pkg_id);
 +
 +    test_user.remove();
 +
 +    UserRequest deleteUserRequest;
 +    deleteUserRequest.setUid(test_user.getUid());
 +
 +    Api::deleteUser(deleteUserRequest);
 +
 +    check_app_permissions(sm_app_id, sm_pkg_id, uid_string.c_str(), SM_NO_PRIVILEGES, SM_ALLOWED_PRIVILEGES);
 +
 +    check_app_after_uninstall(sm_app_id, sm_pkg_id, true);
 +}
 +
 +RUNNER_CHILD_TEST(security_manager_09_add_user_offline)
 +{
 +    const char *const app_id = "security_manager_09_add_user_offline_app";
 +    const char *const pkg_id = "security_manager_09_add_user_offline_pkg";
 +    const std::string username("sm_test_09_user_name");
-     dbusAccess.unmaskService();
-     dbusAccess.startService();
++    ServiceManager serviceManager("security-manager.service");
++    serviceManager.maskService();
++    serviceManager.stopService();
 +
 +    TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, true);
 +
 +    install_app(app_id, pkg_id, user.getUid());
 +
 +    check_app_after_install(app_id, pkg_id);
 +
++    serviceManager.unmaskService();
++    serviceManager.startService();
 +
 +    user.remove();
 +
 +    check_app_after_uninstall(app_id, pkg_id, true);
 +}
 +
  int main(int argc, char *argv[])
  {
      return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);