Generic solution for onlycap issues
[platform/core/test/security-tests.git] / src / ckm / privileged / cc-mode.cpp
index b2b29db..eeddb27 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2000 - 2019 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.
@@ -34,6 +34,7 @@
 #include <ckm-common.h>
 #include <ckm/ckm-manager.h>
 #include <ckm/ckm-control.h>
+#include <scoped_process_label.h>
 
 using namespace CKM;
 using namespace std;
@@ -73,13 +74,13 @@ private:
 
 MdppState::MdppState()
 {
-    ScopedLabel sl(USER_LABEL);
+    ScopedProcessLabel spl(USER_LABEL);
     m_original = vconf_get_str(VCONFKEY_SECURITY_MDPP_STATE);
 }
 
 MdppState::~MdppState()
 {
-    ScopedLabel sl(USER_LABEL);
+    ScopedProcessLabel spl(USER_LABEL);
     if (!m_original)
         vconf_set_str(VCONFKEY_SECURITY_MDPP_STATE, UNSET);
     else {
@@ -89,7 +90,7 @@ MdppState::~MdppState()
 
 void MdppState::set(const char* const value)
 {
-    ScopedLabel sl(USER_LABEL);
+    ScopedProcessLabel spl(USER_LABEL);
     if (value)
     {
         int ret = vconf_set_str(VCONFKEY_SECURITY_MDPP_STATE, value);
@@ -121,7 +122,7 @@ void save_keys()
                 rsa_pub_alias,
                 Policy(Password(), true),
                 Policy(Password(), true))),
-            "Error=" << CKMErrorToString(temp));
+            "Error=" << APICodeToString(temp));
 
     RUNNER_ASSERT_MSG(
         CKM_API_SUCCESS == (temp = manager->createKeyPairECDSA(
@@ -130,14 +131,14 @@ void save_keys()
                 ecdsa_pub_alias,
                 Policy(Password(), true),
                 Policy(Password(), true))),
-            "Error=" << CKMErrorToString(temp));
+            "Error=" << APICodeToString(temp));
 
     RUNNER_ASSERT_MSG(
         CKM_API_SUCCESS == (temp = manager->createKeyAES(
                 aes_length,
                 aes_alias,
                 Policy(Password(), true))),
-            "Error=" << CKMErrorToString(temp));
+            "Error=" << APICodeToString(temp));
 }
 
 void read_key(ManagerShPtr& manager, const Alias& alias, int expected) {
@@ -145,8 +146,8 @@ void read_key(ManagerShPtr& manager, const Alias& alias, int expected) {
     int temp;
     RUNNER_ASSERT_MSG(
             expected == (temp = manager->getKey(alias, Password(), key)),
-            "Expected: " << expected << "/" << CKMErrorToString(expected) << " got: " << temp << "/" <<
-            CKMErrorToString(temp));
+            "Expected: " << expected << "/" << APICodeToString(expected) << " got: " << temp << "/" <<
+            APICodeToString(temp));
 }
 
 void read_keys(int expected)
@@ -167,7 +168,7 @@ void update_cc_mode()
     auto control = Control::create();
     int ret;
     RUNNER_ASSERT_MSG(CKM_API_SUCCESS == (ret = control->updateCCMode()),
-                         "Error=" << CKMErrorToString(ret));
+                         "Error=" << APICodeToString(ret));
 }
 
 void restart_ckm(const char* const mdpp_setting)