aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/ut/utils_ut.cpp
diff options
context:
space:
mode:
authorcerevra <cerevra@yandex-team.ru>2022-02-10 16:45:59 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:59 +0300
commit4f292c7e2fd0a41da93fda51b2d440c979a330b7 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/tvmauth/client/ut/utils_ut.cpp
parentbf41dd01f6c920583e9faae7cd55ed25e547e052 (diff)
downloadydb-4f292c7e2fd0a41da93fda51b2d440c979a330b7.tar.gz
Restoring authorship annotation for <cerevra@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/tvmauth/client/ut/utils_ut.cpp')
-rw-r--r--library/cpp/tvmauth/client/ut/utils_ut.cpp174
1 files changed, 87 insertions, 87 deletions
diff --git a/library/cpp/tvmauth/client/ut/utils_ut.cpp b/library/cpp/tvmauth/client/ut/utils_ut.cpp
index 23ac35f416..e780fb2779 100644
--- a/library/cpp/tvmauth/client/ut/utils_ut.cpp
+++ b/library/cpp/tvmauth/client/ut/utils_ut.cpp
@@ -1,88 +1,88 @@
-#include <library/cpp/tvmauth/client/misc/utils.h>
-
+#include <library/cpp/tvmauth/client/misc/utils.h>
+
#include <library/cpp/testing/unittest/registar.h>
-
-Y_UNIT_TEST_SUITE(UtilsTest) {
- using namespace NTvmAuth;
-
- Y_UNIT_TEST(ParseDstMap) {
- using TMap = NTvmAuth::NTvmApi::TClientSettings::TDstMap;
- UNIT_ASSERT_EQUAL(TMap(), NUtils::ParseDstMap(""));
- UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap(";"), TFromStringException);
- UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap(":"), TFromStringException);
- UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap("3;"), TFromStringException);
- UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap("3:foo;"), TFromStringException);
-
- UNIT_ASSERT_EQUAL(TMap({
- {"foo", 3},
- }),
- NUtils::ParseDstMap("foo:3"));
- UNIT_ASSERT_EQUAL(TMap({
- {"foo", 3},
- {"bar", 17},
- }),
- NUtils::ParseDstMap("foo:3;bar:17;"));
- }
-
- Y_UNIT_TEST(ParseDstVector) {
- using TVector = NTvmAuth::NTvmApi::TClientSettings::TDstVector;
- UNIT_ASSERT_EQUAL(TVector(), NUtils::ParseDstVector(""));
- UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector(";"),
- yexception,
- "Cannot parse empty string as number");
- UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector(":"),
- yexception,
- "Unexpected symbol");
- UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector("3:foo;"),
- yexception,
- "Unexpected symbol");
- UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector("foo:3;"),
- yexception,
- "Unexpected symbol");
-
- UNIT_ASSERT_EQUAL(TVector(1, 3),
- NUtils::ParseDstVector("3"));
- UNIT_ASSERT_EQUAL(TVector({3, 17}),
- NUtils::ParseDstVector("3;17;"));
- }
-
- Y_UNIT_TEST(ToHex) {
- UNIT_ASSERT_VALUES_EQUAL("", NUtils::ToHex(""));
- UNIT_ASSERT_VALUES_EQUAL("61", NUtils::ToHex("a"));
- UNIT_ASSERT_VALUES_EQUAL(
- "6C6B787A6E7620736C6A6876627761656220",
- NUtils::ToHex("lkxznv sljhvbwaeb "));
- }
-
- Y_UNIT_TEST(CheckBbEnvOverriding) {
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Prod));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::ProdYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Test));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::TestYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Stress));
-
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Prod));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::ProdYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Test));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::TestYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Stress));
-
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Prod));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::ProdYateam));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Test));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::TestYateam));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Stress));
-
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Prod));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::ProdYateam));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Test));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::TestYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Stress));
-
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Prod));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::ProdYateam));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Test));
- UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::TestYateam));
- UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Stress));
- }
-}
+
+Y_UNIT_TEST_SUITE(UtilsTest) {
+ using namespace NTvmAuth;
+
+ Y_UNIT_TEST(ParseDstMap) {
+ using TMap = NTvmAuth::NTvmApi::TClientSettings::TDstMap;
+ UNIT_ASSERT_EQUAL(TMap(), NUtils::ParseDstMap(""));
+ UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap(";"), TFromStringException);
+ UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap(":"), TFromStringException);
+ UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap("3;"), TFromStringException);
+ UNIT_ASSERT_EXCEPTION(NUtils::ParseDstMap("3:foo;"), TFromStringException);
+
+ UNIT_ASSERT_EQUAL(TMap({
+ {"foo", 3},
+ }),
+ NUtils::ParseDstMap("foo:3"));
+ UNIT_ASSERT_EQUAL(TMap({
+ {"foo", 3},
+ {"bar", 17},
+ }),
+ NUtils::ParseDstMap("foo:3;bar:17;"));
+ }
+
+ Y_UNIT_TEST(ParseDstVector) {
+ using TVector = NTvmAuth::NTvmApi::TClientSettings::TDstVector;
+ UNIT_ASSERT_EQUAL(TVector(), NUtils::ParseDstVector(""));
+ UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector(";"),
+ yexception,
+ "Cannot parse empty string as number");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector(":"),
+ yexception,
+ "Unexpected symbol");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector("3:foo;"),
+ yexception,
+ "Unexpected symbol");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(NUtils::ParseDstVector("foo:3;"),
+ yexception,
+ "Unexpected symbol");
+
+ UNIT_ASSERT_EQUAL(TVector(1, 3),
+ NUtils::ParseDstVector("3"));
+ UNIT_ASSERT_EQUAL(TVector({3, 17}),
+ NUtils::ParseDstVector("3;17;"));
+ }
+
+ Y_UNIT_TEST(ToHex) {
+ UNIT_ASSERT_VALUES_EQUAL("", NUtils::ToHex(""));
+ UNIT_ASSERT_VALUES_EQUAL("61", NUtils::ToHex("a"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ "6C6B787A6E7620736C6A6876627761656220",
+ NUtils::ToHex("lkxznv sljhvbwaeb "));
+ }
+
+ Y_UNIT_TEST(CheckBbEnvOverriding) {
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Prod));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::ProdYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Test));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::TestYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Prod, EBlackboxEnv::Stress));
+
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Prod));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::ProdYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Test));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::TestYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::ProdYateam, EBlackboxEnv::Stress));
+
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Prod));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::ProdYateam));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Test));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::TestYateam));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Test, EBlackboxEnv::Stress));
+
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Prod));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::ProdYateam));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Test));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::TestYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::TestYateam, EBlackboxEnv::Stress));
+
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Prod));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::ProdYateam));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Test));
+ UNIT_ASSERT(!NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::TestYateam));
+ UNIT_ASSERT(NUtils::CheckBbEnvOverriding(EBlackboxEnv::Stress, EBlackboxEnv::Stress));
+ }
+}