@@ -446,6 +446,18 @@ func TestBox_Sugar_Schema_UserGrant_NoSu(t *testing.T) {
446446 err = b .Schema ().User ().Create (ctx , username , box.UserCreateOptions {Password : password })
447447 require .NoError (t , err )
448448
449+ data , err := conn .Do (tarantool .NewCallRequest ("box.session.user" )).Get ()
450+ require .NoError (t , err )
451+ this_user := data [0 ].(string )
452+
453+ err = b .Session ().Su (ctx , username )
454+ require .NoError (t , err )
455+
456+ defer func () {
457+ err = b .Session ().Su (ctx , this_user )
458+ require .NoError (t , err )
459+ }()
460+
449461 err = b .Schema ().User ().Grant (ctx , username , box.Privilege {
450462 Permissions : []box.Permission {
451463 box .PermissionRead ,
@@ -529,14 +541,32 @@ func TestSchemaUser_Revoke_WithoutSu(t *testing.T) {
529541 err = b .Schema ().User ().Create (ctx , username , box.UserCreateOptions {Password : password })
530542 require .NoError (t , err )
531543
544+ startPrivileges , err := b .Schema ().User ().Info (ctx , username )
545+ require .NoError (t , err )
546+
547+ require .NotEmpty (t , startPrivileges )
548+ // Let's choose random first privilege.
549+ examplePriv := startPrivileges [0 ]
550+
551+ data , err := conn .Do (tarantool .NewCallRequest ("box.session.user" )).Get ()
552+ require .NoError (t , err )
553+ this_user := data [0 ].(string )
554+
555+ err = b .Session ().Su (ctx , username )
556+ require .NoError (t , err )
557+
558+ defer func () {
559+ err = b .Session ().Su (ctx , this_user )
560+ require .NoError (t , err )
561+ }()
562+
532563 // Can`t revoke without su permissions.
533- err = b .Schema ().User ().Grant (ctx , username , box.Privilege {
534- Permissions : []box.Permission {
535- box .PermissionRead ,
536- },
537- Type : box .PrivilegeSpace ,
538- Name : "space1" ,
539- }, box.UserGrantOptions {IfNotExists : false })
564+ err = b .Schema ().User ().Revoke (ctx ,
565+ username ,
566+ examplePriv ,
567+ box.UserRevokeOptions {
568+ IfExists : false ,
569+ })
540570 require .Error (t , err )
541571
542572 // Require that error code is ER_ACCESS_DENIED.
0 commit comments