diff options
| author | komels <[email protected]> | 2022-04-15 16:53:39 +0300 |
|---|---|---|
| committer | komels <[email protected]> | 2022-04-15 16:53:39 +0300 |
| commit | 703a2fb6e100d202d1c7fcd052d73bd5affef408 (patch) | |
| tree | 22b7320c06bb04d86dbf7b9af9ae44281331cd15 /library/cpp/http/simple/ut/https_ut.cpp | |
| parent | 3375bbfda1e2afb03aa2072bf5f2f2c3a26026e8 (diff) | |
Move 'kikimr/yndx'-depending tests out of ydb/core
ref:0a380e13308d579e0545a76924330d1ca5129c43
Diffstat (limited to 'library/cpp/http/simple/ut/https_ut.cpp')
| -rw-r--r-- | library/cpp/http/simple/ut/https_ut.cpp | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/library/cpp/http/simple/ut/https_ut.cpp b/library/cpp/http/simple/ut/https_ut.cpp deleted file mode 100644 index 3849b9ac9ac..00000000000 --- a/library/cpp/http/simple/ut/https_ut.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include <library/cpp/http/simple/http_client.h> - -#include <library/cpp/http/server/response.h> - -#include <library/cpp/testing/unittest/registar.h> -#include <library/cpp/testing/unittest/tests_data.h> - -#include <util/system/shellcommand.h> - -Y_UNIT_TEST_SUITE(Https) { - using TShellCommandPtr = std::unique_ptr<TShellCommand>; - - static TShellCommandPtr start(ui16 port) { - const TString data = ArcadiaSourceRoot() + "/library/cpp/http/simple/ut/https_server"; - - const TString command = - TStringBuilder() - << BuildRoot() << "/library/cpp/http/simple/ut/https_server/https_server" - << " --port " << port - << " --keyfile " << data << "/http_server.key" - << " --certfile " << data << "/http_server.crt"; - - auto res = std::make_unique<TShellCommand>( - command, - TShellCommandOptions() - .SetAsync(true) - .SetLatency(50) - .SetErrorStream(&Cerr)); - - res->Run(); - - i32 tries = 100000; - while (tries-- > 0) { - try { - TKeepAliveHttpClient client("https://localhost", port); - client.DisableVerificationForHttps(); - client.DoGet("/ping"); - break; - } catch (const std::exception& e) { - Cout << "== failed to connect to new server: " << e.what() << Endl; - Sleep(TDuration::MilliSeconds(1)); - } - } - - return res; - } - - static void get(TKeepAliveHttpClient & client) { - TStringStream out; - ui32 code = 0; - - UNIT_ASSERT_NO_EXCEPTION(code = client.DoGet("/ping", &out)); - UNIT_ASSERT_VALUES_EQUAL_C(code, 200, out.Str()); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), "pong.my"); - } - - Y_UNIT_TEST(keepAlive) { - TPortManager pm; - ui16 port = pm.GetPort(443); - TShellCommandPtr httpsServer = start(port); - - TKeepAliveHttpClient client("https://localhost", - port, - TDuration::Seconds(40), - TDuration::Seconds(40)); - client.DisableVerificationForHttps(); - - get(client); - get(client); - - httpsServer->Terminate().Wait(); - httpsServer = start(port); - - get(client); - } - - static void get(TSimpleHttpClient & client) { - TStringStream out; - - UNIT_ASSERT_NO_EXCEPTION_C(client.DoGet("/ping", &out), out.Str()); - UNIT_ASSERT_VALUES_EQUAL(out.Str(), "pong.my"); - } - - Y_UNIT_TEST(simple) { - TPortManager pm; - ui16 port = pm.GetPort(443); - TShellCommandPtr httpsServer = start(port); - - TSimpleHttpClient client("https://localhost", - port, - TDuration::Seconds(40), - TDuration::Seconds(40)); - - get(client); - get(client); - } -} |
