c7337d698896058ba49d47202aced41cd4f8d619
[platform/core/test/security-tests.git] / tests / ckm / capi-access_control.cpp
1 #include <sys/types.h>
2 #include <sys/wait.h>
3
4 #include <dpl/test/test_runner.h>
5 #include <dpl/test/test_runner_child.h>
6
7 #include <tests_common.h>
8 #include <ckm-common.h>
9 #include <access_provider2.h>
10
11 #include <ckmc/ckmc-manager.h>
12 #include <ckmc/ckmc-control.h>
13 #include <ckmc/ckmc-type.h>
14 #include <ckmc/ckmc-error.h>
15
16 #include <ckm/ckm-type.h>
17
18 namespace {
19
20 const uid_t USER_ROOT = 0;
21 const char* APP_PASS = "user-pass";
22 const char* ROOT_PASS = "test-pass";
23
24 const char* NO_ALIAS = "definitely-non-existent-alias";
25 const char* NO_OWNER = "definitely-non-existent-owner";
26
27 const char* TEST_ALIAS = "test-alias";
28 const char* TEST_ALIAS2 = "test-alias2";
29 const char* TEST_ALIAS3 = "test-alias3";
30
31 const char* TEST_LABEL = "test-label";
32 const char* TEST_LABEL2 = "test-label2";
33
34 const char* TEST_DATA = "dsflsdkghkslhglrtghierhgilrehgidsafasdffsgfdgdgfdgfdgfdgfdggf";
35
36 void save_data(const char* alias)
37 {
38     ckmc_raw_buffer_s buffer;
39     buffer.data = reinterpret_cast<unsigned char*>(const_cast<char*>(TEST_DATA));
40     buffer.size = strlen(TEST_DATA);
41     ckmc_policy_s policy;
42     policy.password = NULL;
43     policy.extractable = true;
44
45     int ret = ckmc_save_data(alias, buffer, policy);
46     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Saving data failed. Error: " << ret);
47 }
48
49 void check_remove_allowed(const char* alias)
50 {
51     int ret = ckmc_remove_data(alias);
52     // remove, but ignore non existing
53     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret || CKMC_ERROR_DB_ALIAS_UNKNOWN,
54                          "Removing data failed: " << ret);
55 }
56
57 void check_remove_denied(const char* alias)
58 {
59     int ret = ckmc_remove_data(alias);
60     RUNNER_ASSERT_MSG(
61             CKMC_ERROR_PERMISSION_DENIED == ret,
62             "App with different label shouldn't have rights to remove this data. Error: " << ret);
63 }
64
65 void check_read_allowed(const char* alias)
66 {
67     // try to read previously saved data
68     ckmc_raw_buffer_s* buffer = NULL;
69     int ret = ckmc_get_data(alias, NULL, &buffer);
70     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Getting data failed. Error: " << ret);
71
72     // compare data with expected
73     RUNNER_ASSERT_MSG(
74             buffer->size == strlen(TEST_DATA),
75             "Extracted data length do not match expected data length (encrypted?).");
76
77     RUNNER_ASSERT_MSG(
78             memcmp(const_cast<const char*>(reinterpret_cast<char*>(buffer->data)), TEST_DATA, buffer->size) == 0,
79             "Extracted data do not match expected data (encrypted?).");
80     ckmc_buffer_free(buffer);
81 }
82
83 void check_read_denied(const char* alias)
84 {
85     // try to read previously saved data
86     ckmc_raw_buffer_s* buffer = NULL;
87     int ret = ckmc_get_data(alias, NULL, &buffer);
88     RUNNER_ASSERT_MSG(CKMC_ERROR_PERMISSION_DENIED == ret,
89                          "App with different label shouldn't have rights to read this data. Error: "
90                          << ret);
91     ckmc_buffer_free(buffer);
92 }
93
94 void allow_access(const char* alias, const char* accessor, ckmc_access_right_e rights)
95 {
96     // data removal should revoke this access
97     int ret = ckmc_allow_access(alias, accessor, rights);
98     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Trying to allow access returned: " << ret);
99 }
100
101 void deny_access(const char* alias, const char* accessor)
102 {
103     int ret = ckmc_deny_access(alias, accessor);
104     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Denying access failed. Error: " << ret);
105 }
106
107 void allow_access_by_adm(const char* alias, const char* accessor, ckmc_access_right_e rights)
108 {
109     // data removal should revoke this access
110     CharPtr label = get_label();
111     int ret = ckmc_allow_access_by_adm(USER_ROOT, label.get(), alias, accessor, rights);
112     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Trying to allow access returned: " << ret);
113 }
114
115 void deny_access_by_adm(const char* alias, const char* accessor)
116 {
117     CharPtr label = get_label();
118     int ret = ckmc_deny_access_by_adm(USER_ROOT, label.get(), alias, accessor);
119     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == ret, "Denying access failed. Error: " << ret);
120 }
121
122 int count_aliases()
123 {
124     ckmc_alias_list_s *aliasList = NULL;
125     int ret = ckmc_get_data_alias_list(&aliasList);
126     if (ret == CKMC_ERROR_DB_ALIAS_UNKNOWN)
127         return 0;
128
129     RUNNER_ASSERT_MSG(ret == 0, "Failed to get the list of data aliases. Error: " << ret);
130
131     ckmc_alias_list_s *plist = aliasList;
132     int count = 0;
133     while(plist)
134     {
135         plist = plist->next;
136         count++;
137     }
138     ckmc_alias_list_all_free(aliasList);
139     return count;
140 }
141
142 void check_alias_count(int expected)
143 {
144     int count = count_aliases();
145     RUNNER_ASSERT_MSG(count == expected, "Expected " << expected << " aliases, got " << count);
146 }
147
148 // saves data upon construction and deletes it upon destruction
149 class ScopedSaveData
150 {
151 public:
152     ScopedSaveData(const char* alias) : m_alias(alias)
153     {
154         save_data(alias);
155     }
156
157     ~ScopedSaveData()
158     {
159         /*
160          * Let it throw. If we can't remove data then remaining tests results will be
161          * unreliable anyway.
162          */
163         check_remove_allowed(m_alias);
164     }
165 private:
166     const char* m_alias;
167 };
168
169 } // namespace anonymous
170
171 RUNNER_TEST_GROUP_INIT (T300_CKMC_ACCESS_CONTROL_C_API);
172
173
174 /////////////////////////////////////////////////////////////////////////////
175 // Manager
176 RUNNER_TEST(T3000_init)
177 {
178     int temp;
179     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(APP_UID, APP_PASS)),
180                          "Error=" << temp);
181     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(APP_UID)),
182                          "Error=" << temp);
183     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_ROOT, ROOT_PASS)),
184                          "Error=" << temp);
185     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_ROOT)),
186                          "Error=" << temp);
187
188 }
189
190 // invalid arguments check
191 RUNNER_TEST(T3001_manager_allow_access_invalid)
192 {
193     RUNNER_ASSERT(
194             CKMC_ERROR_INVALID_PARAMETER == ckmc_allow_access(NULL, "accessor", CKMC_AR_READ));
195     RUNNER_ASSERT(
196             CKMC_ERROR_INVALID_PARAMETER == ckmc_allow_access("alias", NULL, CKMC_AR_READ));
197 }
198
199 // invalid arguments check
200 RUNNER_TEST(T3002_manager_deny_access_invalid)
201 {
202     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER == ckmc_deny_access(NULL, "accessor"));
203     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER == ckmc_deny_access("alias", NULL));
204 }
205
206 // tries to allow access for non existing alias
207 RUNNER_CHILD_TEST(T3003_manager_allow_access_non_existing)
208 {
209     switch_to_storage_user(TEST_LABEL);
210
211     int ret = ckmc_allow_access(NO_ALIAS, "label", CKMC_AR_READ);
212     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
213                          "Allowing access for non existing alias returned " << ret);
214 }
215
216 // tries to deny access for non existing alias
217 RUNNER_CHILD_TEST(T3004_manager_deny_access_non_existing)
218 {
219     switch_to_storage_user(TEST_LABEL);
220
221     int ret = ckmc_deny_access(NO_ALIAS, "label");
222     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
223                          "Denying access for non existing alias returned " << ret);
224 }
225
226 // tries to deny access that does not exist in database
227 RUNNER_CHILD_TEST(T3005_manager_deny_access_non_existing_access)
228 {
229     switch_to_storage_user(TEST_LABEL);
230
231     ScopedSaveData ssd(TEST_ALIAS);
232
233     // deny non existing access to existing alias
234     int ret = ckmc_deny_access(TEST_ALIAS, "label");
235     RUNNER_ASSERT_MSG(CKMC_ERROR_INVALID_PARAMETER == ret,
236                          "Denying non existing access returned: " << ret);
237 }
238
239 // tries to allow access to application own data
240 RUNNER_CHILD_TEST(T3006_manager_allow_access_to_myself)
241 {
242     switch_to_storage_user(TEST_LABEL);
243
244     ScopedSaveData ssd(TEST_ALIAS);
245
246     CharPtr label = get_label();
247     int ret = ckmc_allow_access(TEST_ALIAS, label.get(), CKMC_AR_READ);
248     RUNNER_ASSERT_MSG(CKMC_ERROR_INVALID_PARAMETER == ret,
249                          "Trying to allow myself returned: " << ret);
250 }
251
252 // tries to access other application data without permission
253 RUNNER_TEST(T3020_manager_access_not_allowed)
254 {
255     ScopedSaveData ssd(TEST_ALIAS);
256     {
257         ScopedLabel sl(TEST_LABEL2);
258
259         check_read_denied(TEST_ALIAS);
260
261         check_remove_denied(TEST_ALIAS);
262     }
263 }
264
265 // tries to access other application data with permission
266 RUNNER_TEST(T3021_manager_access_allowed)
267 {
268     ScopedSaveData ssd(TEST_ALIAS);
269
270     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
271     {
272         ScopedLabel sl(TEST_LABEL2);
273
274         check_read_allowed(TEST_ALIAS);
275     }
276 }
277
278 // tries to read other application data with permission for read/remove
279 RUNNER_TEST(T3022_manager_access_allowed_with_remove)
280 {
281     ScopedSaveData ssd(TEST_ALIAS);
282
283     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
284     {
285         ScopedLabel sl(TEST_LABEL2);
286
287         check_read_allowed(TEST_ALIAS);
288     }
289 }
290
291 // tries to remove other application data with permission for reading only
292 RUNNER_TEST(T3023_manager_access_allowed_remove_denied)
293 {
294     ScopedSaveData ssd(TEST_ALIAS);
295
296     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
297     {
298         ScopedLabel sl(TEST_LABEL2);
299
300         check_remove_denied(TEST_ALIAS);
301
302         check_read_allowed(TEST_ALIAS);
303     }
304 }
305
306 // tries to remove other application data with permission
307 RUNNER_TEST(T3025_manager_remove_allowed)
308 {
309     ScopedSaveData ssd(TEST_ALIAS);
310
311     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
312     {
313         ScopedLabel sl(TEST_LABEL2);
314
315         check_remove_allowed(TEST_ALIAS);
316     }
317 }
318
319 // tries to access other application data after allow funciton was called twice with different
320 // rights
321 RUNNER_TEST(T3026_manager_double_allow)
322 {
323     ScopedSaveData ssd(TEST_ALIAS);
324
325     // access should be overwritten
326     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
327     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
328     {
329         ScopedLabel sl(TEST_LABEL2);
330
331         check_remove_denied(TEST_ALIAS);
332
333         check_read_allowed(TEST_ALIAS);
334     }
335 }
336
337 // tries to access application data with permission and after permission has been revoked
338 RUNNER_TEST(T3027_manager_allow_deny)
339 {
340     ScopedSaveData ssd(TEST_ALIAS);
341
342     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
343     {
344         ScopedLabel sl(TEST_LABEL2);
345
346         check_remove_denied(TEST_ALIAS);
347
348         check_read_allowed(TEST_ALIAS);
349     }
350
351     deny_access(TEST_ALIAS, TEST_LABEL2);
352     {
353         ScopedLabel sl(TEST_LABEL2);
354
355         check_remove_denied(TEST_ALIAS);
356
357         check_read_denied(TEST_ALIAS);
358     }
359 }
360
361
362 // checks if only aliases readable by given app are returned
363 RUNNER_TEST(T3030_manager_get_all_aliases)
364 {
365     ScopedSaveData ssd1(TEST_ALIAS);
366     ScopedSaveData ssd2(TEST_ALIAS2);
367
368     int count = count_aliases();
369
370     allow_access(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
371     {
372         ScopedLabel sl(TEST_LABEL2);
373
374         // check that app can access other aliases when it has permission
375         check_alias_count(count - 1);
376
377         ScopedSaveData ssd3(TEST_ALIAS3);
378
379         // check that app can access its own aliases
380         check_alias_count(count - 1 + 1);
381     }
382
383     deny_access(TEST_ALIAS, TEST_LABEL2);
384     {
385         ScopedLabel sl(TEST_LABEL2);
386
387         // check that app can't access other aliases for which permission has been revoked
388         check_alias_count(count - 2);
389     }
390 }
391
392 /////////////////////////////////////////////////////////////////////////////
393 // Control
394
395 // invalid argument check
396 RUNNER_TEST(T3101_control_allow_access_invalid)
397 {
398     int ret;
399     ret = ckmc_allow_access_by_adm(USER_ROOT, NULL, "alias", "accessor", CKMC_AR_READ);
400     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER == ret);
401     ret = ckmc_allow_access_by_adm(USER_ROOT, "owner", NULL, "accessor", CKMC_AR_READ);
402     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER == ret);
403     ret = ckmc_allow_access_by_adm(USER_ROOT, "owner", "alias", NULL, CKMC_AR_READ);
404     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER == ret);
405 }
406
407 // invalid argument check
408 RUNNER_TEST(T3102_control_deny_access_invalid)
409 {
410     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER ==
411             ckmc_deny_access_by_adm(USER_ROOT, NULL, "alias", "accessor"));
412     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER ==
413             ckmc_deny_access_by_adm(USER_ROOT, "owner", NULL, "accessor"));
414     RUNNER_ASSERT(CKMC_ERROR_INVALID_PARAMETER ==
415             ckmc_deny_access_by_adm(USER_ROOT, "owner", "alias", NULL));
416 }
417
418 // tries to allow access for non existing alias
419 RUNNER_TEST(T3103_control_allow_access_non_existing)
420 {
421     int ret = ckmc_allow_access_by_adm(USER_ROOT, NO_OWNER, NO_ALIAS, "label", CKMC_AR_READ);
422     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
423                          "Allowing access for non existing alias returned " << ret);
424 }
425
426 // tries to deny access for non existing alias
427 RUNNER_TEST(T3104_control_deny_access_non_existing)
428 {
429     int ret = ckmc_deny_access_by_adm(USER_ROOT, NO_OWNER, NO_ALIAS, "label");
430     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
431                          "Denying access for non existing alias returned " << ret);
432 }
433
434 // tries to deny non existing access
435 RUNNER_TEST(T3105_control_deny_access_non_existing_access)
436 {
437     ScopedSaveData ssd(TEST_ALIAS);
438
439     CharPtr label = get_label();
440
441     // deny non existing access to existing alias
442     int ret = ckmc_deny_access_by_adm(USER_ROOT, label.get(), TEST_ALIAS, "label");
443     RUNNER_ASSERT_MSG(CKMC_ERROR_INVALID_PARAMETER == ret,
444                          "Denying non existing access returned: " << ret);
445 }
446
447 // tries to allow application to access its own data
448 RUNNER_TEST(T3106_control_allow_access_to_myself)
449 {
450     ScopedSaveData ssd(TEST_ALIAS);
451
452     CharPtr label = get_label();
453     int ret = ckmc_allow_access(TEST_ALIAS, label.get(), CKMC_AR_READ);
454     RUNNER_ASSERT_MSG(CKMC_ERROR_INVALID_PARAMETER == ret,
455                          "Trying to allow myself returned: " << ret);
456 }
457
458 // tries to use admin API as a user
459 RUNNER_CHILD_TEST(T3110_control_allow_access_as_user)
460 {
461     RUNNER_IGNORED_MSG("Fixed in next version of ckm!");
462     switch_to_storage_user(TEST_LABEL);
463     int ret = ckmc_allow_access_by_adm(USER_ROOT, "owner", "alias", "accessor", CKMC_AR_READ);
464     RUNNER_ASSERT_MSG(CKMC_ERROR_PERMISSION_DENIED == ret,
465                          "Ordinary user should not be able to use control API. Error " << ret);
466 }
467
468 // tries to use admin API as a user
469 RUNNER_CHILD_TEST(T3111_control_allow_access_as_user)
470 {
471     RUNNER_IGNORED_MSG("Fixed in next version of ckm!");
472     switch_to_storage_user(TEST_LABEL);
473     int ret = ckmc_deny_access_by_adm(USER_ROOT, "owner", "alias", "accessor");
474     RUNNER_ASSERT_MSG(CKMC_ERROR_PERMISSION_DENIED == ret,
475                          "Ordinary user should not be able to use control API. Error " << ret);
476 }
477
478 // tries to read other application data with permission
479 RUNNER_TEST(T3121_control_access_allowed)
480 {
481     ScopedSaveData ssd(TEST_ALIAS);
482
483     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
484     {
485         ScopedLabel sl(TEST_LABEL2);
486
487         check_read_allowed(TEST_ALIAS);
488     }
489 }
490
491 // tries to read other application data with permission to read/remove
492 RUNNER_TEST(T3122_control_access_allowed_with_remove)
493 {
494     ScopedSaveData ssd(TEST_ALIAS);
495
496     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
497     {
498         ScopedLabel sl(TEST_LABEL2);
499
500         check_read_allowed(TEST_ALIAS);
501     }
502 }
503
504 // tries to remove other application data with permission to read
505 RUNNER_TEST(T3122_control_access_allowed_remove_denied)
506 {
507     ScopedSaveData ssd(TEST_ALIAS);
508
509     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
510     {
511         ScopedLabel sl(TEST_LABEL2);
512
513         check_remove_denied(TEST_ALIAS);
514     }
515 }
516
517 // tries to remove other application data with permission
518 RUNNER_TEST(T3125_control_remove_allowed)
519 {
520     ScopedSaveData ssd(TEST_ALIAS);
521
522     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
523     {
524         ScopedLabel sl(TEST_LABEL2);
525
526         check_remove_allowed(TEST_ALIAS);
527     }
528 }
529
530 // tries to access other application data after allow function has been called twice with different
531 // rights
532 RUNNER_TEST(T3126_control_double_allow)
533 {
534     ScopedSaveData ssd(TEST_ALIAS);
535
536     // access should be overwritten
537     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
538     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
539     {
540         ScopedLabel sl(TEST_LABEL2);
541
542         check_remove_denied(TEST_ALIAS);
543
544         check_read_allowed(TEST_ALIAS);
545     }
546 }
547
548 // tries to access other application data with permission and after permission has been revoked
549 RUNNER_TEST(T3127_control_allow_deny)
550 {
551     ScopedSaveData ssd(TEST_ALIAS);
552
553     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
554     {
555         ScopedLabel sl(TEST_LABEL2);
556
557         check_remove_denied(TEST_ALIAS);
558
559         check_read_allowed(TEST_ALIAS);
560     }
561     CharPtr label = get_label();
562     deny_access_by_adm(TEST_ALIAS, TEST_LABEL2);
563     {
564         ScopedLabel sl(TEST_LABEL2);
565
566         check_remove_denied(TEST_ALIAS);
567
568         check_read_denied(TEST_ALIAS);
569     }
570 }
571
572 // checks if only aliases readable by given app are returned
573 RUNNER_TEST(T3130_control_get_all_aliases)
574 {
575     ScopedSaveData ssd1(TEST_ALIAS);
576     ScopedSaveData ssd2(TEST_ALIAS2);
577
578     int count = count_aliases();
579
580     allow_access_by_adm(TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ);
581     {
582         ScopedLabel sl(TEST_LABEL2);
583
584         // check that app can access other aliases when it has permission
585         check_alias_count(count - 1);
586
587         ScopedSaveData ssd3(TEST_ALIAS3);
588
589         // check that app can access its own aliases
590         check_alias_count(count - 1 + 1);
591     }
592
593     deny_access_by_adm(TEST_ALIAS, TEST_LABEL2);
594     {
595         ScopedLabel sl(TEST_LABEL2);
596
597         // check that app can't access other aliases for which permission has been revoked
598         check_alias_count(count - 2);
599     }
600 }
601
602 // tries to add access to data in a database of invalid user
603 RUNNER_TEST(T3140_control_allow_invalid_user)
604 {
605     ScopedSaveData ssd(TEST_ALIAS);
606
607     CharPtr label = get_label();
608     int ret = ckmc_allow_access_by_adm(
609             APP_UID, label.get(), TEST_ALIAS, TEST_LABEL2, CKMC_AR_READ_REMOVE);
610     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
611                          "Trying to allow access to invalid user returned: " << ret);
612 }
613
614 // tries to revoke access to data in a database of invalid user
615 RUNNER_TEST(T3141_control_deny_invalid_user)
616 {
617     ScopedSaveData ssd(TEST_ALIAS);
618
619     CharPtr label = get_label();
620     int ret = ckmc_deny_access_by_adm(APP_UID, label.get(), TEST_ALIAS, TEST_LABEL2);
621     RUNNER_ASSERT_MSG(CKMC_ERROR_DB_ALIAS_UNKNOWN == ret,
622                          "Trying to deny access to invalid user returned: " << ret);
623 }
624
625
626 RUNNER_TEST(T3999_deinit)
627 {
628     int temp;
629     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(APP_UID)),
630                          "Error=" << temp);
631     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(APP_UID)),
632                          "Error=" << temp);
633     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_ROOT)),
634                          "Error=" << temp);
635     RUNNER_ASSERT_MSG(CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_ROOT)),
636                          "Error=" << temp);
637 }