E2EE: Require e2ee-tests to be ran by default user
[platform/core/test/security-tests.git] / src / ckm / ckm-common.h
index 516de56..4d398e5 100644 (file)
@@ -28,6 +28,7 @@
 #include <ckm/ckm-manager-async.h>
 #include <ckmc/ckmc-type.h>
 #include <ckmc/ckmc-error.h>
+#include <ckmc/ckmc-manager.h>
 #include <tests_common.h>
 #include <sys/types.h>
 
@@ -78,9 +79,6 @@ size_t list_size(const T* list)
     return size;
 }
 
-// scoped free
-typedef std::unique_ptr<char, void (*)(void *)> CharPtr;
-
 std::string getLabel();
 // returns process owner id
 std::string getOwnerIdFromSelf();
@@ -221,3 +219,30 @@ void test_no_observer(F&& func, Args... args)
         RUNNER_ASSERT_MSG(false, "Unexpected exception");
     }
 }
+
+class AliasRemover
+{
+public:
+    AliasRemover(const char* alias) : alias(alias) {}
+    ~AliasRemover() {
+        ckmc_remove_alias(alias);
+    }
+
+    AliasRemover(AliasRemover&& other) {
+        alias = other.alias;
+        other.alias = nullptr;
+    }
+
+    AliasRemover& operator=(AliasRemover&& other) {
+        if (&other == this)
+            return *this;
+
+        alias = other.alias;
+        other.alias = nullptr;
+    }
+
+private:
+    const char* alias;
+};
+
+void require_default_user(char *argv[]);