diff options
author | flown4qqqq <flown4qqqq@yandex-team.com> | 2025-01-24 00:47:07 +0300 |
---|---|---|
committer | flown4qqqq <flown4qqqq@yandex-team.com> | 2025-01-24 01:01:16 +0300 |
commit | bf896a57c7a7ffb14ba93068a4c3efeab50dfb36 (patch) | |
tree | 38715f12c0ddf2192da62ab1a41f119c0293e1e2 /yql/essentials/sql/v1/sql_ut.cpp | |
parent | e0834724754ae9e26fd14e27027e69cc22d1939f (diff) | |
download | ydb-bf896a57c7a7ffb14ba93068a4c3efeab50dfb36.tar.gz |
Add option 'HASH' into CREATE USER
Need for: <https://github.com/ydb-platform/ydb-rfc/blob/main/backup_fstek.md>
```
CREATE USER my_user HASH '
{"hash": "p4ffeMugohqyBwyckYCK1TjJfz3LIHbKiGL+t+oEhzw=",
"salt": "U+tzBtgo06EBQCjlARA6Jg==",
"type": "argon2id"
}'
```
commit_hash:a0c695c2e2f7f794e5c4db978fe33a7bfea59e2c
Diffstat (limited to 'yql/essentials/sql/v1/sql_ut.cpp')
-rw-r--r-- | yql/essentials/sql/v1/sql_ut.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/yql/essentials/sql/v1/sql_ut.cpp b/yql/essentials/sql/v1/sql_ut.cpp index 9baf35f8f4..6bdd2c7e44 100644 --- a/yql/essentials/sql/v1/sql_ut.cpp +++ b/yql/essentials/sql/v1/sql_ut.cpp @@ -5017,7 +5017,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqCreateUser.IsOk()); - UNIT_ASSERT(reqCreateUser.Root); auto reqAlterUser = SqlToYql(R"( USE plato; @@ -5033,7 +5032,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqPasswordAndLogin.IsOk()); - UNIT_ASSERT(reqPasswordAndLogin.Root); auto reqPasswordAndNoLogin = SqlToYql(R"( USE plato; @@ -5041,7 +5039,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqPasswordAndNoLogin.IsOk()); - UNIT_ASSERT(reqPasswordAndNoLogin.Root); auto reqLogin = SqlToYql(R"( USE plato; @@ -5049,7 +5046,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqLogin.IsOk()); - UNIT_ASSERT(reqLogin.Root); auto reqNoLogin = SqlToYql(R"( USE plato; @@ -5057,7 +5053,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqNoLogin.IsOk()); - UNIT_ASSERT(reqNoLogin.Root); auto reqLoginNoLogin = SqlToYql(R"( USE plato; @@ -5074,7 +5069,6 @@ select FormatType($f()); )"); UNIT_ASSERT(reqAlterLoginNoLogin.IsOk()); - UNIT_ASSERT(reqAlterLoginNoLogin.Root); auto reqAlterLoginNoLoginWithPassword = SqlToYql(R"( USE plato; @@ -5083,7 +5077,56 @@ select FormatType($f()); )"); UNIT_ASSERT(reqAlterLoginNoLoginWithPassword.IsOk()); - UNIT_ASSERT(reqAlterLoginNoLoginWithPassword.Root); + } + + Y_UNIT_TEST(CreateUserWithHash) { + auto reqCreateUser = SqlToYql(R"( + USE plato; + CREATE USER user1 HASH '{ + "hash": "p4ffeMugohqyBwyckYCK1TjJfz3LIHbKiGL+t+oEhzw=", + "salt": "U+tzBtgo06EBQCjlARA6Jg==", + "type": "argon2id" + }'; + )"); + + UNIT_ASSERT(reqCreateUser.IsOk()); + + auto reqCreateUserWithNoLogin = SqlToYql(R"( + USE plato; + CREATE USER user1 HASH '{ + "hash": "p4ffeMugohqyBwyckYCK1TjJfz3LIHbKiGL+t+oEhzw=", + "salt": "U+tzBtgo06EBQCjlARA6Jg==", + "type": "argon2id" + }' + NOLOGIN; + )"); + + UNIT_ASSERT(reqCreateUserWithNoLogin.IsOk()); + + auto reqCreateUserWithPassword = SqlToYql(R"( + USE plato; + CREATE USER user1 HASH '{ + "hash": "p4ffeMugohqyBwyckYCK1TjJfz3LIHbKiGL+t+oEhzw=", + "salt": "U+tzBtgo06EBQCjlARA6Jg==", + "type": "argon2id" + }' + PASSWORD '123'; + )"); + + UNIT_ASSERT(!reqCreateUserWithPassword.IsOk()); + UNIT_ASSERT_STRING_CONTAINS(reqCreateUserWithPassword.Issues.ToString(), "Error: Conflicting or redundant options"); + + auto reqAlterUser = SqlToYql(R"( + USE plato; + CREATE USER user1; + ALTER USER user1 HASH '{ + "hash": "p4ffeMugohqyBwyckYCK1TjJfz3LIHbKiGL+t+oEhzw=", + "salt": "U+tzBtgo06EBQCjlARA6Jg==", + "type": "argon2id" + }'; + )"); + + UNIT_ASSERT(reqAlterUser.IsOk()); } Y_UNIT_TEST(CreateAlterUserWithoutCluster) { |