Add Agent class wrapping usage of libcynara-agent
[platform/core/test/security-tests.git] / tests / cynara-tests / common / cynara_test_agent_response.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 #include <cynara_test_agent_response.h>
18 #include <plugins.h>
19 #include <cynara-agent.h>
20
21 namespace CynaraTestAgent {
22
23 std::ostream& operator<<(std::ostream& os, const AgentResponse &response)
24 {
25     os << "{";
26     os << " type = " << response.m_type << ",";
27     os << " id = " << response.m_id << ",";
28     os << " data = " << response.m_data;
29     os << " }";
30     return os;
31 }
32
33 AgentResponse AgentResponse::createAllow(cynara_agent_req_id id)
34 {
35     CynaraTestPlugins::AgentDataVector rawData = {CynaraTestPlugins::AGENT_DATA_ALLOW};
36     return AgentResponse(CYNARA_MSG_TYPE_ACTION, id, CynaraTestPlugins::wrapAgentData(rawData));
37 }
38
39 AgentResponse AgentResponse::createDeny(cynara_agent_req_id id)
40 {
41     CynaraTestPlugins::AgentDataVector rawData = {CynaraTestPlugins::AGENT_DATA_DENY};
42     return AgentResponse(CYNARA_MSG_TYPE_ACTION, id, CynaraTestPlugins::wrapAgentData(rawData));
43 }
44
45 AgentResponse AgentResponse::createCancel(cynara_agent_req_id id)
46 {
47     return AgentResponse(CYNARA_MSG_TYPE_CANCEL, id, Cynara::PluginData());
48 }
49
50 } // namespace CynaraTestAgent