2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file test/common/protocols/admin/admincheckresponse.cpp
18 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
20 * @brief Tests for Cynara::AdminCheckResponse usage in Cynara::ProtocolAdmin
23 #include <gtest/gtest.h>
25 #include <protocol/ProtocolAdmin.h>
26 #include <response/AdminCheckResponse.h>
28 #include <ResponseTestHelper.h>
29 #include <TestDataCollection.h>
34 void compare(const Cynara::AdminCheckResponse &resp1, const Cynara::AdminCheckResponse &resp2) {
35 EXPECT_EQ(resp1.result(), resp2.result());
36 EXPECT_EQ(resp1.isBucketValid(), resp2.isBucketValid());
39 static const bool VALID_BUCKET = true;
40 static const bool NO_BUCKET = false;
42 } /* anonymous namespace */
44 using namespace Cynara;
45 using namespace ResponseTestHelper;
46 using namespace TestDataCollection;
48 /* *** compare by objects test cases *** */
50 TEST(ProtocolAdmin, AdminCheckResponse01) {
51 auto response = std::make_shared<AdminCheckResponse>(Results::allow, VALID_BUCKET, SN::min);
52 auto protocol = std::make_shared<ProtocolAdmin>();
53 testResponse(response, protocol);
56 TEST(ProtocolAdmin, AdminCheckResponse02) {
57 auto response = std::make_shared<AdminCheckResponse>(Results::deny, NO_BUCKET, SN::min_1);
58 auto protocol = std::make_shared<ProtocolAdmin>();
59 testResponse(response, protocol);
62 TEST(ProtocolAdmin, AdminCheckResponse03) {
63 auto response = std::make_shared<AdminCheckResponse>(Results::bucket_empty, VALID_BUCKET,
65 auto protocol = std::make_shared<ProtocolAdmin>();
66 testResponse(response, protocol);
69 TEST(ProtocolAdmin, AdminCheckResponse04) {
70 auto response = std::make_shared<AdminCheckResponse>(Results::bucket_not_empty, NO_BUCKET,
72 auto protocol = std::make_shared<ProtocolAdmin>();
73 testResponse(response, protocol);
76 TEST(ProtocolAdmin, AdminCheckResponse05) {
77 auto response = std::make_shared<AdminCheckResponse>(Results::none, VALID_BUCKET, SN::max_1);
78 auto protocol = std::make_shared<ProtocolAdmin>();
79 testResponse(response, protocol);
82 TEST(ProtocolAdmin, AdminCheckResponse06) {
83 auto response = std::make_shared<AdminCheckResponse>(Results::plugin_1, NO_BUCKET, SN::max_2);
84 auto protocol = std::make_shared<ProtocolAdmin>();
85 testResponse(response, protocol);
88 TEST(ProtocolAdmin, AdminCheckResponse07) {
89 auto response = std::make_shared<AdminCheckResponse>(Results::plugin_2, VALID_BUCKET, SN::mid);
90 auto protocol = std::make_shared<ProtocolAdmin>();
91 testResponse(response, protocol);
94 /* *** compare by serialized data test cases *** */
96 TEST(ProtocolAdmin, AdminCheckResponseBinary01) {
97 auto response = std::make_shared<AdminCheckResponse>(Results::allow, VALID_BUCKET, SN::min);
98 auto protocol = std::make_shared<ProtocolAdmin>();
99 binaryTestResponse(response, protocol);
102 TEST(ProtocolAdmin, AdminCheckResponseBinary02) {
103 auto response = std::make_shared<AdminCheckResponse>(Results::deny, NO_BUCKET, SN::min_1);
104 auto protocol = std::make_shared<ProtocolAdmin>();
105 binaryTestResponse(response, protocol);
108 TEST(ProtocolAdmin, AdminCheckResponseBinary03) {
109 auto response = std::make_shared<AdminCheckResponse>(Results::bucket_empty, VALID_BUCKET,
111 auto protocol = std::make_shared<ProtocolAdmin>();
112 binaryTestResponse(response, protocol);
115 TEST(ProtocolAdmin, AdminCheckResponseBinary04) {
116 auto response = std::make_shared<AdminCheckResponse>(Results::bucket_not_empty, NO_BUCKET,
118 auto protocol = std::make_shared<ProtocolAdmin>();
119 binaryTestResponse(response, protocol);
122 TEST(ProtocolAdmin, AdminCheckResponseBinary05) {
123 auto response = std::make_shared<AdminCheckResponse>(Results::none, VALID_BUCKET, SN::max_1);
124 auto protocol = std::make_shared<ProtocolAdmin>();
125 binaryTestResponse(response, protocol);
128 TEST(ProtocolAdmin, AdminCheckResponseBinary06) {
129 auto response = std::make_shared<AdminCheckResponse>(Results::plugin_1, NO_BUCKET, SN::max_2);
130 auto protocol = std::make_shared<ProtocolAdmin>();
131 binaryTestResponse(response, protocol);
134 TEST(ProtocolAdmin, AdminCheckResponseBinary07) {
135 auto response = std::make_shared<AdminCheckResponse>(Results::plugin_2, VALID_BUCKET, SN::mid);
136 auto protocol = std::make_shared<ProtocolAdmin>();
137 binaryTestResponse(response, protocol);