[SM] Tests for trusted dir.
[platform/core/test/security-tests.git] / src / security-manager-tests / common / sm_db.cpp
index 10aa48c..7eb6f3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -241,3 +241,25 @@ void TestSecurityManagerDatabase::setup_default_version_privilege(const std::str
         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;
+}
+