Run key-manager test on onlycap 67/81467/3
authorKyungwook Tak <k.tak@samsung.com>
Tue, 26 Jul 2016 07:28:04 +0000 (16:28 +0900)
committerkyungwook tak <k.tak@samsung.com>
Thu, 28 Jul 2016 01:41:09 +0000 (18:41 -0700)
Notice: This commit is temporary quick fix for only-cap.
        Test cases should be separated to normal cases and
        smack label of self change needed cases for testing
        unprivileged(without any of capability) client.

- Change smack label to System::Privileged
- Reduce key-manager test app lables
- Add ckm test script for running on onlycap (ckm-tests-on-onlycap.sh).
  Usage is same to ordinary ckm-tests because it propagates all params
  and forwards them to ckm-tests

Change-Id: I3babb11d010eff13c35042107af215b3932f4f2e
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
16 files changed:
packaging/security-tests.manifest
packaging/security-tests.spec
src/ckm/CMakeLists.txt
src/ckm/XML_1_okay.xml
src/ckm/XML_2_okay.xml
src/ckm/XML_3_wrong.xml
src/ckm/async-api.cpp
src/ckm/capi-access_control.cpp
src/ckm/capi-testcases.cpp
src/ckm/ckm-common.cpp
src/ckm/ckm-common.h
src/ckm/ckm-tests-on-onlycap.sh [new file with mode: 0644]
src/ckm/encryption-decryption.cpp
src/ckm/initial-values.cpp
src/ckm/main.cpp
src/ckm/system-db.cpp

index c3df657..bb03168 100644 (file)
@@ -9,8 +9,7 @@
         <filesystem path="/usr/bin/libsmack-test" exec_label="_" />
         <filesystem path="/usr/bin/security-manager-tests" exec_label="_" />
         <filesystem path="/usr/bin/cynara-tests" exec_label="_" />
-        <filesystem path="/usr/bin/ckm-tests" exec_label="User" />
-        <filesystem path="/usr/bin/ckm-tests" exec_label="System" />
+        <filesystem path="/usr/bin/ckm-tests" exec_label="System::Privileged" />
     </assign>
     <request>
         <domain name="_" />
index 18011c5..e43138d 100644 (file)
@@ -86,6 +86,7 @@ echo "security-tests postinst done ..."
 /usr/apps/*
 /usr/bin/cynara-test
 /usr/bin/ckm-tests
+/usr/bin/ckm-tests-on-onlycap.sh
 /usr/bin/ckm-integration-tests
 %{ckm_test_dir}/*
 /etc/security-tests
index 87696f1..f0aa9cd 100644 (file)
@@ -32,11 +32,11 @@ ADD_DEFINITIONS("-DCKM_RW_DATA_DIR=\"${CKM_RW_DATA_DIR}\"")
 
 # Dependencies
 PKG_CHECK_MODULES(CKM_DEP
+    REQUIRED
     libsmack
     key-manager
     dbus-1
-    vconf
-    REQUIRED)
+    vconf)
 
 # Targets definition
 
@@ -59,8 +59,10 @@ SET(CKM_SOURCES
 )
 
 INCLUDE_DIRECTORIES(SYSTEM ${CKM_DEP_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/common/ )
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/ckm/ )
+INCLUDE_DIRECTORIES(
+    ${PROJECT_SOURCE_DIR}/src/common
+    ${PROJECT_SOURCE_DIR}/src/ckm
+)
 
 ADD_EXECUTABLE(${TARGET_CKM_TESTS} ${CKM_SOURCES})
 
@@ -69,6 +71,13 @@ TARGET_LINK_LIBRARIES(${TARGET_CKM_TESTS} ${CKM_DEP_LIBRARIES} ${COMMON_TARGET_T
 # Installation
 
 INSTALL(TARGETS ${TARGET_CKM_TESTS} DESTINATION bin)
+INSTALL(FILES ckm-tests-on-onlycap.sh
+    DESTINATION bin
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+                GROUP_READ GROUP_EXECUTE
+                WORLD_READ WORLD_EXECUTE
+)
+
 INSTALL(FILES
     test1801.pkcs12
     pkcs.p12
@@ -88,8 +97,8 @@ SET(C_COMPILATION_SOURCES
 )
 
 PKG_CHECK_MODULES(CKM_C_COMPILATION_DEP
-    key-manager
-    REQUIRED)
+    REQUIRED
+    key-manager)
 
 ADD_EXECUTABLE(${TARGET_C_COMPILATION_TEST} ${C_COMPILATION_SOURCES})
 
index eace3d8..92fe3fd 100644 (file)
@@ -30,7 +30,7 @@
       8lLQwmLiBLx0Yr/RXKf6gJUCAwEAAQ==
       -----END PUBLIC KEY-----
     </PEM>
-    <Permission accessor="web_app1"/>
+    <Permission accessor="test_label"/>
   </Key>
   <Key name="test-key2" type="RSA_PRV" exportable="true">
     <DER>
@@ -77,7 +77,7 @@
       4D6vkEFsGfjkcmSMK83PHhrSE1CmZ/rquPjo7MY8fylkeVfefQoKhTUkr6Nz/DVaGTbTostgRog+
       Vx676FQrM4EzjSSqgA==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Key>
   <Cert exportable="true" name="test-cert1">
     <DER>
       7+XYvhodLRsVqMn7nf7taidDKLO2T4bhujztnTYOhhaXKgPy7AtZ28N2wvX96VyAPB/vrchGmyBK
       kOg11TpPdNDkhb1J4ZCh2gupDg==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Cert>
   <Data name="test-data1" exportable="true">
     <ASCII>My secret data</ASCII>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Data>
   <Key name="test-aes1" type="AES" exportable="true">
     <Base64>
       QUJDREVGR0hJSktMTU5PUFJTVFVWV1hZWjAxMjM0NTY=
     </Base64>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Key>
   <!-- key below is encrypted using AES-CBC algorithm.
      The key used is decrypted <EncryptionKey> provided above.
index bfdc299..0c3a76d 100644 (file)
@@ -17,7 +17,7 @@
       8lLQwmLiBLx0Yr/RXKf6gJUCAwEAAQ==
       -----END PUBLIC KEY-----
     </PEM>
-    <Permission accessor="web_app1"/>
+    <Permission accessor="test_label"/>
   </Key>
   <Key name="test2-key2" type="RSA_PRV" exportable="true">
     <DER>
@@ -64,7 +64,7 @@
       4D6vkEFsGfjkcmSMK83PHhrSE1CmZ/rquPjo7MY8fylkeVfefQoKhTUkr6Nz/DVaGTbTostgRog+
       Vx676FQrM4EzjSSqgA==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Key>
   <Cert exportable="true" name="test2-cert1">
     <DER>
       7+XYvhodLRsVqMn7nf7taidDKLO2T4bhujztnTYOhhaXKgPy7AtZ28N2wvX96VyAPB/vrchGmyBK
       kOg11TpPdNDkhb1J4ZCh2gupDg==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Cert>
   <Data name="test2-data1" exportable="true">
     <ASCII>My secret data</ASCII>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Data>
   <Key name="test2-aes1" type="AES" exportable="true">
     <Base64>
       QUJDREVGR0hJSktMTU5PUFJTVFVWV1hZWjAxMjM0NTY=
     </Base64>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Key>
 </InitialValues>
index 6a1d78a..2fcb32a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <InitialValues version="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="initial_values.xsd ">
   <Key name="test3-key1" type="RSA_PUB" password="123">
-    <Permission accessor="web_app1"/>
+    <Permission accessor="test_label"/>
     <PEM>
       -----BEGIN PUBLIC KEY-----
       MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzIft00bxMjLwkweLexg3
@@ -64,7 +64,7 @@
       4D6vkEFsGfjkcmSMK83PHhrSE1CmZ/rquPjo7MY8fylkeVfefQoKhTUkr6Nz/DVaGTbTostgRog+
       Vx676FQrM4EzjSSqgA==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Key>
   <Cert exportable="true" name="test3-cert1">
     <DER>
       7+XYvhodLRsVqMn7nf7taidDKLO2T4bhujztnTYOhhaXKgPy7AtZ28N2wvX96VyAPB/vrchGmyBK
       kOg11TpPdNDkhb1J4ZCh2gupDg==
     </DER>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label_2"/>
   </Cert>
   <Data name="test3-data1" exportable="true">
     <ASCII>My secret data</ASCII>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Data>
   <Key name="test3-aes1" type="AES">
     <Base64>
       QUJDREVGR0hJSktMTU5PUFJTVFVWV1hZWjAxMjM0NTY=
     </Base64>
-    <Permission accessor="web_app1"/>
-    <Permission accessor="web_app2"/>
+    <Permission accessor="test_label"/>
+    <Permission accessor="test_label_2"/>
   </Key>
 </InitialValues>
index 2fde838..1eb6e19 100644 (file)
@@ -49,9 +49,6 @@ using namespace TestData;
 
 namespace {
 
-const char* TEST_LABEL  = "test_label";
-const char* TEST_LABEL_2    = "test_label-2";
-
 const char* TEST_DATA = "dsflsdkghkslhglrtghierhgilrehgidsafasdffsgfdgdgfdgfdgfdgfdggf";
 
 const char* TEST_PASS = "test-pass";
index 5881ab3..2b58371 100644 (file)
@@ -23,10 +23,10 @@ const int APP_2                 = 6200;
 const int GROUP_2               = 6200;
 const char * const APP_PASS_1   = "app-pass-1";
 const char * const APP_PASS_2   = "app-pass-2";
-const char* APP_LABEL_1         = "APP_LABEL_1";
-const char* APP_LABEL_2         = "APP_LABEL_2";
-const char* APP_LABEL_3         = "APP_LABEL_3";
-const char* APP_LABEL_4         = "APP_LABEL_4";
+const char* APP_LABEL_1         = TEST_LABEL;
+const char* APP_LABEL_2         = TEST_LABEL_2;
+const char* APP_LABEL_3         = TEST_LABEL_3;
+const char* APP_LABEL_4         = TEST_LABEL_4;
 
 
 const char* NO_ALIAS = "definitely-non-existent-alias";
index 284b68a..0de06f0 100644 (file)
@@ -28,7 +28,6 @@ namespace {
 const int USER_APP = 5000;
 const int GROUP_APP = 5000;
 const char* USER_PASS = "user-pass";
-const char* TEST_LABEL = "test_label";
 const char *const TEST_OBJECT1 = "OBJECT1";
 const std::string TEST_ALIAS1 = aliasWithLabel(TEST_LABEL,TEST_OBJECT1);
 const char* TEST_SYSTEM_ALIAS = "system-alias-1";
@@ -343,7 +342,7 @@ RUNNER_TEST(T30206_certificate_list_C_API)
 
 RUNNER_CHILD_TEST(T30207_user_app_save_RSA_key_C_API)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -394,7 +393,7 @@ RUNNER_CHILD_TEST(T30207_user_app_save_RSA_key_C_API)
 
 RUNNER_CHILD_TEST(T30208_user_app_save_AES_key_C_API)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -423,7 +422,7 @@ RUNNER_CHILD_TEST(T30208_user_app_save_AES_key_C_API)
 
 RUNNER_CHILD_TEST(T30209_user_app_save_AES_key_passwd_C_API)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -445,7 +444,7 @@ RUNNER_CHILD_TEST(T30209_user_app_save_AES_key_passwd_C_API)
 
 RUNNER_CHILD_TEST(T30210_app_user_save_RSA_keys_exportable_flag)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -487,7 +486,7 @@ RUNNER_CHILD_TEST(T30210_app_user_save_RSA_keys_exportable_flag)
 
 RUNNER_CHILD_TEST(T30211_app_user_save_AES_keys_exportable_flag)
 {
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -800,7 +799,7 @@ RUNNER_TEST(T3042_save_get_bin_data_C_API)
 
 RUNNER_CHILD_TEST(T3043_app_user_save_bin_data_C_API)
 {
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -933,7 +932,7 @@ RUNNER_CHILD_TEST(T3052_CAPI_create_RSA_key)
 {
        int temp;
 
-       ScopedAccessProvider ap("mylabel");
+       ScopedAccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -993,7 +992,7 @@ RUNNER_CHILD_TEST(T3053_CAPI_create_DSA_key)
 {
        int temp;
 
-       AccessProvider ap("mylabel");
+       AccessProvider ap(TEST_LABEL);
        ap.allowAPI("key-manager::api-storage", "rw");
        ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1178,7 +1177,6 @@ RUNNER_TEST(T3065_CAPI_deinit)
 //RUNNER_TEST_GROUP_INIT(T120_NEGATIVE_TESTS);
 
 
-
 RUNNER_TEST_GROUP_INIT(T307_CKMC_CAPI_OCSP_TESTS);
 
 RUNNER_TEST(T3071_CAPI_init)
index 4f6880d..8cfbac4 100644 (file)
 #include <unistd.h>
 
 const std::string SMACK_USER_APP_PREFIX = "User::App::";
+const char *SYSTEM_LABEL = ckmc_owner_id_system;
+const char *TEST_LABEL = "test_label";
+const char *TEST_LABEL_2 = "test_label_2";
+const char *TEST_LABEL_3 = "test_label_3";
+const char *TEST_LABEL_4 = "test_label_4";
+const char *TEST_LABEL_5 = "test_label_5";
 
 void generate_random(size_t random_bytes, char *output)
 {
index 9bfebe0..7d638ba 100644 (file)
 #include <sys/types.h>
 
 extern const std::string SMACK_USER_APP_PREFIX;
+extern const char *SYSTEM_LABEL;
+extern const char *TEST_LABEL;
+extern const char *TEST_LABEL_2;
+extern const char *TEST_LABEL_3;
+extern const char *TEST_LABEL_4;
+extern const char *TEST_LABEL_5;
 
 // support for error printing
 const char * CKMCErrorToString(int error);
diff --git a/src/ckm/ckm-tests-on-onlycap.sh b/src/ckm/ckm-tests-on-onlycap.sh
new file mode 100644 (file)
index 0000000..bf50482
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Copyright (c) 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.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        ckm-tests-on-onlycap.sh
+# @author      Kyungwook Tak (k.tak@samsung.com)
+# @brief       Run ckm-tests on onlycap environment
+#
+
+# push test app lables to onlycap label list
+echo "System::Privileged \
+      User::App::test_label \
+      User::App::test_label_2 \
+      User::App::test_label_3 \
+      User::App::test_label_4 \
+      User::App::test_label_5 \
+      System" > /sys/fs/smackfs/onlycap
+
+# set capability for changing smack label of self and add/remove smack rules
+setcap cap_mac_admin=eip /usr/bin/ckm-tests
+
+# run test
+ckm-tests "${@}" # propagate all arguments
index cc057b9..33e3455 100644 (file)
@@ -107,7 +107,7 @@ public:
     void init(const std::string& str) {
         RemoveDataEnv<UID>::init(str);
         m_dbu = new ScopedDBUnlock(UID, "db-pass"); // unlock user's database
-        m_sap = new ScopedAccessProvider("my-label");    // setup label
+        m_sap = new ScopedAccessProvider(TEST_LABEL);    // setup label
 
         // setup smack rules and switch user
         m_sap->allowAPI("key-manager::api-storage", "rw");
index e6b4443..d691df5 100644 (file)
@@ -33,8 +33,6 @@ namespace
 const uid_t USER_APP            = 5070;
 const uid_t GROUP_APP           = 5070;
 const char* APP_PASS            = "user-pass";
-const char* TEST_WEB_APP_1      = "web_app1";
-const char* TEST_WEB_APP_2      = "web_app2";
 
 const char *XML_DEVICE_KEY              = "device_key.xml";
 
@@ -111,44 +109,55 @@ void test_exists(const std::string& name, bool expected) {
 
 RUNNER_TEST_GROUP_INIT(T60_INITIAL_VALUES);
 
-RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP, RemoveDataEnv<0>)
+RUNNER_TEST(T6001_init)
 {
     // [prepare]
     // remove database 0
     // copy to the initial-values folder
-    // [test0]
     // check XML file exists
     // restart the key-manager
-    // check XML file exists - should fail
-    // [test1]
-    // check items existence as system service
-    // [test2]
-    // check items existence as web_app1
-    // [test3]
-    // check items existence as web_app2
-
+    // check XML file doesn't exist
 
-    // [prepare]
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
     copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
+    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
+    copy_file(format_src_path(XML_2_okay), format_dest_path(XML_2_okay));
+    copy_file(format_src_path(XML_3_wrong), format_dest_path(XML_3_wrong));
 
-    // [test0]
     test_exists(format_dest_path(XML_1_okay), true);
+    test_exists(format_dest_path(XML_2_okay), true);
+    test_exists(format_dest_path(XML_3_wrong), true);
+
     restart_key_manager();
+
     test_exists(format_dest_path(XML_1_okay), false);
+    test_exists(format_dest_path(XML_2_okay), false);
+    test_exists(format_dest_path(XML_3_wrong), false);
+}
 
+RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP)
+{
     // [test1]
-    check_key(XML_1_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE);
-    check_key_allowed(XML_1_EXPECTED_KEY_2_RSA.c_str(), CKMC_KEY_RSA_PRIVATE);
-    check_key_allowed(XML_1_EXPECTED_KEY_3_AES.c_str(), CKMC_KEY_AES);
-    check_cert_allowed(XML_1_EXPECTED_CERT_1.c_str());
-    check_read_allowed(XML_1_EXPECTED_DATA_1.c_str(), XML_1_EXPECTED_DATA_1_DATA);
+    // check items existence as system service
+    // [test2]
+    // check items existence as TEST_LABEL
+    // [test3]
+    // check items existence as TEST_LABEL_2
+
+    // [test1]
+    {
+        ScopedAccessProvider ap(SYSTEM_LABEL);
+        ap.applyAndSwithToUser(0, 0);
+        check_key(XML_1_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE);
+        check_key_allowed(XML_1_EXPECTED_KEY_2_RSA.c_str(), CKMC_KEY_RSA_PRIVATE);
+        check_key_allowed(XML_1_EXPECTED_KEY_3_AES.c_str(), CKMC_KEY_AES);
+        check_cert_allowed(XML_1_EXPECTED_CERT_1.c_str());
+        check_read_allowed(XML_1_EXPECTED_DATA_1.c_str(), XML_1_EXPECTED_DATA_1_DATA);
+    }
 
     // [test2]
     {
         ScopedDBUnlock unlock(USER_APP, APP_PASS);
-        ScopedAccessProvider ap(TEST_WEB_APP_1);
-        ap.allowAPI("key-manager::api-storage", "rw");
+        ScopedAccessProvider ap(TEST_LABEL);
         ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
         check_key(XML_1_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE);
@@ -161,8 +170,7 @@ RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP, RemoveDataEnv<0>)
     // [test3]
     {
         ScopedDBUnlock unlock(USER_APP, APP_PASS);
-        ScopedAccessProvider ap(TEST_WEB_APP_2);
-        ap.allowAPI("key-manager::api-storage", "rw");
+        ScopedAccessProvider ap(TEST_LABEL_2);
         ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
         check_key_not_visible(XML_1_EXPECTED_KEY_1_RSA.c_str());
@@ -173,31 +181,10 @@ RUNNER_TEST(T6010_PARSE_XML_FILE_AT_STARTUP, RemoveDataEnv<0>)
     }
 }
 
-RUNNER_TEST(T6020_PARSE_TWO_XML_FILES_AT_STARTUP, RemoveDataEnv<0>)
+RUNNER_TEST(T6020_PARSE_TWO_XML_FILES_AT_STARTUP)
 {
-    // [prepare]
-    // remove database 0
-    // copy two files to the initial-values folder
-    // [test0]
-    // check XML files exist
-    // restart the key-manager
-    // check XML files exist - should fail
-    // [test1]
+    // [test]
     // check items existence as system service
-
-    // [prepare]
-    copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
-    copy_file(format_src_path(XML_2_okay), format_dest_path(XML_2_okay));
-
-    // [test0]
-    test_exists(format_dest_path(XML_1_okay), true);
-    test_exists(format_dest_path(XML_1_okay), true);
-    restart_key_manager();
-    test_exists(format_dest_path(XML_2_okay), false);
-    test_exists(format_dest_path(XML_2_okay), false);
-
-    // [test1]
     check_key(XML_1_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE);
     check_key(XML_2_EXPECTED_KEY_1_RSA.c_str(), CKMC_ERROR_NOT_EXPORTABLE);
     check_key_allowed(XML_1_EXPECTED_KEY_2_RSA.c_str(), CKMC_KEY_RSA_PRIVATE);
@@ -210,48 +197,20 @@ RUNNER_TEST(T6020_PARSE_TWO_XML_FILES_AT_STARTUP, RemoveDataEnv<0>)
     check_read_allowed(XML_2_EXPECTED_DATA_1.c_str(), XML_2_EXPECTED_DATA_1_DATA);
 }
 
-RUNNER_TEST(T6030_PARSE_FAIL_XML_AT_STARTUP, RemoveDataEnv<0>)
+RUNNER_TEST(T6030_PARSE_FAIL_XML_AT_STARTUP)
 {
-    // [prepare]
-    // remove database 0
-    // copy failing XML file to the initial-values folder
-    // [test0]
-    // check XML files exist
-    // restart the key-manager
-    // check XML files exist - should fail
-    // [test1]
+    // [test]
     // check items existence as system service - nothing should be available
-
-    // [prepare]
-    copy_file(format_src_path(XML_3_wrong), format_dest_path(XML_3_wrong));
-
-    // [test0]
-    test_exists(format_dest_path(XML_3_wrong), true);
-    restart_key_manager();
-    test_exists(format_dest_path(XML_3_wrong), false);
-
-    // [test1]
     check_key_not_visible(XML_3_EXPECTED_KEY_1_RSA.c_str());
     check_key_not_visible(XML_3_EXPECTED_KEY_2_RSA.c_str());
     check_cert_not_visible(XML_3_EXPECTED_CERT_1.c_str());
     check_read_not_visible(XML_3_EXPECTED_DATA_1.c_str());
 }
 
-RUNNER_TEST(T6040_CHECK_KEYS_VALID, RemoveDataEnv<0>)
+RUNNER_TEST(T6040_CHECK_KEYS_VALID)
 {
-    // [prepare]
-    // remove database 0
-    // copy to the initial-values folder
-    // restart the key-manager
     // [test]
     // check if key can create & verify signature
-
-    // [prepare]
-    copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
-    restart_key_manager();
-
-    // [test]
     ckmc_raw_buffer_s msg_buff = prepare_message_buffer("Raz ugryzla misia pszczola..");
     ckmc_hash_algo_e hash_algo = CKMC_HASH_SHA256;
     ckmc_rsa_padding_algo_e pad_algo = CKMC_PKCS1_PADDING;
@@ -292,14 +251,11 @@ RUNNER_TEST(T6040_CHECK_KEYS_VALID, RemoveDataEnv<0>)
     ckmc_buffer_free(signature);
 }
 
-RUNNER_TEST(T6050_ENCRYPTED_KEY, RemoveDataEnv<0>)
+RUNNER_TEST(T6050_ENCRYPTED_KEY)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
     // to decrypt RSA OAEP cipher: openssl rsautl -decrypt -oaep -in cipher.out -out plaintext -inkey priv.key
-    // remove database 0
-    // copy to the initial-values folder
-    // restart the key-manager
     // [test0]
     // check if encrypted private key is present
     // check if public key is present
@@ -309,11 +265,6 @@ RUNNER_TEST(T6050_ENCRYPTED_KEY, RemoveDataEnv<0>)
     // create signature using the public key
     // verify signature using the decrypted private key
 
-    // [prepare]
-    copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
-    restart_key_manager();
-
     // [test0]
     check_key_allowed(XML_1_EXPECTED_KEY_3_RSA_PRV.c_str(), CKMC_KEY_RSA_PRIVATE);
     check_key_allowed(XML_1_EXPECTED_KEY_3_RSA_PUB.c_str(), CKMC_KEY_RSA_PUBLIC);
@@ -348,23 +299,15 @@ RUNNER_TEST(T6050_ENCRYPTED_KEY, RemoveDataEnv<0>)
     ckmc_buffer_free(signature);
 }
 
-RUNNER_TEST(T6060_ENCRYPTED_ASCII_DATA, RemoveDataEnv<0>)
+RUNNER_TEST(T6060_ENCRYPTED_ASCII_DATA)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
     // to decrypt RSA OAEP cipher: openssl rsautl -decrypt -oaep -in cipher.out -out plaintext -inkey priv.key
-    // remove database 0
-    // copy to the initial-values folder
-    // restart the key-manager
     // [test0]
     // extract data
     // check if data matches the expected size and content
 
-    // [prepare]
-    copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
-    restart_key_manager();
-
     // [test0]
     ckmc_raw_buffer_s *testData1;
     int temp;
@@ -377,23 +320,15 @@ RUNNER_TEST(T6060_ENCRYPTED_ASCII_DATA, RemoveDataEnv<0>)
     ckmc_buffer_free(testData1);
 }
 
-RUNNER_TEST(T6070_ENCRYPTED_BIG_DATA, RemoveDataEnv<0>)
+RUNNER_TEST(T6070_ENCRYPTED_BIG_DATA)
 {
     // [prepare]
     // to encrypt using RSA OAEP:  openssl rsautl -encrypt -oaep -pubin -inkey pub.key -in input.txt -out cipher.out
     // to decrypt RSA OAEP cipher: openssl rsautl -decrypt -oaep -in cipher.out -out plaintext -inkey priv.key
-    // remove database 0
-    // copy to the initial-values folder
-    // restart the key-manager
     // [test0]
     // extract data
     // check if data matches the expected size
 
-    // [prepare]
-    copy_file(format_src_path(XML_DEVICE_KEY), format_dest_key_path(XML_DEVICE_KEY));
-    copy_file(format_src_path(XML_1_okay), format_dest_path(XML_1_okay));
-    restart_key_manager();
-
     // [test0]
     ckmc_raw_buffer_s *testData1;
     int temp;
@@ -403,3 +338,8 @@ RUNNER_TEST(T6070_ENCRYPTED_BIG_DATA, RemoveDataEnv<0>)
     RUNNER_ASSERT_MSG(5918 /* src/ckm/keys/EIV/code.png */ == testData1->size, "invalid data size");
     ckmc_buffer_free(testData1);
 }
+
+RUNNER_TEST(T6999_deinit)
+{
+    remove_user_data(0);
+}
index df2de0a..051d29b 100644 (file)
@@ -28,7 +28,6 @@ const int USER_APP_3 = 5030;
 
 const char * const APP_PASS  = "user-pass";
 const int USER_TEST = 5001;
-const char* TEST_LABEL = "test_label";
 
 const CKM::CertificateShPtrVector EMPTY_CERT_VECTOR;
 const CKM::AliasVector EMPTY_ALIAS_VECTOR;
@@ -235,7 +234,7 @@ RUNNER_TEST(T1012_certificate)
 
 RUNNER_CHILD_TEST(T1013_user_app_save_key)
 {
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -268,7 +267,7 @@ RUNNER_CHILD_TEST(T1013_user_app_save_key)
 
 RUNNER_TEST(T1014_save_with_label)
 {
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -369,7 +368,7 @@ RUNNER_TEST(T1021_save_keys_get_alias)
 
 RUNNER_CHILD_TEST(T1022_app_user_save_keys_get_alias)
 {
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -410,7 +409,7 @@ RUNNER_CHILD_TEST(T1022_app_user_save_keys_get_alias)
 
 RUNNER_CHILD_TEST(T1023_app_user_save_keys_exportable_flag)
 {
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -507,7 +506,7 @@ RUNNER_TEST(T1031_save_get_bin_data)
 RUNNER_CHILD_TEST(T1032_app_user_save_bin_data)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -581,7 +580,7 @@ RUNNER_TEST(T1033_remove_bin_data)
 RUNNER_TEST(T1034_app_remove_bin_data)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -673,7 +672,7 @@ RUNNER_CHILD_TEST(T1041_create_RSA_key)
     auto manager = CKM::Manager::create();
     CKM::AliasVector av;
 
-    ScopedAccessProvider ap("mylabel-rsa");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -695,7 +694,7 @@ RUNNER_CHILD_TEST(T1042_create_RSA_key_foreign_label)
     auto manager = CKM::Manager::create();
     CKM::AliasVector av;
 
-    ScopedAccessProvider ap("mylabel-rsa");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -713,7 +712,7 @@ RUNNER_CHILD_TEST(T1043_create_DSA_key)
     auto manager = CKM::Manager::create();
     CKM::AliasVector av;
 
-    ScopedAccessProvider ap("mylabel-dsa");
+    ScopedAccessProvider ap(TEST_LABEL_3);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -735,7 +734,7 @@ RUNNER_CHILD_TEST(T1044_create_AES_key)
     auto manager = CKM::Manager::create();
     CKM::AliasVector av;
 
-    AccessProvider ap("mylabel-aes");
+    AccessProvider ap(TEST_LABEL_4);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -824,7 +823,7 @@ RUNNER_TEST(T12100_init)
 RUNNER_TEST(T12101_key_exist)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -860,7 +859,7 @@ RUNNER_TEST(T12101_key_exist)
 RUNNER_TEST(T12102_saveKey_empty_alias)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -889,7 +888,7 @@ RUNNER_TEST(T12102_saveKey_empty_alias)
 RUNNER_TEST(T12103_saveKey_foreign_label)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -917,7 +916,7 @@ RUNNER_TEST(T12103_saveKey_foreign_label)
 RUNNER_TEST(T12104_saveKey_empty_key)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -934,7 +933,7 @@ RUNNER_TEST(T12104_saveKey_empty_key)
 RUNNER_TEST(T12105_saveCertificate_empty_alias)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -951,7 +950,7 @@ RUNNER_TEST(T12105_saveCertificate_empty_alias)
 RUNNER_TEST(T12106_saveCertificate_foreign_label)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -968,7 +967,7 @@ RUNNER_TEST(T12106_saveCertificate_foreign_label)
 RUNNER_TEST(T12107_saveCertificate_empty_cert)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -985,7 +984,7 @@ RUNNER_TEST(T12107_saveCertificate_empty_cert)
 RUNNER_TEST(T12108_saveData_empty_alias)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1003,7 +1002,7 @@ RUNNER_TEST(T12108_saveData_empty_alias)
 RUNNER_TEST(T12109_saveData_foreign_label)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1021,7 +1020,7 @@ RUNNER_TEST(T12109_saveData_foreign_label)
 RUNNER_TEST(T12110_saveData_empty_data)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1042,7 +1041,7 @@ RUNNER_TEST(T12110_saveData_empty_data)
 RUNNER_TEST(T12111_getKey_alias_not_exist)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1059,7 +1058,7 @@ RUNNER_TEST(T12111_getKey_alias_not_exist)
 RUNNER_TEST(T12112_getCertificate_alias_not_exist)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1076,7 +1075,7 @@ RUNNER_TEST(T12112_getCertificate_alias_not_exist)
 RUNNER_TEST(T12113_getData_alias_not_exist)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1095,7 +1094,7 @@ RUNNER_TEST(T12113_getData_alias_not_exist)
 RUNNER_TEST(T12114_RSA_key_damaged)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1127,7 +1126,7 @@ RUNNER_TEST(T12114_RSA_key_damaged)
 RUNNER_TEST(T12115_RSA_key_too_short)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1156,7 +1155,7 @@ RUNNER_TEST(T12115_RSA_key_too_short)
 RUNNER_TEST(T12116_DSA_key_too_short)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1208,7 +1207,7 @@ RUNNER_TEST(T12117_AES_key_too_short)
 RUNNER_TEST(T12118_RSA_key_damaged_serviceTest)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1255,7 +1254,7 @@ RUNNER_TEST(T12118_RSA_key_damaged_serviceTest)
 RUNNER_TEST(T12119_saveCertificate_damaged_serviceTest)
 {
     ScopedDBUnlock unlock(USER_APP, APP_PASS);
-    ScopedAccessProvider ap("mylabel");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_APP, GROUP_APP);
 
@@ -1311,7 +1310,6 @@ RUNNER_TEST(T1311_init)
     RUNNER_ASSERT_MSG(time(0) > 1405343457,
         "Time error. Device date is before 14th of July 2014. You must set proper time on device before run this tests!");
 
-    ScopedLabel sl("System");
     struct hostent* he = gethostbyname("google.com");
 
     RUNNER_ASSERT_MSG(he != NULL, "There is problem with translate domain google.com into ip address. Probably network "
@@ -2481,7 +2479,7 @@ RUNNER_TEST(T1511_insert_data)
     CKM::Alias certimAlias("CertIM");
     {
         ScopedDBUnlock unlock(USER_TEST, APP_PASS);
-        ScopedAccessProvider ap("my-label");
+        ScopedAccessProvider ap(TEST_LABEL);
         ap.allowAPI("key-manager::api-storage", "rw");
         ap.applyAndSwithToUser(USER_TEST, GROUP_APP);
 
@@ -2497,7 +2495,7 @@ RUNNER_TEST(T1511_insert_data)
     // actual test
     {
         ScopedDBUnlock unlock(USER_TEST, APP_PASS);
-        ScopedAccessProvider ap("my-label");
+        ScopedAccessProvider ap(TEST_LABEL);
         ap.allowAPI("key-manager::api-storage", "rw");
         ap.applyAndSwithToUser(USER_TEST, GROUP_APP);
 
@@ -2524,7 +2522,7 @@ RUNNER_TEST(T1701_init_unlock_key)
 {
     unlock_user_data(USER_TEST+1, "t170-special-password");
 
-    ScopedAccessProvider ap("t170-special-label");
+    ScopedAccessProvider ap(TEST_LABEL_5);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+1, GROUP_APP);
 }
@@ -2532,7 +2530,7 @@ RUNNER_TEST(T1701_init_unlock_key)
 RUNNER_CHILD_TEST(T1702_insert_data)
 {
     int temp;
-    ScopedAccessProvider ap("t170-special-label");
+    ScopedAccessProvider ap(TEST_LABEL_5);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+1, GROUP_APP);
 
@@ -2560,14 +2558,14 @@ RUNNER_TEST(T1703_removeApplicationData)
     int tmp;
     auto control = CKM::Control::create();
     RUNNER_ASSERT_MSG(
-        CKM_API_SUCCESS == (tmp = control->removeApplicationData("t170-special-label")),
+        CKM_API_SUCCESS == (tmp = control->removeApplicationData(TEST_LABEL_5)),
         "Error=" << CKMErrorToString(tmp));
 }
 
 RUNNER_CHILD_TEST(T1704_data_test)
 {
     int temp;
-    ScopedAccessProvider ap("t170-special-label");
+    ScopedAccessProvider ap(TEST_LABEL_5);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+1, GROUP_APP);
 
@@ -2616,7 +2614,7 @@ RUNNER_TEST(T17101_init)
 RUNNER_CHILD_TEST(T17102_prep_data_01)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+2, GROUP_APP);
 
@@ -2636,7 +2634,7 @@ RUNNER_CHILD_TEST(T17102_prep_data_01)
 RUNNER_CHILD_TEST(T17103_prep_data_02)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label2");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+2, GROUP_APP);
 
@@ -2656,7 +2654,7 @@ RUNNER_CHILD_TEST(T17103_prep_data_02)
 RUNNER_CHILD_TEST(T17104_prep_data_03)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+3, GROUP_APP);
 
@@ -2676,7 +2674,7 @@ RUNNER_CHILD_TEST(T17104_prep_data_03)
 RUNNER_CHILD_TEST(T17105_prep_data_04)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label2");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+3, GROUP_APP);
 
@@ -2702,14 +2700,14 @@ RUNNER_TEST(T17106_remove_application)
         CKM_API_SUCCESS == (tmp = control->lockUserKey(USER_TEST+3)),
         "Error=" << CKMErrorToString(tmp));
     RUNNER_ASSERT_MSG(
-        CKM_API_SUCCESS == (tmp = control->removeApplicationData("t1706-special-label")),
+        CKM_API_SUCCESS == (tmp = control->removeApplicationData(TEST_LABEL)),
         "Error=" << CKMErrorToString(tmp));
 }
 
 RUNNER_CHILD_TEST(T17107_check_data_01)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+2, GROUP_APP);
 
@@ -2727,7 +2725,7 @@ RUNNER_CHILD_TEST(T17107_check_data_01)
 RUNNER_CHILD_TEST(T17108_check_data_02)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label2");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+2, GROUP_APP);
 
@@ -2755,7 +2753,7 @@ RUNNER_TEST(T17109_unlock_user2)
 RUNNER_CHILD_TEST(T17110_check_data_03)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label");
+    ScopedAccessProvider ap(TEST_LABEL);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+3, GROUP_APP);
 
@@ -2773,7 +2771,7 @@ RUNNER_CHILD_TEST(T17110_check_data_03)
 RUNNER_CHILD_TEST(T17111_check_data_04)
 {
     int temp;
-    ScopedAccessProvider ap("t1706-special-label2");
+    ScopedAccessProvider ap(TEST_LABEL_2);
     ap.allowAPI("key-manager::api-storage", "rw");
     ap.applyAndSwithToUser(USER_TEST+3, GROUP_APP);
 
index e9cf43a..5186138 100644 (file)
@@ -42,12 +42,9 @@ const uid_t GROUP_APP           = 5050;
 const char* APP_PASS            = "user-pass";
 
 const char* TEST_ALIAS          = "test-alias";
-const char* SYSTEM_LABEL        = ckmc_owner_id_system;
 const char* INVALID_LABEL       = "coco-jumbo";
 std::string TEST_SYSTEM_ALIAS   = aliasWithLabel(SYSTEM_LABEL, TEST_ALIAS);
 std::string TEST_SYSTEM_ALIAS_2 = aliasWithLabel(SYSTEM_LABEL, "test-alias-2");
-const char* TEST_LABEL          = "test-label";
-const char* TEST_LABEL_2        = "test-label-2";
 
 const char* TEST_DATA =
         "Lorem Ipsum. At vero eos et accusamus et iusto odio dignissimos ducimus "