EGetGroupsRelatedPrivileges,
EGetPkgAuthorId,
EAuthorIdExists,
- EGetAuthorIdByName,
ESetPackageSharedRO,
EIsPackageHybrid,
EAddAppDefinedPrivilege,
*/
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)
*
[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 (?, ?, ?, ?, ?)",
});
}
-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 {
"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");
}
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));
}
"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.");
}
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));
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));
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);
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)
{
"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");
}
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);