/*
- * 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.
m_base.execute(sql.str(), result);
}
}
+
+void TestSecurityManagerDatabase::setup_privilege_mapping(const std::string &version_from,
+ const std::string &version_to,
+ const std::string &privilege,
+ const std::string &mapping)
+{
+ Sqlite3DBaseSelectResult result;
+ std::ostringstream sql;
+
+ if (!m_base.is_open())
+ m_base.open();
+
+ sql.clear();
+ sql.str("");
+ sql << "INSERT INTO privilege_mapping_view (version_from_name, version_to_name, privilege_name, privilege_mapping_name) "
+ "VALUES ("
+ << "'" << version_from << "'" << ","
+ << "'" << version_to << "'" << ","
+ << "'" << privilege << "'" << ","
+ << "'" << mapping << "'" << ")";
+ m_base.execute(sql.str(), result);
+}
+
+void TestSecurityManagerDatabase::setup_default_version_privilege(const std::string &version_from,
+ const std::string &version_to,
+ const std::string &privilege)
+{
+ Sqlite3DBaseSelectResult result;
+ std::ostringstream sql;
+
+ if (!m_base.is_open())
+ m_base.open();
+
+ sql.clear();
+ sql.str("");
+ sql << "INSERT INTO privilege_mapping_view (version_from_name, version_to_name, privilege_name, privilege_mapping_name) "
+ "VALUES ("
+ << "'" << version_from << "'" << ","
+ << "'" << version_to << "'" << ","
+ << "NULL,"
+ << "'" << privilege << "'" << ")";
+ m_base.execute(sql.str(), result);
+
+}
+
+int64_t TestSecurityManagerDatabase::get_author_id(const std::string &authorName)
+{
+ Sqlite3DBaseSelectResult result;
+ std::ostringstream sql;
+
+ if (!m_base.is_open())
+ m_base.open();
+
+ sql.clear();
+ sql.str("SELECT author_id FROM author where name=\"" + authorName + "\"");
+ m_base.execute(sql.str(), result);
+
+ if(result.rows.empty())
+ return 0;
+
+ std::istringstream os(result.rows[0][0]);
+ int64_t id;
+ os >> id;
+ return id;
+}
+