Add test cases for updating an app package
[platform/core/test/security-tests.git] / src / security-manager-tests / test_cases.cpp
index 82d5dd4..2d8cf74 100644 (file)
@@ -642,6 +642,56 @@ RUNNER_TEST(security_manager_09d_uninstall_app_from_hybrid_package)
     }
 }
 
+RUNNER_TEST(security_manager_09e_update_app_nonhybrid_package)
+{
+    constexpr char pkgId[] = "sm_test_09e";
+    AppInstallHelperExt apps[] = {{"sm_test_09e_0", pkgId},
+                                  {"sm_test_09e_1", pkgId}};
+
+    InstallRequest installRequest;
+    installRequest.setPkgId(apps[0].getPkgId());
+    installRequest.setAppId(apps[0].getAppId());
+    // following installation will install sm_test_09e_0
+    Api::install(installRequest, SECURITY_MANAGER_SUCCESS);
+    apps[0].checkAfterInstall();
+    InstallRequest updateRequest;
+    updateRequest.setPkgId(apps[1].getPkgId());
+    updateRequest.setAppId(apps[1].getAppId());
+    // following update should uninstall sm_test_09e_0 and leave sm_test_09e_1 in the DB
+    Api::update(updateRequest, SECURITY_MANAGER_SUCCESS);
+    apps[1].checkAfterInstall();
+    apps[0].checkAfterUninstall(false);
+    // this uninstall should succeed and make sure DB contains NO applications from this package
+    Api::uninstall(updateRequest, SECURITY_MANAGER_SUCCESS);
+    apps[1].checkAfterUninstall(true);
+}
+
+RUNNER_TEST(security_manager_09f_update_app_hybrid_package)
+{
+    constexpr char pkgId[] = "sm_test_09f";
+    AppInstallHelperExt apps[] = {{"sm_test_09f_0", pkgId},
+                                  {"sm_test_09f_1", pkgId}};
+
+    InstallRequest installRequest;
+    installRequest.setPkgId(apps[0].getPkgId());
+    installRequest.setAppId(apps[0].getAppId());
+    installRequest.setHybrid();
+    // following installation will install sm_test_09f_0
+    Api::install(installRequest, SECURITY_MANAGER_SUCCESS);
+    apps[0].checkAfterInstall();
+    InstallRequest updateRequest;
+    updateRequest.setPkgId(apps[1].getPkgId());
+    updateRequest.setAppId(apps[1].getAppId());
+    updateRequest.setHybrid();
+    // following update should uninstall sm_test_09f_0 and leave sm_test_09f_1 in the DB
+    Api::update(updateRequest, SECURITY_MANAGER_SUCCESS);
+    apps[1].checkAfterInstall();
+    apps[0].checkAfterUninstall(false);
+    // this uninstall should succeed and make sure DB contains NO applications from this package
+    Api::uninstall(updateRequest, SECURITY_MANAGER_SUCCESS);
+    apps[1].checkAfterUninstall(true);
+}
+
 RUNNER_CHILD_TEST(security_manager_10_app_has_privilege)
 {
     const PrivilegeVector allowedPrivs = {PRIV_WIFIDIRECT, PRIV_TELEPHONY};