Skip to content

Commit fe4595c

Browse files
committed
tests: fix tests Grant and Revoke NoSu
Fixed and renamed tests. Now, tests follow new Tarantool behavior (about 'grant' and 'revoke' privileges). Closes #511
1 parent 6a24a64 commit fe4595c

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

box/tarantool_test.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func TestSchemaUser_Info_NonExistsUser(t *testing.T) {
428428
require.Nil(t, privileges)
429429
}
430430

431-
func TestBox_Sugar_Schema_UserGrant_NoSu(t *testing.T) {
431+
func TestSchemaUser_Grant_NoSu(t *testing.T) {
432432
const (
433433
username = "to_grant_no_su"
434434
password = "to_grant_no_su"
@@ -446,6 +446,9 @@ 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+
err = b.Session().Su(ctx, username)
450+
require.NoError(t, err)
451+
449452
err = b.Schema().User().Grant(ctx, username, box.Privilege{
450453
Permissions: []box.Permission{
451454
box.PermissionRead,
@@ -461,7 +464,7 @@ func TestBox_Sugar_Schema_UserGrant_NoSu(t *testing.T) {
461464
require.Equal(t, iproto.ER_ACCESS_DENIED, boxErr.Code)
462465
}
463466

464-
func TestBox_Sugar_Schema_UserGrant_WithSu(t *testing.T) {
467+
func TestSchemaUserGrant_WithSu(t *testing.T) {
465468
const (
466469
username = "to_grant_with_su"
467470
password = "to_grant_with_su"
@@ -529,14 +532,23 @@ func TestSchemaUser_Revoke_WithoutSu(t *testing.T) {
529532
err = b.Schema().User().Create(ctx, username, box.UserCreateOptions{Password: password})
530533
require.NoError(t, err)
531534

535+
startPrivileges, err := b.Schema().User().Info(ctx, username)
536+
require.NoError(t, err)
537+
538+
require.NotEmpty(t, startPrivileges)
539+
// Let's choose random first privilege.
540+
examplePriv := startPrivileges[0]
541+
542+
err = b.Session().Su(ctx, username)
543+
require.NoError(t, err)
544+
532545
// 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})
546+
err = b.Schema().User().Revoke(ctx,
547+
username,
548+
examplePriv,
549+
box.UserRevokeOptions{
550+
IfExists: false,
551+
})
540552
require.Error(t, err)
541553

542554
// Require that error code is ER_ACCESS_DENIED.

0 commit comments

Comments
 (0)