Skip to content

Commit 949287c

Browse files
authored
Fix message about absent SID in local schemeshard (#14458)
1 parent 51dd5e5 commit 949287c

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

ydb/core/tx/schemeshard/schemeshard__operation_modify_acl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class TModifyACL: public TSubOperationBase {
1717

1818
THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
1919
const TTabletId ssId = context.SS->SelfTabletId();
20+
const TString databaseName = CanonizePath(context.SS->RootPathElements);
2021

2122
const TString& parentPathStr = Transaction.GetWorkingDir();
2223
const auto& op = Transaction.GetModifyACL();
@@ -62,7 +63,7 @@ class TModifyACL: public TSubOperationBase {
6263
if (static_cast<NACLib::EDiffType>(diffACE.GetDiffType()) == NACLib::EDiffType::Add) {
6364
if (!CheckSidExistsOrIsNonYdb(context.SS->LoginProvider.Sids, diffACE.GetACE().GetSID())) {
6465
result->SetError(NKikimrScheme::StatusPreconditionFailed,
65-
TStringBuilder() << "SID " << diffACE.GetACE().GetSID() << " not found");
66+
TStringBuilder() << "SID " << diffACE.GetACE().GetSID() << " not found in database `" << databaseName << "`");
6667
return result;
6768
}
6869
} // remove diff type is allowed in any case
@@ -71,7 +72,7 @@ class TModifyACL: public TSubOperationBase {
7172
if (owner && AppData()->FeatureFlags.GetEnableStrictAclCheck()) {
7273
if (!CheckSidExistsOrIsNonYdb(context.SS->LoginProvider.Sids, owner)) {
7374
result->SetError(NKikimrScheme::StatusPreconditionFailed,
74-
TStringBuilder() << "Owner SID " << owner << " not found");
75+
TStringBuilder() << "Owner SID " << owner << " not found in database `" << databaseName << "`");
7576
return result;
7677
}
7778
}

ydb/core/tx/schemeshard/ut_login/ut_login.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) {
451451

452452
if (StrictAclCheck) {
453453
AsyncModifyACL(runtime, ++txId, "/MyRoot", "Dir1", diffACL.SerializeAsString(), "");
454-
TestModificationResults(runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, "SID user1 not found"}});
454+
TestModificationResults(runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, "SID user1 not found in database `/MyRoot`"}});
455455

456456
AsyncModifyACL(runtime, ++txId, "/MyRoot", "Dir1", NACLib::TDiffACL{}.SerializeAsString(), "user1");
457-
TestModificationResults(runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, "Owner SID user1 not found"}});
457+
TestModificationResults(runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, "Owner SID user1 not found in database `/MyRoot`"}});
458458
}
459459

460460
CreateAlterLoginCreateUser(runtime, ++txId, "/MyRoot", "user1", "password1");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
import logging
3+
4+
from ydb.tests.oss.ydb_sdk_import import ydb
5+
6+
logger = logging.getLogger(__name__)
7+
8+
9+
# local configuration for the ydb cluster (fetched by ydb_cluster_configuration fixture)
10+
CLUSTER_CONFIG = dict(
11+
extra_feature_flags=['enable_strict_acl_check']
12+
)
13+
14+
15+
def test_create_user(ydb_client, ydb_root, ydb_database):
16+
with ydb_client(ydb_root) as driver:
17+
with ydb.QuerySessionPool(driver, size=1) as pool:
18+
pool.execute_with_retries("CREATE USER user;")
19+
20+
with ydb_client(ydb_database) as driver:
21+
with ydb.QuerySessionPool(driver, size=1) as pool:
22+
finished = False
23+
try:
24+
pool.execute_with_retries(f"GRANT ALL ON `{ydb_database}` TO user;")
25+
finished = True
26+
except Exception as e:
27+
assert f"SID user not found in database `{ydb_database}`" in str(e)
28+
29+
assert not finished

ydb/tests/functional/tenants/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
55
TEST_SRCS(
66
conftest.py
77
test_create_users.py
8+
test_create_users_strict_acl_checks.py
89
test_db_counters.py
910
test_dynamic_tenants.py
1011
test_tenants.py

0 commit comments

Comments
 (0)