get_tests.cpp
Go to the documentation of this file.
00001 #include <gtest/gtest.h>
00002 
00003 #include <string>
00004 
00005 #include <cpr/cpr.h>
00006 
00007 #include "server.h"
00008 
00009 using namespace cpr;
00010 
00011 static Server* server = new Server();
00012 auto base = server->GetBaseUrl();
00013 
00014 TEST(BasicTests, HelloWorldTest) {
00015     auto url = Url{base + "/hello.html"};
00016     auto response = cpr::Get(url);
00017     auto expected_text = std::string{"Hello world!"};
00018     EXPECT_EQ(expected_text, response.text);
00019     EXPECT_EQ(url, response.url);
00020     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00021     EXPECT_EQ(200, response.status_code);
00022     EXPECT_EQ(ErrorCode::OK, response.error.code);
00023 }
00024 
00025 TEST(BasicTests, TimeoutTest) {
00026     auto url = Url{base + "/hello.html"};
00027     auto response = cpr::Get(url, Timeout{0L});
00028     auto expected_text = std::string{"Hello world!"};
00029     EXPECT_EQ(expected_text, response.text);
00030     EXPECT_EQ(url, response.url);
00031     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00032     EXPECT_EQ(200, response.status_code);
00033     EXPECT_EQ(ErrorCode::OK, response.error.code);
00034 }
00035 
00036 TEST(BasicTests, BasicJsonTest) {
00037     auto url = Url{base + "/basic.json"};
00038     auto response = cpr::Get(url);
00039     auto expected_text = std::string{"[\n"
00040                                      "  {\n"
00041                                      "    \"first_key\": \"first_value\",\n"
00042                                      "    \"second_key\": \"second_value\"\n"
00043                                      "  }\n"
00044                                      "]"};
00045     EXPECT_EQ(expected_text, response.text);
00046     EXPECT_EQ(url, response.url);
00047     EXPECT_EQ(std::string{"application/octet-stream"}, response.header["content-type"]);
00048     EXPECT_EQ(200, response.status_code);
00049     EXPECT_EQ(ErrorCode::OK, response.error.code);
00050 }
00051 
00052 TEST(BasicTests, ResourceNotFoundTest) {
00053     auto url = Url{base + "/error.html"};
00054     auto response = cpr::Get(url);
00055     auto expected_text = std::string{"404 Not Found\n"};
00056     EXPECT_EQ(expected_text, response.text);
00057     EXPECT_EQ(url, response.url);
00058     EXPECT_EQ(std::string{"text/plain"}, response.header["content-type"]);
00059     EXPECT_EQ(404, response.status_code);
00060     EXPECT_EQ(ErrorCode::OK, response.error.code);
00061 }
00062 
00063 TEST(BasicTests, BadHostTest) {
00064     auto url = Url{"http://bad_host/"};
00065     auto response = cpr::Get(url);
00066     EXPECT_EQ(std::string{}, response.text);
00067     EXPECT_EQ(url, response.url);
00068     EXPECT_EQ(0, response.status_code);
00069     EXPECT_EQ(ErrorCode::HOST_RESOLUTION_FAILURE, response.error.code);
00070 }
00071 
00072 TEST(CookiesTests, SingleCookieTest) {
00073     auto url = Url{base + "/basic_cookies.html"};
00074     auto cookies = Cookies{{"hello", "world"}, {"my", "another; fake=cookie;"}};
00075     auto response = cpr::Get(url, cookies);
00076     auto expected_text = std::string{"Hello world!"};
00077     EXPECT_EQ(expected_text, response.text);
00078     EXPECT_EQ(url, response.url);
00079     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00080     EXPECT_EQ(200, response.status_code);
00081     EXPECT_EQ(ErrorCode::OK, response.error.code);
00082     cookies = response.cookies;
00083     EXPECT_EQ(cookies["cookie"], response.cookies["cookie"]);
00084     EXPECT_EQ(cookies["icecream"], response.cookies["icecream"]);
00085     EXPECT_EQ(cookies["expires"], response.cookies["expires"]);
00086 }
00087 
00088 TEST(CookiesTests, CheckBasicCookieTest) {
00089     // server validates whether the cookies are indeed present
00090     auto url = Url{base + "/check_cookies.html"};
00091     auto cookies = Cookies{{"cookie", "chocolate"}, {"icecream", "vanilla"}};
00092     auto response = cpr::Get(url, cookies);
00093     auto expected_text = std::string{"Hello world!"};
00094     EXPECT_EQ(expected_text, response.text);
00095     EXPECT_EQ(url, response.url);
00096     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00097     EXPECT_EQ(200, response.status_code);
00098     EXPECT_EQ(ErrorCode::OK, response.error.code);
00099 }
00100 
00101 TEST(CookiesTests, V1CookieTest) {
00102     auto url = Url{base + "/v1_cookies.html"};
00103     auto response = cpr::Get(url);
00104     auto expected_text = std::string{"Hello world!"};
00105     EXPECT_EQ(expected_text, response.text);
00106     EXPECT_EQ(url, response.url);
00107     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00108     EXPECT_EQ(200, response.status_code);
00109     EXPECT_EQ(ErrorCode::OK, response.error.code);
00110     auto cookies = response.cookies;
00111     EXPECT_EQ("\"value with spaces (v1 cookie)\"", cookies["cookie"]);
00112 }
00113 
00114 TEST(CookiesTests, CheckV1CookieTest) {
00115     // server validates whether the cookie is indeed present
00116     auto url = Url{base + "/check_v1_cookies.html"};
00117     auto cookies = Cookies{{"cookie", "\"value with spaces (v1 cookie)\""}};
00118     auto response = cpr::Get(url, cookies);
00119     auto expected_text = std::string{"Hello world!"};
00120     EXPECT_EQ(expected_text, response.text);
00121     EXPECT_EQ(url, response.url);
00122     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00123     EXPECT_EQ(200, response.status_code);
00124     EXPECT_EQ(ErrorCode::OK, response.error.code);
00125 }
00126 
00127 TEST(ParameterTests, SingleParameterTest) {
00128     auto url = Url{base + "/hello.html"};
00129     auto parameters = Parameters{{"key", "value"}};
00130     auto response = cpr::Get(url, parameters);
00131     auto expected_text = std::string{"Hello world!"};
00132     EXPECT_EQ(expected_text, response.text);
00133     EXPECT_EQ(Url{url + "?key=value"}, response.url);
00134     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00135     EXPECT_EQ(200, response.status_code);
00136     EXPECT_EQ(ErrorCode::OK, response.error.code);
00137 }
00138 
00139 TEST(ParameterTests, SingleParameterOnlyKeyTest) {
00140     auto url = Url{base + "/hello.html"};
00141     auto parameters = Parameters{{"key", ""}};
00142     auto response = cpr::Get(url, parameters);
00143     auto expected_text = std::string{"Hello world!"};
00144     EXPECT_EQ(expected_text, response.text);
00145     EXPECT_EQ(Url{url + "?key"}, response.url);
00146     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00147     EXPECT_EQ(200, response.status_code);
00148 }
00149 
00150 TEST(ParameterTests, MultipleParametersTest) {
00151     auto url = Url{base + "/hello.html"};
00152     auto response = cpr::Get(url, Parameters{{"key", "value"},
00153                                              {"hello", "world"},
00154                                              {"test", "case"}});
00155     auto expected_text = std::string{"Hello world!"};
00156     EXPECT_EQ(expected_text, response.text);
00157     EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url);
00158     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00159     EXPECT_EQ(200, response.status_code);
00160     EXPECT_EQ(ErrorCode::OK, response.error.code);
00161 }
00162 
00163 TEST(ParameterTests, MultipleDynamicParametersTest) {
00164     auto url = Url{base + "/hello.html"};
00165     auto parameters = Parameters{{"key", "value"}};
00166     parameters.AddParameter({"hello", "world"});
00167     parameters.AddParameter({"test", "case"});
00168     auto response = cpr::Get(url, parameters);
00169     auto expected_text = std::string{"Hello world!"};
00170     EXPECT_EQ(expected_text, response.text);
00171     EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url);
00172     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00173     EXPECT_EQ(200, response.status_code);
00174     EXPECT_EQ(ErrorCode::OK, response.error.code);
00175 }
00176 
00177 TEST(BasicAuthenticationTests, BasicAuthenticationSuccessTest) {
00178     auto url = Url{base + "/basic_auth.html"};
00179     auto response = cpr::Get(url, Authentication{"user", "password"});
00180     auto expected_text = std::string{"Header reflect GET"};
00181     EXPECT_EQ(expected_text, response.text);
00182     EXPECT_EQ(url, response.url);
00183     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00184     EXPECT_EQ(200, response.status_code);
00185     EXPECT_EQ(ErrorCode::OK, response.error.code);
00186 }
00187 
00188 TEST(BasicAuthenticationTests, BasicDigestSuccessTest) {
00189     auto url = Url{base + "/digest_auth.html"};
00190     auto response = cpr::Get(url, Digest{"user", "password"});
00191     auto expected_text = std::string{"Header reflect GET"};
00192     EXPECT_EQ(expected_text, response.text);
00193     EXPECT_EQ(url, response.url);
00194     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00195     EXPECT_EQ(200, response.status_code);
00196     EXPECT_EQ(ErrorCode::OK, response.error.code);
00197 }
00198 
00199 TEST(BasicAthenticationParameterTests, BasicAuthenticationSuccessSingleParameterTest) {
00200     auto url = Url{base + "/basic_auth.html"};
00201     auto response = cpr::Get(url, Authentication{"user", "password"},
00202                              Parameters{{"hello", "world"}});
00203     auto expected_text = std::string{"Header reflect GET"};
00204     EXPECT_EQ(expected_text, response.text);
00205     EXPECT_EQ(Url{url + "?hello=world"}, response.url);
00206     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00207     EXPECT_EQ(200, response.status_code);
00208     EXPECT_EQ(ErrorCode::OK, response.error.code);
00209 }
00210 
00211 TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessMultipleParametersTest) {
00212     auto url = Url{base + "/basic_auth.html"};
00213     auto response = cpr::Get(url, Authentication{"user", "password"},
00214                              Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}});
00215     auto expected_text = std::string{"Header reflect GET"};
00216     EXPECT_EQ(expected_text, response.text);
00217     EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url);
00218     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00219     EXPECT_EQ(200, response.status_code);
00220     EXPECT_EQ(ErrorCode::OK, response.error.code);
00221 }
00222 
00223 TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessSingleParameterReverseTest) {
00224     auto url = Url{base + "/basic_auth.html"};
00225     auto response = cpr::Get(url, Parameters{{"hello", "world"}},
00226                              Authentication{"user", "password"});
00227     auto expected_text = std::string{"Header reflect GET"};
00228     EXPECT_EQ(expected_text, response.text);
00229     EXPECT_EQ(Url{url + "?hello=world"}, response.url);
00230     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00231     EXPECT_EQ(200, response.status_code);
00232     EXPECT_EQ(ErrorCode::OK, response.error.code);
00233 }
00234 
00235 TEST(BasicAuthenticationParameterTests, BasicAuthenticationSuccessMultipleParametersReverseTest) {
00236     auto url = Url{base + "/basic_auth.html"};
00237     auto response = cpr::Get(url, Parameters{{"key", "value"},
00238                                              {"hello", "world"},
00239                                              {"test", "case"}},
00240                              Authentication{"user", "password"});
00241 
00242     auto expected_text = std::string{"Header reflect GET"};
00243     EXPECT_EQ(expected_text, response.text);
00244     EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url);
00245     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00246     EXPECT_EQ(200, response.status_code);
00247     EXPECT_EQ(ErrorCode::OK, response.error.code);
00248 }
00249 
00250 TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessSingleHeaderTest) {
00251     auto url = Url{base + "/basic_auth.html"};
00252     auto response = cpr::Get(url, Authentication{"user", "password"},
00253                              Header{{"hello", "world"}});
00254     auto expected_text = std::string{"Header reflect GET"};
00255     EXPECT_EQ(expected_text, response.text);
00256     EXPECT_EQ(url, response.url);
00257     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00258     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00259     EXPECT_EQ(200, response.status_code);
00260     EXPECT_EQ(ErrorCode::OK, response.error.code);
00261 }
00262 
00263 TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessMultipleHeadersTest) {
00264     auto url = Url{base + "/basic_auth.html"};
00265     auto response = cpr::Get(url, Authentication{"user", "password"},
00266                              Header{{"key", "value"}, {"hello", "world"}, {"test", "case"}});
00267     auto expected_text = std::string{"Header reflect GET"};
00268     EXPECT_EQ(expected_text, response.text);
00269     EXPECT_EQ(url, response.url);
00270     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00271     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00272     EXPECT_EQ(std::string{"value"}, response.header["key"]);
00273     EXPECT_EQ(std::string{"case"}, response.header["test"]);
00274     EXPECT_EQ(200, response.status_code);
00275     EXPECT_EQ(ErrorCode::OK, response.error.code);
00276 }
00277 
00278 TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessSingleHeaderReverseTest) {
00279     auto url = Url{base + "/basic_auth.html"};
00280     auto response = cpr::Get(url, Header{{"hello", "world"}},
00281                              Authentication{"user", "password"});
00282     auto expected_text = std::string{"Header reflect GET"};
00283     EXPECT_EQ(expected_text, response.text);
00284     EXPECT_EQ(url, response.url);
00285     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00286     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00287     EXPECT_EQ(200, response.status_code);
00288     EXPECT_EQ(ErrorCode::OK, response.error.code);
00289 }
00290 
00291 TEST(BasicAuthenticationHeaderTests, BasicAuthenticationSuccessMultipleHeadersReverseTest) {
00292     auto url = Url{base + "/basic_auth.html"};
00293     auto response = cpr::Get(url, Header{{"key", "value"}, {"hello", "world"}, {"test", "case"}},
00294                              Authentication{"user", "password"});
00295     auto expected_text = std::string{"Header reflect GET"};
00296     EXPECT_EQ(expected_text, response.text);
00297     EXPECT_EQ(url, response.url);
00298     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00299     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00300     EXPECT_EQ(std::string{"value"}, response.header["key"]);
00301     EXPECT_EQ(std::string{"case"}, response.header["test"]);
00302     EXPECT_EQ(200, response.status_code);
00303     EXPECT_EQ(ErrorCode::OK, response.error.code);
00304 }
00305 
00306 TEST(BasicAuthenticationTests, BasicAuthenticationNullFailureTest) {
00307     auto url = Url{base + "/basic_auth.html"};
00308     auto response = cpr::Get(url);
00309     EXPECT_EQ(std::string{}, response.text);
00310     EXPECT_EQ(url, response.url);
00311     EXPECT_EQ(std::string{}, response.header["content-type"]);
00312     EXPECT_EQ(401, response.status_code);
00313     EXPECT_EQ(ErrorCode::OK, response.error.code);
00314 }
00315 
00316 TEST(BasicAuthenticationTests, BasicAuthenticationFailureTest) {
00317     auto url = Url{base + "/basic_auth.html"};
00318     auto response = cpr::Get(url, Authentication{"user", "bad_password"});
00319     EXPECT_EQ(std::string{}, response.text);
00320     EXPECT_EQ(url, response.url);
00321     EXPECT_EQ(std::string{}, response.header["content-type"]);
00322     EXPECT_EQ(401, response.status_code);
00323     EXPECT_EQ(ErrorCode::OK, response.error.code);
00324 }
00325 
00326 TEST(BasicAuthenticationParameterTests, BasicAuthenticationFailureSingleParameterTest) {
00327     auto url = Url{base + "/basic_auth.html"};
00328     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00329                              Parameters{{"hello", "world"}});
00330     EXPECT_EQ(std::string{}, response.text);
00331     EXPECT_EQ(Url{url + "?hello=world"}, response.url);
00332     EXPECT_EQ(std::string{}, response.header["content-type"]);
00333     EXPECT_EQ(401, response.status_code);
00334     EXPECT_EQ(ErrorCode::OK, response.error.code);
00335 }
00336 
00337 TEST(BasicAuthenticationParameterTests, BasicAuthenticationFailureMultipleParametersTest) {
00338     auto url = Url{base + "/basic_auth.html"};
00339     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00340                              Parameters{{"key", "value"}, {"hello", "world"}, {"test", "case"}});
00341     EXPECT_EQ(std::string{}, response.text);
00342     EXPECT_EQ(Url{url + "?key=value&hello=world&test=case"}, response.url);
00343     EXPECT_EQ(std::string{}, response.header["content-type"]);
00344     EXPECT_EQ(401, response.status_code);
00345     EXPECT_EQ(ErrorCode::OK, response.error.code);
00346 }
00347 
00348 TEST(HeaderTests, HeaderJsonTest) {
00349     auto url = Url{base + "/basic.json"};
00350     auto response = cpr::Get(url, Header{{"content-type", "application/json"}});
00351     auto expected_text = std::string{"[\n"
00352                                      "  {\n"
00353                                      "    \"first_key\": \"first_value\",\n"
00354                                      "    \"second_key\": \"second_value\"\n"
00355                                      "  }\n"
00356                                      "]"};
00357     EXPECT_EQ(expected_text, response.text);
00358     EXPECT_EQ(url, response.url);
00359     EXPECT_EQ(std::string{"application/json"}, response.header["content-type"]);
00360     EXPECT_EQ(200, response.status_code);
00361     EXPECT_EQ(ErrorCode::OK, response.error.code);
00362 }
00363 
00364 TEST(HeaderTests, HeaderReflectNoneTest) {
00365     auto url = Url{base + "/header_reflect.html"};
00366     auto response = cpr::Get(url);
00367     auto expected_text = std::string{"Header reflect GET"};
00368     EXPECT_EQ(expected_text, response.text);
00369     EXPECT_EQ(url, response.url);
00370     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00371     EXPECT_EQ(std::string{}, response.header["hello"]);
00372     EXPECT_EQ(200, response.status_code);
00373     EXPECT_EQ(ErrorCode::OK, response.error.code);
00374 }
00375 
00376 TEST(HeaderTests, HeaderReflectEmptyTest) {
00377     auto url = Url{base + "/header_reflect.html"};
00378     auto response = cpr::Get(url, Header{});
00379     auto expected_text = std::string{"Header reflect GET"};
00380     EXPECT_EQ(expected_text, response.text);
00381     EXPECT_EQ(url, response.url);
00382     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00383     EXPECT_EQ(std::string{}, response.header["hello"]);
00384     EXPECT_EQ(200, response.status_code);
00385     EXPECT_EQ(ErrorCode::OK, response.error.code);
00386 }
00387 
00388 TEST(HeaderTests, HeaderReflectSingleTest) {
00389     auto url = Url{base + "/header_reflect.html"};
00390     auto response = cpr::Get(url, Header{{"hello", "world"}});
00391     auto expected_text = std::string{"Header reflect GET"};
00392     EXPECT_EQ(expected_text, response.text);
00393     EXPECT_EQ(url, response.url);
00394     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00395     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00396     EXPECT_EQ(200, response.status_code);
00397     EXPECT_EQ(ErrorCode::OK, response.error.code);
00398 }
00399 
00400 TEST(HeaderTests, HeaderReflectMultipleTest) {
00401     auto url = Url{base + "/header_reflect.html"};
00402     auto response = cpr::Get(url, Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}});
00403     auto expected_text = std::string{"Header reflect GET"};
00404     EXPECT_EQ(expected_text, response.text);
00405     EXPECT_EQ(url, response.url);
00406     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00407     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00408     EXPECT_EQ(std::string{"value"}, response.header["key"]);
00409     EXPECT_EQ(std::string{"case"}, response.header["test"]);
00410     EXPECT_EQ(200, response.status_code);
00411     EXPECT_EQ(ErrorCode::OK, response.error.code);
00412 }
00413 
00414 TEST(HeaderTests, HeaderReflectCaseInsensitiveTest) {
00415     auto url = Url{base + "/header_reflect.html"};
00416     auto response = cpr::Get(url, Header{{"HeLlO", "wOrLd"}});
00417     auto expected_text = std::string{"Header reflect GET"};
00418     EXPECT_EQ(expected_text, response.text);
00419     EXPECT_EQ(url, response.url);
00420     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00421     EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]);
00422     EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]);
00423     EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]);
00424     EXPECT_EQ(200, response.status_code);
00425     EXPECT_EQ(ErrorCode::OK, response.error.code);
00426 }
00427 
00428 TEST(HeaderTests, SetEmptyHeaderTest) {
00429     auto url = Url{base + "/header_reflect.html"};
00430     auto response = cpr::Get(url, Header{{"hello", ""}});
00431     auto expected_text = std::string{"Header reflect GET"};
00432     EXPECT_EQ(expected_text, response.text);
00433     EXPECT_EQ(url, response.url);
00434     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00435     EXPECT_EQ(std::string{}, response.header["hello"]);
00436     EXPECT_EQ(200, response.status_code);
00437     EXPECT_EQ(ErrorCode::OK, response.error.code);
00438 }
00439 
00440 TEST(ParameterHeaderTests, HeaderReflectNoneParametersTest) {
00441     auto url = Url{base + "/header_reflect.html"};
00442     auto response = cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}});
00443     auto expected_text = std::string{"Header reflect GET"};
00444     EXPECT_EQ(expected_text, response.text);
00445     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00446     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00447     EXPECT_EQ(std::string{}, response.header["hello"]);
00448     EXPECT_EQ(200, response.status_code);
00449     EXPECT_EQ(ErrorCode::OK, response.error.code);
00450 }
00451 
00452 TEST(ParameterHeaderTests, HeaderReflectEmptyParametersTest) {
00453     auto url = Url{base + "/header_reflect.html"};
00454     auto response = cpr::Get(url, Header{},
00455                              Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}});
00456     auto expected_text = std::string{"Header reflect GET"};
00457     EXPECT_EQ(expected_text, response.text);
00458     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00459     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00460     EXPECT_EQ(std::string{}, response.header["hello"]);
00461     EXPECT_EQ(200, response.status_code);
00462     EXPECT_EQ(ErrorCode::OK, response.error.code);
00463 }
00464 
00465 TEST(ParameterHeaderTests, HeaderReflectSingleParametersTest) {
00466     auto url = Url{base + "/header_reflect.html"};
00467     auto response = cpr::Get(url, Header{{"hello", "world"}},
00468                              Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}});
00469     auto expected_text = std::string{"Header reflect GET"};
00470     EXPECT_EQ(expected_text, response.text);
00471     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00472     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00473     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00474     EXPECT_EQ(200, response.status_code);
00475     EXPECT_EQ(ErrorCode::OK, response.error.code);
00476 }
00477 
00478 TEST(ParameterHeaderTests, HeaderReflectMultipleParametersTest) {
00479     auto url = Url{base + "/header_reflect.html"};
00480     auto response = cpr::Get(url, Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}},
00481                              Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}});
00482     auto expected_text = std::string{"Header reflect GET"};
00483     EXPECT_EQ(expected_text, response.text);
00484     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00485     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00486     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00487     EXPECT_EQ(std::string{"value"}, response.header["key"]);
00488     EXPECT_EQ(std::string{"case"}, response.header["test"]);
00489     EXPECT_EQ(200, response.status_code);
00490     EXPECT_EQ(ErrorCode::OK, response.error.code);
00491 }
00492 
00493 TEST(ParameterHeaderTests, HeaderReflectCaseInsensitiveParametersTest) {
00494     auto url = Url{base + "/header_reflect.html"};
00495     auto response = cpr::Get(url, Header{{"HeLlO", "wOrLd"}},
00496                              Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}});
00497     auto expected_text = std::string{"Header reflect GET"};
00498     EXPECT_EQ(expected_text, response.text);
00499     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00500     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00501     EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]);
00502     EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]);
00503     EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]);
00504     EXPECT_EQ(200, response.status_code);
00505     EXPECT_EQ(ErrorCode::OK, response.error.code);
00506 }
00507 
00508 TEST(ParameterHeaderTests, HeaderReflectEmptyParametersReverseTest) {
00509     auto url = Url{base + "/header_reflect.html"};
00510     auto response = cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}},
00511                              Header{});
00512     auto expected_text = std::string{"Header reflect GET"};
00513     EXPECT_EQ(expected_text, response.text);
00514     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00515     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00516     EXPECT_EQ(std::string{}, response.header["hello"]);
00517     EXPECT_EQ(200, response.status_code);
00518     EXPECT_EQ(ErrorCode::OK, response.error.code);
00519 }
00520 
00521 TEST(ParameterHeaderTests, HeaderReflectSingleParametersReverseTest) {
00522     auto url = Url{base + "/header_reflect.html"};
00523     auto response = cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}},
00524                              Header{{"hello", "world"}});
00525     auto expected_text = std::string{"Header reflect GET"};
00526     EXPECT_EQ(expected_text, response.text);
00527     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00528     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00529     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00530     EXPECT_EQ(200, response.status_code);
00531     EXPECT_EQ(ErrorCode::OK, response.error.code);
00532 }
00533 
00534 TEST(ParameterHeaderTests, HeaderReflectMultipleParametersReverseTest) {
00535     auto url = Url{base + "/header_reflect.html"};
00536     auto response = cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}},
00537                              Header{{"hello", "world"}, {"key", "value"}, {"test", "case"}});
00538     auto expected_text = std::string{"Header reflect GET"};
00539     EXPECT_EQ(expected_text, response.text);
00540     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00541     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00542     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00543     EXPECT_EQ(std::string{"value"}, response.header["key"]);
00544     EXPECT_EQ(std::string{"case"}, response.header["test"]);
00545     EXPECT_EQ(200, response.status_code);
00546     EXPECT_EQ(ErrorCode::OK, response.error.code);
00547 }
00548 
00549 TEST(ParameterHeaderTests, HeaderReflectCaseInsensitiveParametersReverseTest) {
00550     auto url = Url{base + "/header_reflect.html"};
00551     auto response = cpr::Get(url, Parameters{{"one", "two"}, {"three", "four"}, {"five", "six"}},
00552                              Header{{"HeLlO", "wOrLd"}});
00553     auto expected_text = std::string{"Header reflect GET"};
00554     EXPECT_EQ(expected_text, response.text);
00555     EXPECT_EQ(Url{url + "?one=two&three=four&five=six"}, response.url);
00556     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00557     EXPECT_EQ(std::string{"wOrLd"}, response.header["hello"]);
00558     EXPECT_EQ(std::string{"wOrLd"}, response.header["HELLO"]);
00559     EXPECT_EQ(std::string{"wOrLd"}, response.header["hElLo"]);
00560     EXPECT_EQ(200, response.status_code);
00561     EXPECT_EQ(ErrorCode::OK, response.error.code);
00562 }
00563 
00564 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAATest) {
00565     auto url = Url{base + "/basic_auth.html"};
00566     auto response = cpr::Get(url, Authentication{"user", "password"}, Parameters{}, Header{});
00567     auto expected_text = std::string{"Header reflect GET"};
00568     EXPECT_EQ(expected_text, response.text);
00569     EXPECT_EQ(url, response.url);
00570     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00571     EXPECT_EQ(std::string{}, response.header["hello"]);
00572     EXPECT_EQ(200, response.status_code);
00573     EXPECT_EQ(ErrorCode::OK, response.error.code);
00574 }
00575 
00576 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderABTest) {
00577     auto url = Url{base + "/basic_auth.html"};
00578     auto response = cpr::Get(url, Authentication{"user", "bad_password"}, Parameters{}, Header{});
00579     EXPECT_EQ(std::string{}, response.text);
00580     EXPECT_EQ(url, response.url);
00581     EXPECT_EQ(std::string{}, response.header["content-type"]);
00582     EXPECT_EQ(std::string{}, response.header["hello"]);
00583     EXPECT_EQ(401, response.status_code);
00584     EXPECT_EQ(ErrorCode::OK, response.error.code);
00585 }
00586 
00587 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderACTest) {
00588     auto url = Url{base + "/basic_auth.html"};
00589     auto response = cpr::Get(url, Authentication{"user", "password"}, Parameters{{"one", "two"}},
00590                              Header{});
00591     auto expected_text = std::string{"Header reflect GET"};
00592     EXPECT_EQ(expected_text, response.text);
00593     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00594     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00595     EXPECT_EQ(std::string{}, response.header["hello"]);
00596     EXPECT_EQ(200, response.status_code);
00597     EXPECT_EQ(ErrorCode::OK, response.error.code);
00598 }
00599 
00600 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderADTest) {
00601     auto url = Url{base + "/basic_auth.html"};
00602     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00603                              Parameters{{"one", "two"}}, Header{});
00604     EXPECT_EQ(std::string{}, response.text);
00605     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00606     EXPECT_EQ(std::string{}, response.header["content-type"]);
00607     EXPECT_EQ(std::string{}, response.header["hello"]);
00608     EXPECT_EQ(401, response.status_code);
00609     EXPECT_EQ(ErrorCode::OK, response.error.code);
00610 }
00611 
00612 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAETest) {
00613     auto url = Url{base + "/basic_auth.html"};
00614     auto response = cpr::Get(url, Authentication{"user", "password"}, Parameters{},
00615                              Header{{"hello", "world"}});
00616     auto expected_text = std::string{"Header reflect GET"};
00617     EXPECT_EQ(expected_text, response.text);
00618     EXPECT_EQ(url, response.url);
00619     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00620     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00621     EXPECT_EQ(200, response.status_code);
00622     EXPECT_EQ(ErrorCode::OK, response.error.code);
00623 }
00624 
00625 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAFTest) {
00626     auto url = Url{base + "/basic_auth.html"};
00627     auto response = cpr::Get(url, Authentication{"user", "bad_password"}, Parameters{},
00628                              Header{{"hello", "world"}});
00629     EXPECT_EQ(std::string{}, response.text);
00630     EXPECT_EQ(url, response.url);
00631     EXPECT_EQ(std::string{}, response.header["content-type"]);
00632     EXPECT_EQ(std::string{}, response.header["hello"]);
00633     EXPECT_EQ(401, response.status_code);
00634     EXPECT_EQ(ErrorCode::OK, response.error.code);
00635 }
00636 
00637 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAGTest) {
00638     auto url = Url{base + "/basic_auth.html"};
00639     auto response = cpr::Get(url, Authentication{"user", "password"}, Parameters{{"one", "two"}},
00640                              Header{{"hello", "world"}});
00641     auto expected_text = std::string{"Header reflect GET"};
00642     EXPECT_EQ(expected_text, response.text);
00643     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00644     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00645     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00646     EXPECT_EQ(200, response.status_code);
00647     EXPECT_EQ(ErrorCode::OK, response.error.code);
00648 }
00649 
00650 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderAHTest) {
00651     auto url = Url{base + "/basic_auth.html"};
00652     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00653                              Parameters{{"one", "two"}}, Header{{"hello", "world"}});
00654     EXPECT_EQ(std::string{}, response.text);
00655     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00656     EXPECT_EQ(std::string{}, response.header["content-type"]);
00657     EXPECT_EQ(std::string{}, response.header["hello"]);
00658     EXPECT_EQ(401, response.status_code);
00659     EXPECT_EQ(ErrorCode::OK, response.error.code);
00660 }
00661 
00662 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBATest) {
00663     auto url = Url{base + "/basic_auth.html"};
00664     auto response = cpr::Get(url, Parameters{}, Header{}, Authentication{"user", "password"});
00665     auto expected_text = std::string{"Header reflect GET"};
00666     EXPECT_EQ(expected_text, response.text);
00667     EXPECT_EQ(url, response.url);
00668     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00669     EXPECT_EQ(std::string{}, response.header["hello"]);
00670     EXPECT_EQ(200, response.status_code);
00671     EXPECT_EQ(ErrorCode::OK, response.error.code);
00672 }
00673 
00674 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBBTest) {
00675     auto url = Url{base + "/basic_auth.html"};
00676     auto response = cpr::Get(url, Parameters{}, Header{}, Authentication{"user", "bad_password"});
00677     EXPECT_EQ(std::string{}, response.text);
00678     EXPECT_EQ(url, response.url);
00679     EXPECT_EQ(std::string{}, response.header["content-type"]);
00680     EXPECT_EQ(std::string{}, response.header["hello"]);
00681     EXPECT_EQ(401, response.status_code);
00682     EXPECT_EQ(ErrorCode::OK, response.error.code);
00683 }
00684 
00685 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBCTest) {
00686     auto url = Url{base + "/basic_auth.html"};
00687     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Header{},
00688                              Authentication{"user", "password"});
00689     auto expected_text = std::string{"Header reflect GET"};
00690     EXPECT_EQ(expected_text, response.text);
00691     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00692     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00693     EXPECT_EQ(std::string{}, response.header["hello"]);
00694     EXPECT_EQ(200, response.status_code);
00695     EXPECT_EQ(ErrorCode::OK, response.error.code);
00696 }
00697 
00698 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBDTest) {
00699     auto url = Url{base + "/basic_auth.html"};
00700     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Header{},
00701                              Authentication{"user", "bad_password"});
00702     EXPECT_EQ(std::string{}, response.text);
00703     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00704     EXPECT_EQ(std::string{}, response.header["content-type"]);
00705     EXPECT_EQ(std::string{}, response.header["hello"]);
00706     EXPECT_EQ(401, response.status_code);
00707     EXPECT_EQ(ErrorCode::OK, response.error.code);
00708 }
00709 
00710 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBETest) {
00711     auto url = Url{base + "/basic_auth.html"};
00712     auto response = cpr::Get(url, Parameters{}, Header{{"hello", "world"}},
00713                              Authentication{"user", "password"});
00714     auto expected_text = std::string{"Header reflect GET"};
00715     EXPECT_EQ(expected_text, response.text);
00716     EXPECT_EQ(url, response.url);
00717     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00718     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00719     EXPECT_EQ(200, response.status_code);
00720     EXPECT_EQ(ErrorCode::OK, response.error.code);
00721 }
00722 
00723 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBFTest) {
00724     auto url = Url{base + "/basic_auth.html"};
00725     auto response = cpr::Get(url, Parameters{}, Header{{"hello", "world"}},
00726                              Authentication{"user", "bad_password"});
00727     EXPECT_EQ(std::string{}, response.text);
00728     EXPECT_EQ(url, response.url);
00729     EXPECT_EQ(std::string{}, response.header["content-type"]);
00730     EXPECT_EQ(std::string{}, response.header["hello"]);
00731     EXPECT_EQ(401, response.status_code);
00732     EXPECT_EQ(ErrorCode::OK, response.error.code);
00733 }
00734 
00735 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBGTest) {
00736     auto url = Url{base + "/basic_auth.html"};
00737     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Header{{"hello", "world"}},
00738                              Authentication{"user", "password"});
00739     auto expected_text = std::string{"Header reflect GET"};
00740     EXPECT_EQ(expected_text, response.text);
00741     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00742     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00743     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00744     EXPECT_EQ(200, response.status_code);
00745     EXPECT_EQ(ErrorCode::OK, response.error.code);
00746 }
00747 
00748 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderBHTest) {
00749     auto url = Url{base + "/basic_auth.html"};
00750     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Header{{"hello", "world"}},
00751                              Authentication{"user", "bad_password"});
00752     EXPECT_EQ(std::string{}, response.text);
00753     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00754     EXPECT_EQ(std::string{}, response.header["content-type"]);
00755     EXPECT_EQ(std::string{}, response.header["hello"]);
00756     EXPECT_EQ(401, response.status_code);
00757     EXPECT_EQ(ErrorCode::OK, response.error.code);
00758 }
00759 
00760 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCATest) {
00761     auto url = Url{base + "/basic_auth.html"};
00762     auto response = cpr::Get(url, Header{}, Authentication{"user", "password"}, Parameters{});
00763     auto expected_text = std::string{"Header reflect GET"};
00764     EXPECT_EQ(expected_text, response.text);
00765     EXPECT_EQ(url, response.url);
00766     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00767     EXPECT_EQ(std::string{}, response.header["hello"]);
00768     EXPECT_EQ(200, response.status_code);
00769     EXPECT_EQ(ErrorCode::OK, response.error.code);
00770 }
00771 
00772 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCBTest) {
00773     auto url = Url{base + "/basic_auth.html"};
00774     auto response = cpr::Get(url, Header{}, Authentication{"user", "bad_password"}, Parameters{});
00775     EXPECT_EQ(std::string{}, response.text);
00776     EXPECT_EQ(url, response.url);
00777     EXPECT_EQ(std::string{}, response.header["content-type"]);
00778     EXPECT_EQ(std::string{}, response.header["hello"]);
00779     EXPECT_EQ(401, response.status_code);
00780     EXPECT_EQ(ErrorCode::OK, response.error.code);
00781 }
00782 
00783 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCCTest) {
00784     auto url = Url{base + "/basic_auth.html"};
00785     auto response = cpr::Get(url,  Header{}, Authentication{"user", "password"},
00786                              Parameters{{"one", "two"}});
00787     auto expected_text = std::string{"Header reflect GET"};
00788     EXPECT_EQ(expected_text, response.text);
00789     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00790     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00791     EXPECT_EQ(std::string{}, response.header["hello"]);
00792     EXPECT_EQ(200, response.status_code);
00793     EXPECT_EQ(ErrorCode::OK, response.error.code);
00794 }
00795 
00796 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCDTest) {
00797     auto url = Url{base + "/basic_auth.html"};
00798     auto response = cpr::Get(url,  Header{}, Authentication{"user", "bad_password"},
00799                              Parameters{{"one", "two"}});
00800     EXPECT_EQ(std::string{}, response.text);
00801     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00802     EXPECT_EQ(std::string{}, response.header["content-type"]);
00803     EXPECT_EQ(std::string{}, response.header["hello"]);
00804     EXPECT_EQ(401, response.status_code);
00805     EXPECT_EQ(ErrorCode::OK, response.error.code);
00806 }
00807 
00808 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCETest) {
00809     auto url = Url{base + "/basic_auth.html"};
00810     auto response = cpr::Get(url, Header{{"hello", "world"}}, Authentication{"user", "password"},
00811                              Parameters{});
00812     auto expected_text = std::string{"Header reflect GET"};
00813     EXPECT_EQ(expected_text, response.text);
00814     EXPECT_EQ(url, response.url);
00815     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00816     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00817     EXPECT_EQ(200, response.status_code);
00818     EXPECT_EQ(ErrorCode::OK, response.error.code);
00819 }
00820 
00821 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCFTest) {
00822     auto url = Url{base + "/basic_auth.html"};
00823     auto response = cpr::Get(url, Header{{"hello", "world"}},
00824                              Authentication{"user", "bad_password"}, Parameters{});
00825     EXPECT_EQ(std::string{}, response.text);
00826     EXPECT_EQ(url, response.url);
00827     EXPECT_EQ(std::string{}, response.header["content-type"]);
00828     EXPECT_EQ(std::string{}, response.header["hello"]);
00829     EXPECT_EQ(401, response.status_code);
00830     EXPECT_EQ(ErrorCode::OK, response.error.code);
00831 }
00832 
00833 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCGTest) {
00834     auto url = Url{base + "/basic_auth.html"};
00835     auto response = cpr::Get(url,  Header{{"hello", "world"}}, Authentication{"user", "password"},
00836                              Parameters{{"one", "two"}});
00837     auto expected_text = std::string{"Header reflect GET"};
00838     EXPECT_EQ(expected_text, response.text);
00839     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00840     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00841     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00842     EXPECT_EQ(200, response.status_code);
00843     EXPECT_EQ(ErrorCode::OK, response.error.code);
00844 }
00845 
00846 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderCHTest) {
00847     auto url = Url{base + "/basic_auth.html"};
00848     auto response = cpr::Get(url,  Header{{"hello", "world"}},
00849                              Authentication{"user", "bad_password"}, Parameters{{"one", "two"}});
00850     EXPECT_EQ(std::string{}, response.text);
00851     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00852     EXPECT_EQ(std::string{}, response.header["content-type"]);
00853     EXPECT_EQ(std::string{}, response.header["hello"]);
00854     EXPECT_EQ(401, response.status_code);
00855     EXPECT_EQ(ErrorCode::OK, response.error.code);
00856 }
00857 
00858 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDATest) {
00859     auto url = Url{base + "/basic_auth.html"};
00860     auto response = cpr::Get(url, Authentication{"user", "password"}, Header{}, Parameters{});
00861     auto expected_text = std::string{"Header reflect GET"};
00862     EXPECT_EQ(expected_text, response.text);
00863     EXPECT_EQ(url, response.url);
00864     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00865     EXPECT_EQ(std::string{}, response.header["hello"]);
00866     EXPECT_EQ(200, response.status_code);
00867     EXPECT_EQ(ErrorCode::OK, response.error.code);
00868 }
00869 
00870 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDBTest) {
00871     auto url = Url{base + "/basic_auth.html"};
00872     auto response = cpr::Get(url, Authentication{"user", "bad_password"}, Header{}, Parameters{});
00873     EXPECT_EQ(std::string{}, response.text);
00874     EXPECT_EQ(url, response.url);
00875     EXPECT_EQ(std::string{}, response.header["content-type"]);
00876     EXPECT_EQ(std::string{}, response.header["hello"]);
00877     EXPECT_EQ(401, response.status_code);
00878     EXPECT_EQ(ErrorCode::OK, response.error.code);
00879 }
00880 
00881 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDCTest) {
00882     auto url = Url{base + "/basic_auth.html"};
00883     auto response = cpr::Get(url, Authentication{"user", "password"}, Header{},
00884                              Parameters{{"one", "two"}});
00885     auto expected_text = std::string{"Header reflect GET"};
00886     EXPECT_EQ(expected_text, response.text);
00887     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00888     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00889     EXPECT_EQ(std::string{}, response.header["hello"]);
00890     EXPECT_EQ(200, response.status_code);
00891     EXPECT_EQ(ErrorCode::OK, response.error.code);
00892 }
00893 
00894 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDDTest) {
00895     auto url = Url{base + "/basic_auth.html"};
00896     auto response = cpr::Get(url, Authentication{"user", "bad_password"}, Header{},
00897                              Parameters{{"one", "two"}});
00898     EXPECT_EQ(std::string{}, response.text);
00899     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00900     EXPECT_EQ(std::string{}, response.header["content-type"]);
00901     EXPECT_EQ(std::string{}, response.header["hello"]);
00902     EXPECT_EQ(401, response.status_code);
00903     EXPECT_EQ(ErrorCode::OK, response.error.code);
00904 }
00905 
00906 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDETest) {
00907     auto url = Url{base + "/basic_auth.html"};
00908     auto response = cpr::Get(url, Authentication{"user", "password"}, Header{{"hello", "world"}},
00909                              Parameters{});
00910     auto expected_text = std::string{"Header reflect GET"};
00911     EXPECT_EQ(expected_text, response.text);
00912     EXPECT_EQ(url, response.url);
00913     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00914     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00915     EXPECT_EQ(200, response.status_code);
00916     EXPECT_EQ(ErrorCode::OK, response.error.code);
00917 }
00918 
00919 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDFTest) {
00920     auto url = Url{base + "/basic_auth.html"};
00921     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00922                              Header{{"hello", "world"}}, Parameters{});
00923     EXPECT_EQ(std::string{}, response.text);
00924     EXPECT_EQ(url, response.url);
00925     EXPECT_EQ(std::string{}, response.header["content-type"]);
00926     EXPECT_EQ(std::string{}, response.header["hello"]);
00927     EXPECT_EQ(401, response.status_code);
00928     EXPECT_EQ(ErrorCode::OK, response.error.code);
00929 }
00930 
00931 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDGTest) {
00932     auto url = Url{base + "/basic_auth.html"};
00933     auto response = cpr::Get(url, Authentication{"user", "password"}, Header{{"hello", "world"}},
00934                              Parameters{{"one", "two"}});
00935     auto expected_text = std::string{"Header reflect GET"};
00936     EXPECT_EQ(expected_text, response.text);
00937     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00938     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00939     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
00940     EXPECT_EQ(200, response.status_code);
00941     EXPECT_EQ(ErrorCode::OK, response.error.code);
00942 }
00943 
00944 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderDHTest) {
00945     auto url = Url{base + "/basic_auth.html"};
00946     auto response = cpr::Get(url, Authentication{"user", "bad_password"},
00947                              Header{{"hello", "world"}}, Parameters{{"one", "two"}});
00948     EXPECT_EQ(std::string{}, response.text);
00949     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00950     EXPECT_EQ(std::string{}, response.header["content-type"]);
00951     EXPECT_EQ(std::string{}, response.header["hello"]);
00952     EXPECT_EQ(401, response.status_code);
00953     EXPECT_EQ(ErrorCode::OK, response.error.code);
00954 }
00955 
00956 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEATest) {
00957     auto url = Url{base + "/basic_auth.html"};
00958     auto response = cpr::Get(url, Header{}, Parameters{}, Authentication{"user", "password"});
00959     auto expected_text = std::string{"Header reflect GET"};
00960     EXPECT_EQ(expected_text, response.text);
00961     EXPECT_EQ(url, response.url);
00962     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00963     EXPECT_EQ(std::string{}, response.header["hello"]);
00964     EXPECT_EQ(200, response.status_code);
00965     EXPECT_EQ(ErrorCode::OK, response.error.code);
00966 }
00967 
00968 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEBTest) {
00969     auto url = Url{base + "/basic_auth.html"};
00970     auto response = cpr::Get(url, Header{}, Parameters{}, Authentication{"user", "bad_password"});
00971     EXPECT_EQ(std::string{}, response.text);
00972     EXPECT_EQ(url, response.url);
00973     EXPECT_EQ(std::string{}, response.header["content-type"]);
00974     EXPECT_EQ(std::string{}, response.header["hello"]);
00975     EXPECT_EQ(401, response.status_code);
00976     EXPECT_EQ(ErrorCode::OK, response.error.code);
00977 }
00978 
00979 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderECTest) {
00980     auto url = Url{base + "/basic_auth.html"};
00981     auto response = cpr::Get(url, Header{}, Parameters{{"one", "two"}}, Authentication{"user", "password"});
00982     auto expected_text = std::string{"Header reflect GET"};
00983     EXPECT_EQ(expected_text, response.text);
00984     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00985     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
00986     EXPECT_EQ(std::string{}, response.header["hello"]);
00987     EXPECT_EQ(200, response.status_code);
00988     EXPECT_EQ(ErrorCode::OK, response.error.code);
00989 }
00990 
00991 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEDTest) {
00992     auto url = Url{base + "/basic_auth.html"};
00993     auto response = cpr::Get(url, Header{}, Parameters{{"one", "two"}}, Authentication{"user", "bad_password"});
00994     EXPECT_EQ(std::string{}, response.text);
00995     EXPECT_EQ(Url{url + "?one=two"}, response.url);
00996     EXPECT_EQ(std::string{}, response.header["content-type"]);
00997     EXPECT_EQ(std::string{}, response.header["hello"]);
00998     EXPECT_EQ(401, response.status_code);
00999     EXPECT_EQ(ErrorCode::OK, response.error.code);
01000 }
01001 
01002 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEETest) {
01003     auto url = Url{base + "/basic_auth.html"};
01004     auto response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{}, Authentication{"user", "password"});
01005     auto expected_text = std::string{"Header reflect GET"};
01006     EXPECT_EQ(expected_text, response.text);
01007     EXPECT_EQ(url, response.url);
01008     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01009     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
01010     EXPECT_EQ(200, response.status_code);
01011     EXPECT_EQ(ErrorCode::OK, response.error.code);
01012 }
01013 
01014 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEFTest) {
01015     auto url = Url{base + "/basic_auth.html"};
01016     auto response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{}, Authentication{"user", "bad_password"});
01017     EXPECT_EQ(std::string{}, response.text);
01018     EXPECT_EQ(url, response.url);
01019     EXPECT_EQ(std::string{}, response.header["content-type"]);
01020     EXPECT_EQ(std::string{}, response.header["hello"]);
01021     EXPECT_EQ(401, response.status_code);
01022     EXPECT_EQ(ErrorCode::OK, response.error.code);
01023 }
01024 
01025 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEGTest) {
01026     auto url = Url{base + "/basic_auth.html"};
01027     auto response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{{"one", "two"}}, Authentication{"user", "password"});
01028     auto expected_text = std::string{"Header reflect GET"};
01029     EXPECT_EQ(expected_text, response.text);
01030     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01031     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01032     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
01033     EXPECT_EQ(200, response.status_code);
01034     EXPECT_EQ(ErrorCode::OK, response.error.code);
01035 }
01036 
01037 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderEHTest) {
01038     auto url = Url{base + "/basic_auth.html"};
01039     auto response = cpr::Get(url, Header{{"hello", "world"}}, Parameters{{"one", "two"}}, Authentication{"user", "bad_password"});
01040     EXPECT_EQ(std::string{}, response.text);
01041     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01042     EXPECT_EQ(std::string{}, response.header["content-type"]);
01043     EXPECT_EQ(std::string{}, response.header["hello"]);
01044     EXPECT_EQ(401, response.status_code);
01045     EXPECT_EQ(ErrorCode::OK, response.error.code);
01046 }
01047 
01048 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFATest) {
01049     auto url = Url{base + "/basic_auth.html"};
01050     auto response = cpr::Get(url, Parameters{}, Authentication{"user", "password"}, Header{});
01051     auto expected_text = std::string{"Header reflect GET"};
01052     EXPECT_EQ(expected_text, response.text);
01053     EXPECT_EQ(url, response.url);
01054     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01055     EXPECT_EQ(std::string{}, response.header["hello"]);
01056     EXPECT_EQ(200, response.status_code);
01057     EXPECT_EQ(ErrorCode::OK, response.error.code);
01058 }
01059 
01060 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFBTest) {
01061     auto url = Url{base + "/basic_auth.html"};
01062     auto response = cpr::Get(url, Parameters{}, Authentication{"user", "bad_password"}, Header{});
01063     EXPECT_EQ(std::string{}, response.text);
01064     EXPECT_EQ(url, response.url);
01065     EXPECT_EQ(std::string{}, response.header["content-type"]);
01066     EXPECT_EQ(std::string{}, response.header["hello"]);
01067     EXPECT_EQ(401, response.status_code);
01068     EXPECT_EQ(ErrorCode::OK, response.error.code);
01069 }
01070 
01071 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFCTest) {
01072     auto url = Url{base + "/basic_auth.html"};
01073     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "password"}, Header{});
01074     auto expected_text = std::string{"Header reflect GET"};
01075     EXPECT_EQ(expected_text, response.text);
01076     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01077     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01078     EXPECT_EQ(std::string{}, response.header["hello"]);
01079     EXPECT_EQ(200, response.status_code);
01080     EXPECT_EQ(ErrorCode::OK, response.error.code);
01081 }
01082 
01083 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFDTest) {
01084     auto url = Url{base + "/basic_auth.html"};
01085     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "bad_password"}, Header{});
01086     EXPECT_EQ(std::string{}, response.text);
01087     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01088     EXPECT_EQ(std::string{}, response.header["content-type"]);
01089     EXPECT_EQ(std::string{}, response.header["hello"]);
01090     EXPECT_EQ(401, response.status_code);
01091     EXPECT_EQ(ErrorCode::OK, response.error.code);
01092 }
01093 
01094 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFETest) {
01095     auto url = Url{base + "/basic_auth.html"};
01096     auto response = cpr::Get(url, Parameters{}, Authentication{"user", "password"}, Header{{"hello", "world"}});
01097     auto expected_text = std::string{"Header reflect GET"};
01098     EXPECT_EQ(expected_text, response.text);
01099     EXPECT_EQ(url, response.url);
01100     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01101     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
01102     EXPECT_EQ(200, response.status_code);
01103     EXPECT_EQ(ErrorCode::OK, response.error.code);
01104 }
01105 
01106 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFFTest) {
01107     auto url = Url{base + "/basic_auth.html"};
01108     auto response = cpr::Get(url, Parameters{}, Authentication{"user", "bad_password"}, Header{{"hello", "world"}});
01109     EXPECT_EQ(std::string{}, response.text);
01110     EXPECT_EQ(url, response.url);
01111     EXPECT_EQ(std::string{}, response.header["content-type"]);
01112     EXPECT_EQ(std::string{}, response.header["hello"]);
01113     EXPECT_EQ(401, response.status_code);
01114     EXPECT_EQ(ErrorCode::OK, response.error.code);
01115 }
01116 
01117 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFGTest) {
01118     auto url = Url{base + "/basic_auth.html"};
01119     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "password"}, Header{{"hello", "world"}});
01120     auto expected_text = std::string{"Header reflect GET"};
01121     EXPECT_EQ(expected_text, response.text);
01122     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01123     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01124     EXPECT_EQ(std::string{"world"}, response.header["hello"]);
01125     EXPECT_EQ(200, response.status_code);
01126     EXPECT_EQ(ErrorCode::OK, response.error.code);
01127 }
01128 
01129 TEST(BasicAuthenticationParameterHeaderTests, BasicAuthenticationParameterHeaderFHTest) {
01130     auto url = Url{base + "/basic_auth.html"};
01131     auto response = cpr::Get(url, Parameters{{"one", "two"}}, Authentication{"user", "bad_password"}, Header{{"hello", "world"}});
01132     EXPECT_EQ(std::string{}, response.text);
01133     EXPECT_EQ(Url{url + "?one=two"}, response.url);
01134     EXPECT_EQ(std::string{}, response.header["content-type"]);
01135     EXPECT_EQ(std::string{}, response.header["hello"]);
01136     EXPECT_EQ(401, response.status_code);
01137     EXPECT_EQ(ErrorCode::OK, response.error.code);
01138 }
01139 
01140 TEST(GetRedirectTests, RedirectTest) {
01141     auto url = Url{base + "/temporary_redirect.html"};
01142     auto response = cpr::Get(url, false); // This should be turned into an object
01143     auto expected_text = std::string{"Found"};
01144     EXPECT_EQ(expected_text, response.text);
01145     EXPECT_EQ(url, response.url);
01146     EXPECT_EQ(std::string{}, response.header["content-type"]);
01147     EXPECT_EQ(302, response.status_code);
01148     EXPECT_EQ(ErrorCode::OK, response.error.code);
01149 }
01150 
01151 TEST(GetRedirectTests, ZeroMaxRedirectsTest) {
01152     auto url = Url{base + "/hello.html"};
01153     auto response = cpr::Get(url, MaxRedirects(0));
01154     auto expected_text = std::string{"Hello world!"};
01155     EXPECT_EQ(expected_text, response.text);
01156     EXPECT_EQ(url, response.url);
01157     EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]);
01158     EXPECT_EQ(200, response.status_code);
01159     EXPECT_EQ(ErrorCode::OK, response.error.code);
01160 }
01161 
01162 int main(int argc, char** argv) {
01163     ::testing::InitGoogleTest(&argc, argv);
01164     ::testing::AddGlobalTestEnvironment(server);
01165     return RUN_ALL_TESTS();
01166 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02