@@ -446,6 +446,14 @@ 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+ this_user := data [0 ].(string )
451+
452+ err = b .Session ().Su (ctx , username )
453+ require .NoError (t , err )
454+
455+ defer b .Session ().Su (ctx , this_user )
456+
449457 err = b .Schema ().User ().Grant (ctx , username , box.Privilege {
450458 Permissions : []box.Permission {
451459 box .PermissionRead ,
@@ -461,7 +469,7 @@ func TestBox_Sugar_Schema_UserGrant_NoSu(t *testing.T) {
461469 require .Equal (t , iproto .ER_ACCESS_DENIED , boxErr .Code )
462470}
463471
464- func TestBox_Sugar_Schema_UserGrant_WithSu (t * testing.T ) {
472+ func TestSchemaUserGrant_WithSu (t * testing.T ) {
465473 const (
466474 username = "to_grant_with_su"
467475 password = "to_grant_with_su"
@@ -529,14 +537,28 @@ func TestSchemaUser_Revoke_WithoutSu(t *testing.T) {
529537 err = b .Schema ().User ().Create (ctx , username , box.UserCreateOptions {Password : password })
530538 require .NoError (t , err )
531539
540+ startPrivileges , err := b .Schema ().User ().Info (ctx , username )
541+ require .NoError (t , err )
542+
543+ require .NotEmpty (t , startPrivileges )
544+ // Let's choose random first privilege.
545+ examplePriv := startPrivileges [0 ]
546+
547+ data , err := conn .Do (tarantool .NewCallRequest ("box.session.user" )).Get ()
548+ this_user := data [0 ].(string )
549+
550+ err = b .Session ().Su (ctx , username )
551+ require .NoError (t , err )
552+
553+ defer b .Session ().Su (ctx , this_user )
554+
532555 // 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 })
556+ err = b .Schema ().User ().Revoke (ctx ,
557+ username ,
558+ examplePriv ,
559+ box.UserRevokeOptions {
560+ IfExists : false ,
561+ })
540562 require .Error (t , err )
541563
542564 // Require that error code is ER_ACCESS_DENIED.
0 commit comments