Remove unused GetAuthorIdByName() 42/238942/5
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 20 Jul 2020 13:59:19 +0000 (15:59 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Thu, 20 Aug 2020 08:34:03 +0000 (10:34 +0200)
Change-Id: Ie83236411ece80754f0edd1428aedfda13796098

src/common/include/privilege_db.h
src/common/privilege_db.cpp
test/privilege_db_fixture.cpp
test/test_privilege_db_add_app.cpp
test/test_privilege_db_app_pkg_getters.cpp

index a0e92cdaeb700fd9c4e31f14336b53e94f59abee..030cd76a1850b14db564a13451cc1e805c2075ac 100644 (file)
@@ -75,7 +75,6 @@ enum class StmtType : uint8_t {
     EGetGroupsRelatedPrivileges,
     EGetPkgAuthorId,
     EAuthorIdExists,
-    EGetAuthorIdByName,
     ESetPackageSharedRO,
     EIsPackageHybrid,
     EAddAppDefinedPrivilege,
@@ -471,16 +470,6 @@ public:
      */
     void GetPkgAuthorId(const std::string &pkgName, int &authorId);
 
-    /* Retrieve an id of an author from database by its name
-     *
-     * @param[in] authorName    author's name
-     * @param[out] authorId     matching author id or -1 if no such author exists
-     *
-     * @exception PrivilegeDb::Exception::InternalError on internal error
-     * @exception PrivilegeDb::Exception::ConstraintError on constraint violation
-     */
-    void GetAuthorIdByName(const std::string &authorName, int &authorId);
-
     /**
      * Retrieve vector of pairs with group_name (1st value) and privilege_name (2nd value)
      *
index 478941ea1fdfe1966bacff0732f20ed74d180104..07ade390018bd12e73866ff67275dc0026fffd4f 100644 (file)
@@ -72,7 +72,6 @@ constexpr const char *g_queries[StmtTypeCount] = {
     [underlying(StmtType::EGetGroupsRelatedPrivileges)] = "SELECT DISTINCT group_name, privilege_name FROM privilege_group",
     [underlying(StmtType::EGetPkgAuthorId)] = "SELECT author_id FROM pkg WHERE name = ? AND author_id IS NOT NULL",
     [underlying(StmtType::EAuthorIdExists)] = "SELECT count(*) FROM author where author_id=?",
-    [underlying(StmtType::EGetAuthorIdByName)] = "SELECT author_id FROM author WHERE name=?",
     [underlying(StmtType::ESetPackageSharedRO)] = "UPDATE pkg SET shared_ro=? WHERE name=?",
     [underlying(StmtType::EIsPackageHybrid)] = "SELECT is_hybrid FROM pkg WHERE name=?",
     [underlying(StmtType::EAddAppDefinedPrivilege)] = "INSERT INTO app_defined_privilege_view (app_name, uid, privilege, type, license) VALUES (?, ?, ?, ?, ?)",
@@ -563,22 +562,6 @@ void PrivilegeDb::GetPkgAuthorId(const std::string &pkgName, int &authorId)
     });
 }
 
-void PrivilegeDb::GetAuthorIdByName(const std::string &authorName, int &authorId)
-{
-    try_catch<void>([&] {
-        auto command = getStatement(StmtType::EGetAuthorIdByName);
-
-        command->BindString(1, authorName);
-        if (command->Step()) {
-            authorId = command->GetColumnInteger(0);
-            LogDebug("Got authorid: " << authorId << " for authorName " << authorName);
-        } else {
-            authorId = -1;
-            LogDebug("No authorid found for authorName " << authorName);
-        }
-    });
-}
-
 bool PrivilegeDb::AuthorIdExists(int authorId)
 {
     return try_catch<bool>([&]() -> bool {
index b5d68a1fb967eb8f9add1506b3d913b8021e63d6..e616c9138fd2136bd3e1404f773fba656d99d10e 100644 (file)
@@ -145,7 +145,7 @@ void PrivilegeDBFixture::addAppSuccess(const std::string &appName,
         "PkgNameExists wrongly not reported " << pkgName << " as existing package name");
 
     if (authorName.length() > 0) {
-        BOOST_REQUIRE_NO_THROW(testPrivDb->GetAuthorIdByName(authorName, authorId));
+        BOOST_REQUIRE_NO_THROW(testPrivDb->GetPkgAuthorId(pkgName, authorId));
         BOOST_REQUIRE_MESSAGE(testPrivDb->AuthorIdExists(authorId),
             "AuthorIdExists wrongly not reported " << uid << " as existing author id");
     }
@@ -161,7 +161,7 @@ void PrivilegeDBFixture::addAppFail(const std::string &appName,
     int authorId;
 
     if (authorName.length() > 0) {
-        BOOST_REQUIRE_NO_THROW(testPrivDb->GetAuthorIdByName(authorName, authorId));
+        BOOST_REQUIRE_NO_THROW(testPrivDb->GetPkgAuthorId(pkgName, authorId));
         BOOST_REQUIRE_NO_THROW(authorNameExists = testPrivDb->AuthorIdExists(authorId));
     }
 
@@ -177,7 +177,7 @@ void PrivilegeDBFixture::addAppFail(const std::string &appName,
         "PkgNameExists wrongly changed value after unsuccessful  installation.");
 
     if (authorName.length() > 0) {
-        BOOST_REQUIRE_NO_THROW(testPrivDb->GetAuthorIdByName(authorName, authorId));
+        BOOST_REQUIRE_NO_THROW(testPrivDb->GetPkgAuthorId(pkgName, authorId));
         BOOST_REQUIRE_MESSAGE(authorNameExists == testPrivDb->AuthorIdExists(authorId),
         "AuthorIdExists wrongly changed value after unsuccessful  installation.");
     }
index a8df3cca743cd7ed2e0976f285f786b256d7d7df..ccc7bdeb67d0ace9384d7345596192d2dbd0eac9 100644 (file)
@@ -165,7 +165,6 @@ POSITIVE_TEST_CASE(T580_add_applications_with_different_authors_to_packages)
 POSITIVE_TEST_CASE(T590_add_applications_with_empty_noempty_author)
 {
     int authorIdPkg;
-    int authorId;
 
     addAppSuccess(app(1), pkg(1), uid(1), tizenVer(1), "", NotHybrid);
     BOOST_REQUIRE_NO_THROW(getPrivDb()->GetPkgAuthorId(pkg(1), authorIdPkg));
@@ -175,9 +174,6 @@ POSITIVE_TEST_CASE(T590_add_applications_with_empty_noempty_author)
     addAppSuccess(app(2), pkg(1), uid(1), tizenVer(1), author(1), NotHybrid);
     BOOST_REQUIRE_NO_THROW(getPrivDb()->GetPkgAuthorId(pkg(1), authorIdPkg));
     BOOST_REQUIRE_MESSAGE(authorIdPkg != -1, "Wrong author id returned: -1");
-    BOOST_REQUIRE_NO_THROW(getPrivDb()->GetAuthorIdByName(author(1), authorId));
-    BOOST_REQUIRE_MESSAGE(authorId == authorIdPkg, "Author id returned by GetAuthorIdByName: "
-        << authorId << " does not match author id returned by GetPkgAuthorId: " << authorIdPkg);
 
     addAppSuccess(app(3), pkg(1), uid(1), tizenVer(1), "", NotHybrid);
     BOOST_REQUIRE_NO_THROW(getPrivDb()->GetPkgAuthorId(pkg(2), authorIdPkg));
index 396e35f75f522f400afbc5b788c7bcf9c56db5e4..f47d429b52852c1c41e6068a56b3685a7080dad3 100644 (file)
@@ -40,7 +40,6 @@
 struct PrivilegeDBGettersFixture : PrivilegeDBFixture
 {
     void checkGetAllPackages(std::vector<std::string> expectedPackages);
-    void checkGetAuthorIdByName(const std::string &authorName, int expectedAuthorId);
     void checkGetAppPkgInfo(const std::string &app, const std::string &expectedPackage,
         bool expectedIsHybrid, bool expectedIsSharedRO);
     void checkGetPkgApps(const std::string &package, std::vector<std::string> expectedApps);
@@ -62,16 +61,6 @@ void PrivilegeDBGettersFixture::checkGetAllPackages(std::vector<std::string> exp
     expectedPackages.begin(), expectedPackages.end());
 };
 
-void PrivilegeDBGettersFixture::checkGetAuthorIdByName(const std::string &authorName,
-        int expectedAuthorId)
-{
-    int authorId;
-    BOOST_REQUIRE_NO_THROW(getPrivDb()->GetAuthorIdByName(authorName, authorId));
-    BOOST_CHECK_MESSAGE(expectedAuthorId == authorId, "GetAuthorIdByName for authorName: "
-        << authorName << " returned wrong authorId: " << authorId << " expected: "
-        << expectedAuthorId);
-};
-
 void PrivilegeDBGettersFixture::checkGetAppPkgInfo(const std::string &app,
     const std::string &expectedPackage, bool expectedIsHybrid, bool expectedIsSharedRO)
 {
@@ -196,7 +185,7 @@ POSITIVE_TEST_CASE(T325_app_name_pkg_author_exists)
         "AppNameExists wrongly not reported " << app(1) << " as existing application name");
     BOOST_REQUIRE_MESSAGE(getPrivDb()->PkgNameExists(pkg(1)),
         "PkgNameExists wrongly not reported " << pkg(1) << " as existing package name");
-    BOOST_REQUIRE_NO_THROW(getPrivDb()->GetAuthorIdByName(author(1), authorId));
+    BOOST_REQUIRE_NO_THROW(getPrivDb()->GetPkgAuthorId(pkg(1), authorId));
     BOOST_REQUIRE_MESSAGE(getPrivDb()->AuthorIdExists(authorId),
         "AuthorIdExists wrongly not found " << author(1) << " as existing author");
 }
@@ -426,23 +415,6 @@ POSITIVE_TEST_CASE(T370_get_pkg_author_id)
     checkGetPkgAuthorId(pkg(1), 3);
 }
 
-POSITIVE_TEST_CASE(T375_get_pkg_author_id_by_name)
-{
-    checkGetAuthorIdByName(author(1), -1);
-
-    addAppSuccess(app(1), pkg(1), uid(1), tizenVer(1), author(1), NotHybrid);
-    checkGetAuthorIdByName(author(1), 1);
-
-    addAppSuccess(app(2), pkg(2), uid(2), tizenVer(1), author(2), NotHybrid);
-    checkGetAuthorIdByName(author(2), 2);
-
-    removeAppSuccess(app(1), uid(1));
-    checkGetAuthorIdByName(author(1), -1);
-
-    addAppSuccess(app(1), pkg(1), uid(1), tizenVer(1), author(1), Hybrid);
-    checkGetAuthorIdByName(author(1), 3);
-}
-
 POSITIVE_TEST_CASE(T380_is_package_Hybrid)
 {
     checkIsPackageHybrid(pkg(1), NotHybrid);