diff options
author | feldsherov <feldsherov@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:29 +0300 |
commit | 077ab504815199e62ffc54daee873cf1d6b64297 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library | |
parent | e73723ec73b27276cd45b9b46b752138a51d669c (diff) | |
download | ydb-077ab504815199e62ffc54daee873cf1d6b64297.tar.gz |
Restoring authorship annotation for <feldsherov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
19 files changed, 240 insertions, 240 deletions
diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 21b63213b6..6c753f68a9 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -24,7 +24,7 @@ RECURSE( mapped_file/ut mbitmap omni - text_norm + text_norm omni/print_omni omni/usage omni/ut diff --git a/library/cpp/http/io/stream.cpp b/library/cpp/http/io/stream.cpp index 71f4b9f927..6689be684f 100644 --- a/library/cpp/http/io/stream.cpp +++ b/library/cpp/http/io/stream.cpp @@ -436,10 +436,10 @@ TString THttpInput::BestCompressionScheme(TArrayRef<const TStringBuf> codings) c ); } -TString THttpInput::BestCompressionScheme() const { +TString THttpInput::BestCompressionScheme() const { return BestCompressionScheme(TCompressionCodecFactory::Instance().GetBestCodecs()); -} - +} + bool THttpInput::GetContentLength(ui64& value) const noexcept { return Impl_->GetContentLength(value); } diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index deabe5de45..1ea35df675 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -441,52 +441,52 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { UNIT_ASSERT(!result.Contains("content-length")); } - Y_UNIT_TEST(CodecsPriority) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + Y_UNIT_TEST(CodecsPriority) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"br", "gzip"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: br")); - } - - Y_UNIT_TEST(CodecsPriority2) { - TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: br")); + } + + Y_UNIT_TEST(CodecsPriority2) { + TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip, br\r\n\r\n"); TVector<TStringBuf> codecs = {"gzip", "br"}; - - THttpInput i(&request); - TString result; - TStringOutput out(result); - THttpOutput httpOut(&out, &i); - - httpOut.EnableKeepAlive(true); + + THttpInput i(&request); + TString result; + TStringOutput out(result); + THttpOutput httpOut(&out, &i); + + httpOut.EnableKeepAlive(true); httpOut.EnableCompression(codecs); - httpOut << "HTTP/1.1 200 OK\r\n"; - char answer[] = "Mary had a little lamb."; - httpOut << "Content-Length: " << strlen(answer) << "\r\n" - "\r\n"; - httpOut << answer; - httpOut.Finish(); - - Cdbg << result; - result.to_lower(); - UNIT_ASSERT(result.Contains("content-encoding: gzip")); - } - + httpOut << "HTTP/1.1 200 OK\r\n"; + char answer[] = "Mary had a little lamb."; + httpOut << "Content-Length: " << strlen(answer) << "\r\n" + "\r\n"; + httpOut << answer; + httpOut.Finish(); + + Cdbg << result; + result.to_lower(); + UNIT_ASSERT(result.Contains("content-encoding: gzip")); + } + Y_UNIT_TEST(HasTrailers) { TMemoryInput response( "HTTP/1.1 200 OK\r\n" diff --git a/library/cpp/http/server/conn.cpp b/library/cpp/http/server/conn.cpp index eee1e95a5f..38a76c4c30 100644 --- a/library/cpp/http/server/conn.cpp +++ b/library/cpp/http/server/conn.cpp @@ -26,14 +26,14 @@ public: return &HO_; } - inline void Reset() { - if (S_ != INVALID_SOCKET) { - // send RST packet to client - S_.SetLinger(true, 0); - S_.Close(); - } - } - + inline void Reset() { + if (S_ != INVALID_SOCKET) { + // send RST packet to client + S_.SetLinger(true, 0); + S_.Close(); + } + } + private: TSocket S_; TSocketInput SI_; @@ -63,7 +63,7 @@ THttpInput* THttpServerConn::Input() noexcept { THttpOutput* THttpServerConn::Output() noexcept { return Impl_->Output(); } - -void THttpServerConn::Reset() { - return Impl_->Reset(); -} + +void THttpServerConn::Reset() { + return Impl_->Reset(); +} diff --git a/library/cpp/http/server/conn.h b/library/cpp/http/server/conn.h index 181bc3fc5c..3aa5329af4 100644 --- a/library/cpp/http/server/conn.h +++ b/library/cpp/http/server/conn.h @@ -29,8 +29,8 @@ public: return Output()->CanBeKeepAlive(); } - void Reset(); - + void Reset(); + private: class TImpl; THolder<TImpl> Impl_; diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp index 00ca18e1cb..128583bdd7 100644 --- a/library/cpp/http/server/http.cpp +++ b/library/cpp/http/server/http.cpp @@ -668,14 +668,14 @@ void TClientRequest::ReleaseConnection() { } } -void TClientRequest::ResetConnection() { - if (HttpConn_) { - // send RST packet to client - HttpConn_->Reset(); - HttpConn_.Destroy(); - } -} - +void TClientRequest::ResetConnection() { + if (HttpConn_) { + // send RST packet to client + HttpConn_->Reset(); + HttpConn_.Destroy(); + } +} + void TClientRequest::Process(void* ThreadSpecificResource) { THolder<TClientRequest> this_(this); diff --git a/library/cpp/http/server/http.h b/library/cpp/http/server/http.h index 1328bdce3f..b292d38f27 100644 --- a/library/cpp/http/server/http.h +++ b/library/cpp/http/server/http.h @@ -128,8 +128,8 @@ public: void ReleaseConnection(); - void ResetConnection(); - + void ResetConnection(); + private: /* * Processes the request after 'connection' been created and 'Headers' been read diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp index 16f72df972..cc62bb988e 100644 --- a/library/cpp/http/server/http_ut.cpp +++ b/library/cpp/http/server/http_ut.cpp @@ -481,29 +481,29 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { ExceptionMessage = CurrentExceptionMessage(); } - TString ExceptionMessage; - }; - - class TResetConnectionServer: public THttpServer::ICallBack { - class TRequest: public TClientRequest { - public: - bool Reply(void* /*tsr*/) override { - Output() << "HTTP/1.1"; - ResetConnection(); - - return true; - } - }; - + TString ExceptionMessage; + }; + + class TResetConnectionServer: public THttpServer::ICallBack { + class TRequest: public TClientRequest { + public: + bool Reply(void* /*tsr*/) override { + Output() << "HTTP/1.1"; + ResetConnection(); + + return true; + } + }; + public: - TClientRequest* CreateClient() override { - return new TRequest(); - } - - void OnException() override { - ExceptionMessage = CurrentExceptionMessage(); - } - + TClientRequest* CreateClient() override { + return new TRequest(); + } + + void OnException() override { + ExceptionMessage = CurrentExceptionMessage(); + } + TString ExceptionMessage; }; @@ -526,21 +526,21 @@ Y_UNIT_TEST_SUITE(THttpServerTest) { } }; - Y_UNIT_TEST(TTestResetConnection) { - TPortManager pm; - const ui16 port = pm.GetPort(); - - TResetConnectionServer serverImpl; - THttpServer server(&serverImpl, THttpServer::TOptions(port)); - UNIT_ASSERT(server.Start()); - - TTestRequest r(port, "request"); - - UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); - - server.Stop(); - }; - + Y_UNIT_TEST(TTestResetConnection) { + TPortManager pm; + const ui16 port = pm.GetPort(); + + TResetConnectionServer serverImpl; + THttpServer server(&serverImpl, THttpServer::TOptions(port)); + UNIT_ASSERT(server.Start()); + + TTestRequest r(port, "request"); + + UNIT_ASSERT_EXCEPTION_CONTAINS(r.Execute(), TSystemError, "Connection reset by peer"); + + server.Stop(); + }; + Y_UNIT_TEST(TTestReleaseConnection) { TPortManager pm; const ui16 port = pm.GetPort(); diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h index 7b30e98dc1..4c33498dfa 100644 --- a/library/cpp/protobuf/json/json2proto.h +++ b/library/cpp/protobuf/json/json2proto.h @@ -98,11 +98,11 @@ namespace NProtobufJson { return *this; } - TSelf& SetAllowUnknownFields(bool value) { - AllowUnknownFields = value; - return *this; - } - + TSelf& SetAllowUnknownFields(bool value) { + AllowUnknownFields = value; + return *this; + } + FldNameMode FieldNameMode = FieldNameOriginalCase; bool AllowUnknownFields = true; diff --git a/library/cpp/tvmauth/client/client_status.h b/library/cpp/tvmauth/client/client_status.h index 8805d471c8..bbaf29d289 100644 --- a/library/cpp/tvmauth/client/client_status.h +++ b/library/cpp/tvmauth/client/client_status.h @@ -10,7 +10,7 @@ namespace NTvmAuth { Ok, Warning, Error, - IncompleteTicketsSet, + IncompleteTicketsSet, }; TClientStatus(ECode state, TString&& lastError) @@ -35,23 +35,23 @@ namespace NTvmAuth { } TString CreateJugglerMessage() const { - return TStringBuilder() << GetJugglerCode() << ";TvmClient: " << LastError_ << "\n"; + return TStringBuilder() << GetJugglerCode() << ";TvmClient: " << LastError_ << "\n"; } private: - int32_t GetJugglerCode() const { - switch (Code_) { - case ECode::Ok: + int32_t GetJugglerCode() const { + switch (Code_) { + case ECode::Ok: return 0; // OK juggler check state - case ECode::Warning: - case ECode::IncompleteTicketsSet: + case ECode::Warning: + case ECode::IncompleteTicketsSet: return 1; // WARN juggler check state - case ECode::Error: + case ECode::Error: return 2; // CRIT juggler check state - } - return 2; // This should not happen, so set check state as CRIT. - } - + } + return 2; // This should not happen, so set check state as CRIT. + } + ECode Code_ = Ok; TString LastError_; }; diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp index f441cc3c35..6ec15c0e88 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.cpp @@ -53,10 +53,10 @@ namespace NTvmAuth::NDynamicClient { { } - TTvmClient::~TTvmClient() { - TBase::StopWorker(); - } - + TTvmClient::~TTvmClient() { + TBase::StopWorker(); + } + void TTvmClient::Worker() { TBase::Worker(); ProcessTasks(); diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h index ed9ba237a5..58ed953b63 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/tvm_client.h @@ -30,7 +30,7 @@ namespace NTvmAuth::NDynamicClient { class TTvmClient: public NTvmApi::TThreadedUpdater { public: static TAsyncUpdaterPtr Create(const NTvmApi::TClientSettings& settings, TLoggerPtr logger); - virtual ~TTvmClient(); + virtual ~TTvmClient(); NThreading::TFuture<TAddResponse> Add(TDsts&& dsts); std::optional<TString> GetOptionalServiceTicketFor(const TTvmId dst); diff --git a/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp b/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp index cd20efc4d9..89403c15e4 100644 --- a/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp +++ b/library/cpp/tvmauth/client/misc/api/dynamic_dst/ut/tvm_client_ut.cpp @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(DynamicClient) { mutable std::vector<TString> Tickets; }; - Y_UNIT_TEST(StartWithIncompleteTicketsSet) { + Y_UNIT_TEST(StartWithIncompleteTicketsSet) { TInstant now = TInstant::Now(); CleanCache(); WriteFile("./service_tickets", @@ -96,12 +96,12 @@ Y_UNIT_TEST_SUITE(DynamicClient) { NTvmApi::TClientSettings s; s.SetSelfTvmId(100500); - s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}, false); - s.SetDiskCacheDir(CACHE_DIR); - - auto l = MakeIntrusive<TLogger>(); - - { + s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}, false); + s.SetDiskCacheDir(CACHE_DIR); + + auto l = MakeIntrusive<TLogger>(); + + { TOfflineUpdater client(s, l, false, @@ -109,51 +109,51 @@ Y_UNIT_TEST_SUITE(DynamicClient) { R"({"213" : { "error" : "some error"}})", R"({"123" : { "ticket" : "service_ticket_3"}})", }); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(19)); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(19)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); - - NThreading::TFuture<TAddResponse> fut = client.Add({123}); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - - client.Worker(); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - + + NThreading::TFuture<TAddResponse> fut = client.Add({123}); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + + client.Worker(); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(19)); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(123)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(19)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(123)); - - UNIT_ASSERT(fut.HasValue()); - TAddResponse resp{ - {123, {EDstStatus::Success, ""}}, - }; - UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); - + + UNIT_ASSERT(fut.HasValue()); + TAddResponse resp{ + {123, {EDstStatus::Success, ""}}, + }; + UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); + UNIT_ASSERT(client.Tickets.empty()); - - TDsts dsts{19, 123, 213}; - UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); - - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - } - } - - Y_UNIT_TEST(StartWithEmptyTicketsSet) { + + TDsts dsts{19, 123, 213}; + UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); + + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + } + } + + Y_UNIT_TEST(StartWithEmptyTicketsSet) { CleanCache(); - - NTvmApi::TClientSettings s; - s.SetSelfTvmId(100500); - s.EnableServiceTicketsFetchOptions("qwerty", {{"kolmo", 213}}, false); - s.SetDiskCacheDir(CACHE_DIR); - - auto l = MakeIntrusive<TLogger>(); - - { + + NTvmApi::TClientSettings s; + s.SetSelfTvmId(100500); + s.EnableServiceTicketsFetchOptions("qwerty", {{"kolmo", 213}}, false); + s.SetDiskCacheDir(CACHE_DIR); + + auto l = MakeIntrusive<TLogger>(); + + { TOfflineUpdater client(s, l, false, @@ -161,46 +161,46 @@ Y_UNIT_TEST_SUITE(DynamicClient) { R"({"213" : { "error" : "some error"}})", R"({"123" : { "ticket" : "3:serv:CBAQ__________9_IgYIlJEGEHs:CcafYQH-FF5XaXMuJrgLZj98bIC54cs1ZkcFS9VV_9YM9iOM_0PXCtMkdg85rFjxE_BMpg7bE8ZuoqNfdw0FPt0BAKNeISwlydj4o0IjY82--LZBpP8CRn-EpAnkRaDShdlfrcF2pk1SSmEX8xdyZVQEnkUPY0cHGlFnu231vnE"}})", }); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - - NThreading::TFuture<TAddResponse> fut = client.Add({123}); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - - client.Worker(); - UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); - + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + + NThreading::TFuture<TAddResponse> fut = client.Add({123}); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + + client.Worker(); + UNIT_ASSERT_VALUES_EQUAL(TClientStatus::IncompleteTicketsSet, client.GetStatus()); + UNIT_ASSERT(!client.GetCachedServiceTickets()->TicketsById.contains(213)); UNIT_ASSERT(client.GetCachedServiceTickets()->TicketsById.contains(123)); UNIT_ASSERT(client.GetCachedServiceTickets()->ErrorsById.contains(213)); UNIT_ASSERT(!client.GetCachedServiceTickets()->ErrorsById.contains(123)); - - UNIT_ASSERT(fut.HasValue()); - TAddResponse resp{ - {123, {EDstStatus::Success, ""}}, - }; - UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); - + + UNIT_ASSERT(fut.HasValue()); + TAddResponse resp{ + {123, {EDstStatus::Success, ""}}, + }; + UNIT_ASSERT_VALUES_EQUAL(resp, fut.GetValue()); + UNIT_ASSERT(client.Tickets.empty()); - - TDsts dsts{123, 213}; - UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); - - UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); - } - }; - Y_UNIT_TEST(StartWithIncompleteCacheAndAdd) { - TInstant now = TInstant::Now(); + + TDsts dsts{123, 213}; + UNIT_ASSERT_VALUES_EQUAL(dsts, client.GetDsts()); + + UNIT_ASSERT_EXCEPTION_CONTAINS(client.GetOptionalServiceTicketFor(213), TMissingServiceTicket, "some error"); + } + }; + Y_UNIT_TEST(StartWithIncompleteCacheAndAdd) { + TInstant now = TInstant::Now(); CleanCache(); WriteFile("./service_tickets", - R"({"19" : { "ticket" : "3:serv:CBAQ__________9_IgYIKhCUkQY:CX"}})" - "\t100500", - now); - - NTvmApi::TClientSettings s; - s.SetSelfTvmId(100500); + R"({"19" : { "ticket" : "3:serv:CBAQ__________9_IgYIKhCUkQY:CX"}})" + "\t100500", + now); + + NTvmApi::TClientSettings s; + s.SetSelfTvmId(100500); s.EnableServiceTicketsFetchOptions("qwerty", {{"blackbox", 19}, {"kolmo", 213}}); s.SetDiskCacheDir(CACHE_DIR); diff --git a/library/cpp/tvmauth/client/misc/api/settings.h b/library/cpp/tvmauth/client/misc/api/settings.h index f0050b65e7..715ab3e02c 100644 --- a/library/cpp/tvmauth/client/misc/api/settings.h +++ b/library/cpp/tvmauth/client/misc/api/settings.h @@ -163,9 +163,9 @@ namespace NTvmAuth::NTvmApi { } // Deprecated: set attributes directly - void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, - TDstMap&& dsts, - const bool considerIncompleteTicketsSetAsError = true) { + void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, + TDstMap&& dsts, + const bool considerIncompleteTicketsSetAsError = true) { IsIncompleteTicketsSetAnError = considerIncompleteTicketsSetAsError; Secret = selfSecret; @@ -179,9 +179,9 @@ namespace NTvmAuth::NTvmApi { } // Deprecated: set attributes directly - void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, - TDstVector&& dsts, - const bool considerIncompleteTicketsSetAsError = true) { + void EnableServiceTicketsFetchOptions(const TStringBuf selfSecret, + TDstVector&& dsts, + const bool considerIncompleteTicketsSetAsError = true) { IsIncompleteTicketsSetAnError = considerIncompleteTicketsSetAsError; Secret = selfSecret; FetchServiceTicketsForDsts = std::move(dsts); diff --git a/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp b/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp index 3b691042cd..a7df49c05d 100644 --- a/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp +++ b/library/cpp/tvmauth/client/misc/api/threaded_updater.cpp @@ -50,7 +50,7 @@ namespace NTvmAuth::NTvmApi { TClientStatus TThreadedUpdater::GetStatus() const { const TClientStatus::ECode state = GetState(); - return TClientStatus(state, GetLastError(state == TClientStatus::Ok || state == TClientStatus::IncompleteTicketsSet)); + return TClientStatus(state, GetLastError(state == TClientStatus::Ok || state == TClientStatus::IncompleteTicketsSet)); } NRoles::TRolesPtr TThreadedUpdater::GetRoles() const { @@ -72,10 +72,10 @@ namespace NTvmAuth::NTvmApi { } if (tickets->TicketsById.size() < Destinations_.size()) { if (Settings_.IsIncompleteTicketsSetAnError) { - return TClientStatus::Error; - } else { - return TClientStatus::IncompleteTicketsSet; - } + return TClientStatus::Error; + } else { + return TClientStatus::IncompleteTicketsSet; + } } } if ((Settings_.IsServiceTicketCheckingRequired() || Settings_.IsUserTicketCheckingRequired()) && ArePublicKeysInvalid(now)) { @@ -375,9 +375,9 @@ namespace NTvmAuth::NTvmApi { SetUpdateTimeOfServiceTickets(time); - if (count > 0) { - LogInfo(TStringBuilder() << "Cache was updated with " << count << " service ticket(s): " << time); - } + if (count > 0) { + LogInfo(TStringBuilder() << "Cache was updated with " << count << " service ticket(s): " << time); + } } void TThreadedUpdater::UpdatePublicKeysCache(const TString& publicKeys, TInstant time) { diff --git a/library/cpp/tvmauth/client/misc/async_updater.cpp b/library/cpp/tvmauth/client/misc/async_updater.cpp index a8adef3d1f..9cb0332ed4 100644 --- a/library/cpp/tvmauth/client/misc/async_updater.cpp +++ b/library/cpp/tvmauth/client/misc/async_updater.cpp @@ -49,8 +49,8 @@ namespace NTvmAuth { } bool TAsyncUpdaterBase::AreServiceTicketsInvalid(TInstant now) const { - TServiceTicketsPtr c = GetCachedServiceTickets(); - // Empty set of tickets is allways valid. + TServiceTicketsPtr c = GetCachedServiceTickets(); + // Empty set of tickets is allways valid. return c && !c->TicketsById.empty() && IsInvalid(GetInvalidationTimeOfServiceTickets(), now); } diff --git a/library/cpp/tvmauth/client/misc/async_updater.h b/library/cpp/tvmauth/client/misc/async_updater.h index 1ff0b4f4e7..7b556d7a38 100644 --- a/library/cpp/tvmauth/client/misc/async_updater.h +++ b/library/cpp/tvmauth/client/misc/async_updater.h @@ -29,15 +29,15 @@ namespace NTvmAuth { public: using TMapAliasStr = THashMap<TClientSettings::TAlias, TString>; using TMapIdStr = THashMap<TTvmId, TString>; - using TIdSet = THashSet<TTvmId>; - using TAliasSet = THashSet<TClientSettings::TAlias>; + using TIdSet = THashSet<TTvmId>; + using TAliasSet = THashSet<TClientSettings::TAlias>; using TMapAliasId = THashMap<TClientSettings::TAlias, TTvmId>; TServiceTickets(TMapIdStr&& tickets, TMapIdStr&& errors, const TMapAliasId& dstMap) : TicketsById(std::move(tickets)) , ErrorsById(std::move(errors)) { - InitAliasesAndUnfetchedIds(dstMap); + InitAliasesAndUnfetchedIds(dstMap); InitInvalidationTime(); } @@ -66,7 +66,7 @@ namespace NTvmAuth { TAliasSet UnfetchedAliases; private: - void InitAliasesAndUnfetchedIds(const TMapAliasId& dstMap) { + void InitAliasesAndUnfetchedIds(const TMapAliasId& dstMap) { for (const auto& pair : dstMap) { auto it = TicketsById.find(pair.second); auto errIt = ErrorsById.find(pair.second); @@ -74,11 +74,11 @@ namespace NTvmAuth { if (it == TicketsById.end()) { if (errIt != ErrorsById.end()) { Y_ENSURE(ErrorsByAlias.insert({pair.first, errIt->second}).second, - "failed to add: " << pair.first); - } else { + "failed to add: " << pair.first); + } else { UnfetchedAliases.insert(pair.first); UnfetchedIds.insert(pair.second); - } + } } else { Y_ENSURE(TicketsByAlias.insert({pair.first, it->second}).second, "failed to add: " << pair.first); diff --git a/library/cpp/tvmauth/client/misc/getter.h b/library/cpp/tvmauth/client/misc/getter.h index 3f627dd4d4..b0327d69e9 100644 --- a/library/cpp/tvmauth/client/misc/getter.h +++ b/library/cpp/tvmauth/client/misc/getter.h @@ -28,8 +28,8 @@ namespace NTvmAuth { } private: - template <class Key, class Cont, class UnfetchedCont> - TString GetTicketImpl(const Key& dst, const Cont& tickets, const Cont& errors, const UnfetchedCont& unfetched) const { + template <class Key, class Cont, class UnfetchedCont> + TString GetTicketImpl(const Key& dst, const Cont& tickets, const Cont& errors, const UnfetchedCont& unfetched) const { auto it = tickets.find(dst); if (it != tickets.end()) { return it->second; @@ -42,11 +42,11 @@ namespace NTvmAuth { << it->second; } - if (unfetched.contains(dst)) { - ythrow TMissingServiceTicket() - << "Failed to get ticket for '" << dst << "': this dst was not fetched yet."; - } - + if (unfetched.contains(dst)) { + ythrow TMissingServiceTicket() + << "Failed to get ticket for '" << dst << "': this dst was not fetched yet."; + } + ythrow TBrokenTvmClientSettings() << "Destination '" << dst << "' was not specified in settings. " << "Check your settings (if you use Qloud/YP/tvmtool - check it's settings)"; diff --git a/library/cpp/tvmauth/client/ut/async_updater_ut.cpp b/library/cpp/tvmauth/client/ut/async_updater_ut.cpp index 0252ffcfc8..1c1e8cbaae 100644 --- a/library/cpp/tvmauth/client/ut/async_updater_ut.cpp +++ b/library/cpp/tvmauth/client/ut/async_updater_ut.cpp @@ -83,9 +83,9 @@ Y_UNIT_TEST_SUITE(AsyncUpdater) { Y_UNIT_TEST(ServiceTickets_Aliases) { using TId = TServiceTickets::TMapIdStr; - using TUnfetchedId = TServiceTickets::TIdSet; + using TUnfetchedId = TServiceTickets::TIdSet; using TStr = TServiceTickets::TMapAliasStr; - using TUnfetchedAlias = TServiceTickets::TAliasSet; + using TUnfetchedAlias = TServiceTickets::TAliasSet; using TAls = TServiceTickets::TMapAliasId; TServiceTickets t(TId{}, TId{}, TAls{}); @@ -106,14 +106,14 @@ Y_UNIT_TEST_SUITE(AsyncUpdater) { UNIT_ASSERT_EQUAL(TStr({{"1", "t1"}, {"2", "t2"}}), t.TicketsByAlias); UNIT_ASSERT_EQUAL(TStr({{"3", "e1"}}), t.ErrorsByAlias); UNIT_ASSERT_EQUAL(TUnfetchedAlias({}), t.UnfetchedAliases); - } - - Y_UNIT_TEST(ServiceTickets_UnfetchedIds) { - using TId = TServiceTickets::TMapIdStr; - using TUnfetchedId = TServiceTickets::TIdSet; - using TStr = TServiceTickets::TMapAliasStr; - using TUnfetchedAlias = TServiceTickets::TAliasSet; - using TAls = TServiceTickets::TMapAliasId; + } + + Y_UNIT_TEST(ServiceTickets_UnfetchedIds) { + using TId = TServiceTickets::TMapIdStr; + using TUnfetchedId = TServiceTickets::TIdSet; + using TStr = TServiceTickets::TMapAliasStr; + using TUnfetchedAlias = TServiceTickets::TAliasSet; + using TAls = TServiceTickets::TMapAliasId; TServiceTickets t(TId({{1, "t1"}, {2, "t2"}}), TId(), TAls({{"1", 1}, {"2", 2}, {"3", 3}})); |