lyndonb-bq commented on a change in pull request #8725:
URL: https://github.com/apache/arrow/pull/8725#discussion_r532762600
##########
File path: cpp/src/arrow/flight/flight_test.cc
##########
@@ -1186,6 +1188,139 @@ class TestBasicHeaderAuthMiddleware : public
::testing::Test {
std::shared_ptr<BearerAuthServerMiddlewareFactory> bearer_middleware_;
};
+// This test keeps an internal cookie cache and compares that with the
middleware.
+class TestCookieMiddleware : public ::testing::Test {
+ public:
+ // Setup function creates middleware factory and starts it up.
+ void SetUp() {
+ factory_ = GetCookieFactory();
+ CallInfo callInfo;
+ factory_->StartCall(callInfo, &middleware_);
+ }
+
+ // Function to add incoming cookies to middleware and validate them.
+ void AddAndValidate(const std::string& incoming_cookie) {
+ // Add cookie
+ CallHeaders call_headers;
+ call_headers.insert(std::make_pair(arrow::util::string_view("set-cookie"),
+
arrow::util::string_view(incoming_cookie)));
+ middleware_->ReceivedHeaders(call_headers);
+ expected_cookie_cache_.UpdateCachedCookies(call_headers);
+
+ // Get cookie from middleware.
+ TestCallHeaders add_call_headers;
+ middleware_->SendingHeaders(&add_call_headers);
+ const std::string actual_cookies = add_call_headers.GetCookies();
+
+ // Validate cookie
+ const std::string expected_cookies =
expected_cookie_cache_.GetValidCookiesAsString();
+ const std::vector<std::string> split_expected_cookies =
+ SplitCookies(expected_cookies);
+ const std::vector<std::string> split_actual_cookies =
SplitCookies(actual_cookies);
+ EXPECT_EQ(split_expected_cookies, split_actual_cookies);
+ }
+
+ // Function to take a list of cookies and split them into a vector of
individual
+ // cookies. This is done because the cookie cache is a map so ordering is not
Review comment:
Yes, good call. Will change this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]