aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2017-09-18 02:39:46 +0900
committeripknHama <ipknhama@gmail.com>2017-09-18 02:39:46 +0900
commite93ba25f2cd156a6544a3c9894cd667906146874 (patch)
treee3b4910792d079b703d3cf89ddbd7655e11051bf /tests
parent9c26e1ebdea1c43ac1a30a8f2ab83debc923cd56 (diff)
downloadcrow-e93ba25f2cd156a6544a3c9894cd667906146874.tar.gz
crow-e93ba25f2cd156a6544a3c9894cd667906146874.zip
Fix cookie parsing: Cookie doesn't have escaping mechanism.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/unittest.cpp b/tests/unittest.cpp
index a85f7bc..303fa72 100644
--- a/tests/unittest.cpp
+++ b/tests/unittest.cpp
@@ -856,12 +856,16 @@ TEST(middleware_cookieparser)
std::string value1;
std::string value2;
+ std::string value3;
+ std::string value4;
CROW_ROUTE(app, "/")([&](const request& req){
{
auto& ctx = app.get_context<CookieParser>(req);
value1 = ctx.get_cookie("key1");
value2 = ctx.get_cookie("key2");
+ value3 = ctx.get_cookie("key3");
+ value4 = ctx.get_cookie("key4");
}
return "";
@@ -869,7 +873,7 @@ TEST(middleware_cookieparser)
decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
auto _ = async(launch::async, [&]{server.run();});
- std::string sendmsg = "GET /\r\nCookie: key1=value1; key2=\"val\\\"ue2\"\r\n\r\n";
+ std::string sendmsg = "GET /\r\nCookie: key1=value1; key2=\"val=ue2\"; key3=\"val\"ue3\"; key4=\"val\"ue4\"\r\n\r\n";
asio::io_service is;
{
asio::ip::tcp::socket c(is);
@@ -882,7 +886,9 @@ TEST(middleware_cookieparser)
}
{
ASSERT_EQUAL("value1", value1);
- ASSERT_EQUAL("val\"ue2", value2);
+ ASSERT_EQUAL("val=ue2", value2);
+ ASSERT_EQUAL("val\"ue3", value3);
+ ASSERT_EQUAL("val\"ue4", value4);
}
server.stop();
}