SET(CYNARA_SRC ${PROJECT_SOURCE_DIR}/src)
SET(CYNARA_SOURCES_FOR_TESTS
+ ${CYNARA_SRC}/common/containers/BinaryQueue.cpp
+ ${CYNARA_SRC}/common/protocol/ProtocolAdmin.cpp
+ ${CYNARA_SRC}/common/protocol/ProtocolFrame.cpp
+ ${CYNARA_SRC}/common/protocol/ProtocolFrameHeader.cpp
+ ${CYNARA_SRC}/common/protocol/ProtocolFrameSerializer.cpp
+ ${CYNARA_SRC}/common/request/AdminCheckRequest.cpp
+ ${CYNARA_SRC}/common/request/InsertOrUpdateBucketRequest.cpp
+ ${CYNARA_SRC}/common/request/ListRequest.cpp
+ ${CYNARA_SRC}/common/request/RemoveBucketRequest.cpp
+ ${CYNARA_SRC}/common/request/RequestTaker.cpp
+ ${CYNARA_SRC}/common/request/SetPoliciesRequest.cpp
+ ${CYNARA_SRC}/common/response/CheckResponse.cpp
+ ${CYNARA_SRC}/common/response/CodeResponse.cpp
+ ${CYNARA_SRC}/common/response/ListResponse.cpp
+ ${CYNARA_SRC}/common/response/ResponseTaker.cpp
${CYNARA_SRC}/common/types/PolicyBucket.cpp
${CYNARA_SRC}/common/types/PolicyKey.cpp
${CYNARA_SRC}/common/types/PolicyKeyHelpers.cpp
SET(CYNARA_TESTS_SOURCES
TestEventListenerProxy.cpp
common/exceptions/bucketrecordcorrupted.cpp
+ common/protocols/admin/listrequest.cpp
+ common/protocols/admin/listresponse.cpp
common/types/policybucket.cpp
credsCommons/parser/Parser.cpp
helpers.cpp
${CYNARA_SRC}/include
${CYNARA_SRC}
credsCommons/parser
+ common/protocols
)
ADD_EXECUTABLE(${TARGET_CYNARA_TESTS}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/CommonsTestHelper.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Common helper functions for tests of serialization by protocols
+ */
+
+#ifndef TEST_COMMON_PROTOCOLS_COMMONSTESTHELPER_H_
+#define TEST_COMMON_PROTOCOLS_COMMONSTESTHELPER_H_
+
+#include <gtest/gtest.h>
+
+namespace {
+
+template <typename R>
+void compare(const R &r1, const R &r2) {
+ (void) r1;
+ (void) r2;
+ ASSERT_FALSE("Specialization of compare function must be implemented!");
+}
+
+} /* namespace anonymous */
+
+#endif /* TEST_COMMON_PROTOCOLS_COMMONSTESTHELPER_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/RequestTestHelper.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Helper functions for tests of request serialization by protocols
+ */
+
+#ifndef TEST_COMMON_PROTOCOLS_REQUESTTESTHELPER_H_
+#define TEST_COMMON_PROTOCOLS_REQUESTTESTHELPER_H_
+
+#include <memory>
+
+#include <gtest/gtest.h>
+
+#include <containers/BinaryQueue.h>
+#include <containers/RawBuffer.h>
+#include <protocol/Protocol.h>
+#include <request/pointers.h>
+#include <request/RequestContext.h>
+#include <response/ResponseTaker.h>
+
+#include "CommonsTestHelper.h"
+
+namespace {
+namespace RequestTestHelper {
+
+template <typename R>
+void testRequest(std::shared_ptr<R> request, Cynara::ProtocolPtr protocol) {
+ auto queue = std::make_shared<Cynara::BinaryQueue>();
+ auto context = std::make_shared<Cynara::RequestContext>(Cynara::ResponseTakerPtr(), queue);
+
+ request->execute(request, protocol, context);
+
+ auto extractedRequest = protocol->extractRequestFromBuffer(queue);
+ ASSERT_TRUE(bool(extractedRequest));
+ ASSERT_EQ(queue->size(), 0);
+
+ compare(*request, dynamic_cast<R &>(*extractedRequest));
+}
+
+void binaryTestRequest(Cynara::RequestPtr request, Cynara::ProtocolPtr protocol) {
+ auto queue = std::make_shared<Cynara::BinaryQueue>();
+ auto context = std::make_shared<Cynara::RequestContext>(Cynara::ResponseTakerPtr(), queue);
+
+ request->execute(request, protocol, context);
+ Cynara::RawBuffer data(queue->size());
+ queue->flatten(data.data(), queue->size());
+
+ auto extractedRequest = protocol->extractRequestFromBuffer(queue);
+ ASSERT_TRUE(bool(extractedRequest));
+ ASSERT_EQ(queue->size(), 0);
+
+ extractedRequest->execute(extractedRequest, protocol, context);
+ Cynara::RawBuffer data2(queue->size());
+ queue->flatten(data2.data(), queue->size());
+
+ ASSERT_EQ(data, data2);
+}
+
+} /* namespace RequestTestHelper */
+} /* namespace anonymous */
+
+#endif /* TEST_COMMON_PROTOCOLS_REQUESTTESTHELPER_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/ResponseTestHelper.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Helper functions for tests of response serialization by protocols
+ */
+
+#ifndef TEST_COMMON_PROTOCOLS_RESPONSETESTHELPER_H_
+#define TEST_COMMON_PROTOCOLS_RESPONSETESTHELPER_H_
+
+#include <memory>
+
+#include <gtest/gtest.h>
+
+#include <containers/BinaryQueue.h>
+#include <containers/RawBuffer.h>
+#include <protocol/Protocol.h>
+#include <request/RequestContext.h>
+#include <response/pointers.h>
+#include <response/ResponseTaker.h>
+
+#include "CommonsTestHelper.h"
+
+namespace {
+namespace ResponseTestHelper {
+
+template <typename R>
+void testResponse(std::shared_ptr<R> response, Cynara::ProtocolPtr protocol) {
+ auto queue = std::make_shared<Cynara::BinaryQueue>();
+ auto context = std::make_shared<Cynara::RequestContext>(Cynara::ResponseTakerPtr(), queue);
+
+ response->execute(response, protocol, context);
+
+ auto extractedResponse = protocol->extractResponseFromBuffer(queue);
+ ASSERT_TRUE(bool(extractedResponse));
+ ASSERT_EQ(queue->size(), 0);
+
+ compare(*response, dynamic_cast<R &>(*extractedResponse));
+}
+
+void binaryTestResponse(Cynara::ResponsePtr response, Cynara::ProtocolPtr protocol) {
+ auto queue = std::make_shared<Cynara::BinaryQueue>();
+ auto context = std::make_shared<Cynara::RequestContext>(Cynara::ResponseTakerPtr(), queue);
+
+ response->execute(response, protocol, context);
+ Cynara::RawBuffer data(queue->size());
+ queue->flatten(data.data(), queue->size());
+
+ auto extractedResponse = protocol->extractResponseFromBuffer(queue);
+ ASSERT_TRUE(bool(extractedResponse));
+ ASSERT_EQ(queue->size(), 0);
+
+ extractedResponse->execute(extractedResponse, protocol, context);
+ Cynara::RawBuffer data2(queue->size());
+ queue->flatten(data2.data(), queue->size());
+
+ ASSERT_EQ(data, data2);
+}
+
+} /* namespace ResponseTestHelper */
+} /* namespace anonymous */
+
+#endif /* TEST_COMMON_PROTOCOLS_RESPONSETESTHELPER_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/TestDataCollection.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Collection of sample data for protocol tests
+ */
+
+#ifndef TEST_COMMON_PROTOCOLS_TESTDATACOLLECTION_H_
+#define TEST_COMMON_PROTOCOLS_TESTDATACOLLECTION_H_
+
+#include <cstdint>
+
+#include <types/PolicyBucketId.h>
+#include <types/PolicyKey.h>
+#include <types/PolicyResult.h>
+#include <types/PolicyType.h>
+#include <types/ProtocolFields.h>
+
+namespace {
+namespace TestDataCollection {
+
+typedef Cynara::PolicyKeyFeature PKF;
+
+namespace Keys {
+ static const Cynara::PolicyKey k_nun(PKF::create(""), PKF::create("u"), PKF::create(""));
+ static const Cynara::PolicyKey k_cup(PKF::create("c"), PKF::create("u"), PKF::create("p"));
+ static const Cynara::PolicyKey k_www(PKF::createWildcard(), PKF::createWildcard(),
+ PKF::createWildcard());
+ static const Cynara::PolicyKey k_wuw(PKF::createWildcard(), PKF::create("u"),
+ PKF::createWildcard());
+ static const Cynara::PolicyKey k_aaa(PKF::createAny(), PKF::createAny(), PKF::createAny());
+ static const Cynara::PolicyKey k_wua(PKF::createWildcard(), PKF::create("u"), PKF::createAny());
+ static const Cynara::PolicyKey k_nua(PKF::create(""), PKF::create("u"), PKF::createAny());
+} /* namespace Keys */
+
+namespace SN {
+ static const Cynara::ProtocolFrameSequenceNumber min(0);
+ static const Cynara::ProtocolFrameSequenceNumber min_1(min + 1);
+ static const Cynara::ProtocolFrameSequenceNumber min_2(min + 2);
+ static const Cynara::ProtocolFrameSequenceNumber max(UINT16_MAX);
+ static const Cynara::ProtocolFrameSequenceNumber max_1(max - 1);
+ static const Cynara::ProtocolFrameSequenceNumber max_2(max - 2);
+ static const Cynara::ProtocolFrameSequenceNumber mid((min + max) / 2);
+} /* namespace SN */
+
+namespace Buckets {
+ static const Cynara::PolicyBucketId empty("");
+ static const Cynara::PolicyBucketId not_empty("testBucket_1");
+} /* namespace Buckets */
+
+namespace Types {
+ static const Cynara::PolicyType allow(Cynara::PredefinedPolicyType::ALLOW);
+ static const Cynara::PolicyType deny(Cynara::PredefinedPolicyType::DENY);
+ static const Cynara::PolicyType bucket(Cynara::PredefinedPolicyType::BUCKET);
+ static const Cynara::PolicyType none(Cynara::PredefinedPolicyType::NONE);
+ static const Cynara::PolicyType plugin_type(100);
+} /* namespace Types */
+
+namespace Results {
+ static const Cynara::PolicyResult allow(Types::allow, "");
+ static const Cynara::PolicyResult deny(Types::deny, "");
+ static const Cynara::PolicyResult bucket_empty(Types::bucket, Buckets::empty);
+ static const Cynara::PolicyResult bucket_not_empty(Types::bucket, Buckets::not_empty);
+ static const Cynara::PolicyResult none(Types::none, "");
+ static const Cynara::PolicyResult plugin_1(Types::plugin_type, "");
+ static const Cynara::PolicyResult plugin_2(Types::plugin_type, "meta_data_2");
+} /* namespace Results */
+} /* namespace TestDataCollection */
+} /* namespace anonymous */
+
+#endif /* TEST_COMMON_PROTOCOLS_TESTDATACOLLECTION_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/admin/listrequest.cpp
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Tests for Cynara::ListRequest usage in Cynara::ProtocolAdmin
+ */
+
+#include <gtest/gtest.h>
+
+#include <protocol/ProtocolAdmin.h>
+#include <request/ListRequest.h>
+
+#include <RequestTestHelper.h>
+#include <TestDataCollection.h>
+
+namespace {
+
+template<>
+void compare(const Cynara::ListRequest &req1, const Cynara::ListRequest &req2) {
+ EXPECT_EQ(req1.bucket(), req2.bucket());
+ EXPECT_EQ(req1.filter(), req2.filter());
+}
+
+} /* namespace anonymous */
+
+using namespace Cynara;
+using namespace RequestTestHelper;
+using namespace TestDataCollection;
+
+/* *** compare by objects test cases *** */
+
+TEST(ProtocolAdmin, ListRequest01) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_nun, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest02) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_cup, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest03) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_www, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest04) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_wuw, SN::max);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest05) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_aaa, SN::max_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest06) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_wua, SN::max_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequest07) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_nua, SN::mid);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testRequest(request, protocol);
+}
+
+/* *** compare by serialized data test cases *** */
+
+TEST(ProtocolAdmin, ListRequestBinary01) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_nun, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary02) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_cup, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary03) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_www, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary04) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_wuw, SN::max);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary05) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_aaa, SN::max_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary06) {
+ auto request = std::make_shared<ListRequest>(Buckets::not_empty, Keys::k_wua, SN::max_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
+
+TEST(ProtocolAdmin, ListRequestBinary07) {
+ auto request = std::make_shared<ListRequest>(Buckets::empty, Keys::k_nua, SN::mid);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestRequest(request, protocol);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test/common/protocols/admin/listresponse.cpp
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief Tests for Cynara::ListResponse usage in Cynara::ProtocolAdmin
+ */
+
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include <protocol/ProtocolAdmin.h>
+#include <response/ListResponse.h>
+#include <types/Policy.h>
+
+#include <ResponseTestHelper.h>
+#include <TestDataCollection.h>
+
+namespace {
+
+template<>
+void compare(const Cynara::ListResponse &resp1, const Cynara::ListResponse &resp2) {
+ EXPECT_EQ(resp1.policies(), resp2.policies());
+ EXPECT_EQ(resp1.isBucketValid(), resp2.isBucketValid());
+}
+
+static const bool VALID_BUCKET = true;
+static const bool NO_BUCKET = false;
+
+} /* namespace anonymous */
+
+using namespace Cynara;
+using namespace ResponseTestHelper;
+using namespace TestDataCollection;
+
+/* *** compare by objects test cases *** */
+
+TEST(ProtocolAdmin, ListResponse01) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nun, Results::allow),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse02) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_cup, Results::deny),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse03) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_www, Results::bucket_empty),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse04) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_wuw, Results::bucket_not_empty),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse05) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_aaa, Results::none),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse06) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_wua, Results::plugin_1),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponse07) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nua, Results::plugin_2),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::mid);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseMultiplePolicies) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nun, Results::allow),
+ Policy(Keys::k_cup, Results::deny),
+ Policy(Keys::k_www, Results::bucket_empty),
+ Policy(Keys::k_wuw, Results::bucket_not_empty),
+ Policy(Keys::k_aaa, Results::none),
+ Policy(Keys::k_wua, Results::plugin_1),
+ Policy(Keys::k_nua, Results::plugin_2),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseEmptyPolicies) {
+ std::vector<Policy> policies;
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseNoBucket) {
+ std::vector<Policy> policies;
+
+ auto response = std::make_shared<ListResponse>(policies, NO_BUCKET, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ testResponse(response, protocol);
+}
+
+/* *** compare by serialized data test cases *** */
+
+TEST(ProtocolAdmin, ListResponseBinary01) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nun, Results::allow),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary02) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_cup, Results::deny),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary03) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_www, Results::bucket_empty),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary04) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_wuw, Results::bucket_not_empty),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary05) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_aaa, Results::none),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary06) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_wua, Results::plugin_1),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::max_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinary07) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nua, Results::plugin_2),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::mid);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinaryMultiplePolicies) {
+ std::vector<Policy> policies = {
+ Policy(Keys::k_nun, Results::allow),
+ Policy(Keys::k_cup, Results::deny),
+ Policy(Keys::k_www, Results::bucket_empty),
+ Policy(Keys::k_wuw, Results::bucket_not_empty),
+ Policy(Keys::k_aaa, Results::none),
+ Policy(Keys::k_wua, Results::plugin_1),
+ Policy(Keys::k_nua, Results::plugin_2),
+ };
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinaryEmptyPolicies) {
+ std::vector<Policy> policies;
+
+ auto response = std::make_shared<ListResponse>(policies, VALID_BUCKET, SN::min_1);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}
+
+TEST(ProtocolAdmin, ListResponseBinaryNoBucket) {
+ std::vector<Policy> policies;
+
+ auto response = std::make_shared<ListResponse>(policies, NO_BUCKET, SN::min_2);
+ auto protocol = std::make_shared<ProtocolAdmin>();
+ binaryTestResponse(response, protocol);
+}