@@ -112,6 +112,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) {
112112 TTestEnv env (runtime);
113113 ui64 txId = 100 ;
114114 CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user1" , " password1" );
115+ CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user2" , " password2" );
115116 auto resultLogin = Login (runtime, " user1" , " password1" );
116117 UNIT_ASSERT_VALUES_EQUAL (resultLogin.error (), " " );
117118
@@ -171,6 +172,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) {
171172 TTestEnv env (runtime);
172173 ui64 txId = 100 ;
173174 CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user1" , " password1" );
175+ CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user2" , " password2" );
174176 auto resultLogin = Login (runtime, " user1" , " password1" );
175177 UNIT_ASSERT_VALUES_EQUAL (resultLogin.error (), " " );
176178
@@ -249,6 +251,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) {
249251 TTestEnv env (runtime);
250252 ui64 txId = 100 ;
251253 CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user1" , " password1" );
254+ CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user2" , " password2" );
252255 auto resultLogin = Login (runtime, " user1" , " password1" );
253256 UNIT_ASSERT_VALUES_EQUAL (resultLogin.error (), " " );
254257
@@ -308,6 +311,53 @@ Y_UNIT_TEST_SUITE(TSchemeShardLoginTest) {
308311 auto describe = DescribePath (runtime, TTestTxConfig::SchemeShard, " /MyRoot" );
309312 CheckSecurityState (describe, {.PublicKeysSize = 1 , .SidsSize = 0 });
310313 }
314+
315+ Y_UNIT_TEST (AddAccess_NonExisting) {
316+ TTestBasicRuntime runtime;
317+ TTestEnv env (runtime);
318+ ui64 txId = 100 ;
319+
320+ AsyncMkDir (runtime, ++txId, " /MyRoot" , " Dir1" );
321+ TestModificationResult (runtime, txId, NKikimrScheme::StatusAccepted);
322+
323+ {
324+ NACLib::TDiffACL diffACL;
325+ diffACL.AddAccess (NACLib::EAccessType::Allow, NACLib::GenericUse, " user1" );
326+ AsyncModifyACL (runtime, ++txId, " /MyRoot" , " Dir1" , diffACL.SerializeAsString (), " " );
327+ TestModificationResults (runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, " SID user1 not found" }});
328+ }
329+
330+ {
331+ AsyncModifyACL (runtime, ++txId, " /MyRoot" , " Dir1" , NACLib::TDiffACL{}.SerializeAsString (), " user1" );
332+ TestModificationResults (runtime, txId, {{NKikimrScheme::StatusPreconditionFailed, " Owner SID user1 not found" }});
333+ }
334+
335+ CreateAlterLoginCreateUser (runtime, ++txId, " /MyRoot" , " user1" , " password1" );
336+
337+ TestDescribeResult (DescribePath (runtime, " /MyRoot/Dir1" ),
338+ {NLs::HasNoRight (" +U:user1" ), NLs::HasNoEffectiveRight (" +U:user1" ), NLs::HasOwner (" root@builtin" )});
339+ }
340+
341+ Y_UNIT_TEST (AddAccess_NonYdb) {
342+ TTestBasicRuntime runtime;
343+ TTestEnv env (runtime);
344+ ui64 txId = 100 ;
345+
346+ AsyncMkDir (runtime, ++txId, " /MyRoot" , " Dir1" );
347+ TestModificationResult (runtime, txId, NKikimrScheme::StatusAccepted);
348+
349+ {
350+ NACLib::TDiffACL diffACL;
351+ diffACL.AddAccess (NACLib::EAccessType::Allow, NACLib::GenericUse, " user1@staff" );
352+ AsyncModifyACL (runtime, ++txId, " /MyRoot" , " Dir1" , diffACL.SerializeAsString (), " " );
353+ TestModificationResult (runtime, txId, NKikimrScheme::StatusSuccess);
354+ }
355+
356+ {
357+ AsyncModifyACL (runtime, ++txId, " /MyRoot" , " Dir1" , NACLib::TDiffACL{}.SerializeAsString (), " user1@staff" );
358+ TestModificationResult (runtime, txId, NKikimrScheme::StatusSuccess);
359+ }
360+ }
311361
312362 Y_UNIT_TEST (DisableBuiltinAuthMechanism) {
313363 TTestBasicRuntime runtime;
0 commit comments