diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/http/misc/httpreqdata_ut.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/http/misc/httpreqdata_ut.cpp')
-rw-r--r-- | library/cpp/http/misc/httpreqdata_ut.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/library/cpp/http/misc/httpreqdata_ut.cpp b/library/cpp/http/misc/httpreqdata_ut.cpp index e7f16ef27c..24225e78ac 100644 --- a/library/cpp/http/misc/httpreqdata_ut.cpp +++ b/library/cpp/http/misc/httpreqdata_ut.cpp @@ -4,19 +4,19 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { Y_UNIT_TEST(Headers) { - TServerRequestData sd; - + TServerRequestData sd; + sd.AddHeader("x-xx", "y-yy"); sd.AddHeader("x-Xx", "y-yy"); - - UNIT_ASSERT_VALUES_EQUAL(sd.HeadersCount(), 1); - + + UNIT_ASSERT_VALUES_EQUAL(sd.HeadersCount(), 1); + sd.AddHeader("x-XxX", "y-yyy"); - UNIT_ASSERT_VALUES_EQUAL(sd.HeadersCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(sd.HeadersCount(), 2); UNIT_ASSERT_VALUES_EQUAL(TStringBuf(sd.HeaderIn("X-XX")), TStringBuf("y-yy")); UNIT_ASSERT_VALUES_EQUAL(TStringBuf(sd.HeaderIn("X-XXX")), TStringBuf("y-yyy")); - } - + } + Y_UNIT_TEST(ComplexHeaders) { TServerRequestData sd; sd.SetHost("zzz", 1); @@ -43,24 +43,24 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { } Y_UNIT_TEST(ParseScan) { - TServerRequestData rd; + TServerRequestData rd; - // Parse parses url without host - UNIT_ASSERT(!rd.Parse(" http://yandex.ru/yandsearch?>a=fake&haha=da HTTP 1.1 OK")); + // Parse parses url without host + UNIT_ASSERT(!rd.Parse(" http://yandex.ru/yandsearch?>a=fake&haha=da HTTP 1.1 OK")); - // This should work - UNIT_ASSERT(rd.Parse(" /yandsearch?>a=fake&haha=da HTTP 1.1 OK")); + // This should work + UNIT_ASSERT(rd.Parse(" /yandsearch?>a=fake&haha=da HTTP 1.1 OK")); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), ">a=fake&haha=da"); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf()); - rd.Scan(); - UNIT_ASSERT(rd.CgiParam.Has("gta", "fake")); - UNIT_ASSERT(rd.CgiParam.Has("haha", "da")); - UNIT_ASSERT(!rd.CgiParam.Has("no-param")); + rd.Scan(); + UNIT_ASSERT(rd.CgiParam.Has("gta", "fake")); + UNIT_ASSERT(rd.CgiParam.Has("haha", "da")); + UNIT_ASSERT(!rd.CgiParam.Has("no-param")); - rd.Clear(); - } + rd.Clear(); + } Y_UNIT_TEST(Ctor) { const TString qs("gta=fake&haha=da"); @@ -69,55 +69,55 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs); UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs); - UNIT_ASSERT(rd.CgiParam.Has("gta")); - UNIT_ASSERT(rd.CgiParam.Has("haha")); - UNIT_ASSERT(!rd.CgiParam.Has("no-param")); - } + UNIT_ASSERT(rd.CgiParam.Has("gta")); + UNIT_ASSERT(rd.CgiParam.Has("haha")); + UNIT_ASSERT(!rd.CgiParam.Has("no-param")); + } Y_UNIT_TEST(HashCut) { const TString qs(">a=fake&haha=da"); const TString header = " /yandsearch?" + qs + "#&uberParam=yes&q=? HTTP 1.1 OK"; - TServerRequestData rd; + TServerRequestData rd; rd.Parse(header.c_str()); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs); UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs); - rd.Scan(); - UNIT_ASSERT(rd.CgiParam.Has("gta")); - UNIT_ASSERT(rd.CgiParam.Has("haha")); - UNIT_ASSERT(!rd.CgiParam.Has("uberParam")); - } + rd.Scan(); + UNIT_ASSERT(rd.CgiParam.Has("gta")); + UNIT_ASSERT(rd.CgiParam.Has("haha")); + UNIT_ASSERT(!rd.CgiParam.Has("uberParam")); + } Y_UNIT_TEST(MisplacedHashCut) { - TServerRequestData rd; - rd.Parse(" /y#ndsearch?>a=fake&haha=da&uberParam=yes&q=? HTTP 1.1 OK"); + TServerRequestData rd; + rd.Parse(" /y#ndsearch?>a=fake&haha=da&uberParam=yes&q=? HTTP 1.1 OK"); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), ""); UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), ""); - rd.Scan(); - UNIT_ASSERT(rd.CgiParam.empty()); - } + rd.Scan(); + UNIT_ASSERT(rd.CgiParam.empty()); + } Y_UNIT_TEST(CornerCase) { - TServerRequestData rd; - rd.Parse(" /yandsearch?#"); + TServerRequestData rd; + rd.Parse(" /yandsearch?#"); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), ""); UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), ""); - rd.Scan(); - UNIT_ASSERT(rd.CgiParam.empty()); - } + rd.Scan(); + UNIT_ASSERT(rd.CgiParam.empty()); + } Y_UNIT_TEST(AppendQueryString) { const TString qs("gta=fake&haha=da"); TServerRequestData rd(qs.c_str()); - UNIT_ASSERT(rd.CgiParam.Has("gta", "fake")); - UNIT_ASSERT(rd.CgiParam.Has("haha", "da")); + UNIT_ASSERT(rd.CgiParam.Has("gta", "fake")); + UNIT_ASSERT(rd.CgiParam.Has("haha", "da")); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs); UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), rd.OrigQueryStringBuf()); @@ -128,11 +128,11 @@ Y_UNIT_TEST_SUITE(TRequestServerDataTest) { UNIT_ASSERT_STRINGS_EQUAL(rd.QueryStringBuf(), qs + '&' + appendix); UNIT_ASSERT_STRINGS_EQUAL(rd.OrigQueryStringBuf(), qs); - rd.Scan(); + rd.Scan(); - UNIT_ASSERT(rd.CgiParam.Has("gta", "true")); - UNIT_ASSERT(rd.CgiParam.Has("gta", "new")); - } + UNIT_ASSERT(rd.CgiParam.Has("gta", "true")); + UNIT_ASSERT(rd.CgiParam.Has("gta", "new")); + } Y_UNIT_TEST(SetRemoteAddrSimple) { static const TString TEST = "abacaba.search.yandex.net"; |