Rename /tests to /ckm to align with tizen branch
[platform/core/test/security-tests.git] / src / cynara-tests / common / cynara_test_client.cpp
1 /*
2  * Copyright (c) 2014 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 #include <cynara_test_client.h>
18
19 #include <tests_common.h>
20
21 namespace CynaraTestClient {
22
23 Client::Client()
24     : m_cynara(nullptr)
25 {
26     int ret = cynara_initialize(&m_cynara, nullptr);
27     RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
28                          "cynara_initialize failed. ret: " << ret);
29     RUNNER_ASSERT_MSG(m_cynara != nullptr, "cynara struct was not initialized");
30 }
31
32 Client::~Client()
33 {
34     cynara_finish(m_cynara);
35 }
36
37 void Client::check(const char *client, const char *session,
38                    const char *user, const char *privilege,
39                    int expectedResult)
40 {
41     int ret = cynara_check(m_cynara, client, session, user, privilege);
42     RUNNER_ASSERT_MSG(ret == expectedResult,
43                          "cynara_check returned wrong value: "
44                              << ret << " != " << expectedResult << "."
45                              << " client: " << formatCstr(client) << ","
46                              << " session: " << formatCstr(session) << ","
47                              << " user: " << formatCstr(user) << ","
48                              << " privilege: " << formatCstr(privilege));
49 }
50
51 } //namespace CynaraTestClient