comparison UnitTests/RestApi.cpp @ 330:78a8eaa5f30b

cookies
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Jan 2013 11:41:13 +0100
parents e5402c368b21
children c51c9ed603e6
comparison
equal deleted inserted replaced
329:f579d50fdf8f 330:78a8eaa5f30b
7 #include "../Core/Uuid.h" 7 #include "../Core/Uuid.h"
8 #include "../Core/OrthancException.h" 8 #include "../Core/OrthancException.h"
9 #include "../Core/Compression/ZlibCompressor.h" 9 #include "../Core/Compression/ZlibCompressor.h"
10 10
11 using namespace Orthanc; 11 using namespace Orthanc;
12
13 TEST(RestApi, ParseCookies)
14 {
15 HttpHandler::Arguments headers;
16 HttpHandler::Arguments cookies;
17
18 headers["cookies"] = "a=b;c=d;;;e=f;;g=h;";
19 HttpHandler::ParseCookies(cookies, headers);
20 ASSERT_EQ(4u, cookies.size());
21 ASSERT_EQ("b", cookies["a"]);
22 ASSERT_EQ("d", cookies["c"]);
23 ASSERT_EQ("f", cookies["e"]);
24 ASSERT_EQ("h", cookies["g"]);
25
26 headers["cookies"] = " name = value ; name2=value2";
27 HttpHandler::ParseCookies(cookies, headers);
28 ASSERT_EQ(2u, cookies.size());
29 ASSERT_EQ("value", cookies["name"]);
30 ASSERT_EQ("value2", cookies["name2"]);
31
32 headers["cookies"] = " ;;; ";
33 HttpHandler::ParseCookies(cookies, headers);
34 ASSERT_EQ(0u, cookies.size());
35
36 headers["cookies"] = " ; n=v ;; ";
37 HttpHandler::ParseCookies(cookies, headers);
38 ASSERT_EQ(1u, cookies.size());
39 ASSERT_EQ("v", cookies["n"]);
40 }
12 41
13 TEST(RestApi, RestApiPath) 42 TEST(RestApi, RestApiPath)
14 { 43 {
15 RestApiPath::Components args; 44 RestApiPath::Components args;
16 UriComponents trail; 45 UriComponents trail;