CKM::ErrorToString removed from key-manager
[platform/core/test/security-tests.git] / src / ckm-integration / process-settings / unlock-ckm.cpp
1 /*
2  *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16 /*
17  * @file       unlock-ckm.cpp
18  * @author     Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version    1.0
20  */
21 #include <ckm/ckm-control.h>
22
23 #include <ckm-common.h>
24 #include <tests_common.h>
25
26 #include <process-settings/unlock-ckm.h>
27
28 namespace ProcessSettings {
29
30 UnlockCkm::UnlockCkm(const Policy &policy)
31   : m_policy(policy)
32 {}
33
34 void UnlockCkm::Apply() {
35     int temp;
36
37     m_uid = m_policy.GetUid();
38
39     auto control = CKM::Control::create();
40
41     // Let's clean up environment.
42     // It will usually fails.
43     control->removeUserData(m_uid);
44
45     RUNNER_ASSERT_MSG(
46         CKM_API_SUCCESS == (temp = control->unlockUserKey(m_uid, "DummyPassword")),
47         "Error=" << CKMErrorToString(temp));
48
49 }
50
51 void UnlockCkm::Revoke() {
52     int temp;
53     auto control = CKM::Control::create();
54     RUNNER_ASSERT_MSG(
55         CKM_API_SUCCESS == (temp = control->removeUserData(m_uid)),
56         "Error=" << CKMErrorToString(temp));
57 }
58
59 UnlockCkm::~UnlockCkm() {}
60
61 } // namespace ProcessSettings
62