<HTML><BODY><div><div>Error message on granted privileges was not flexible and<br>did not distinguish between universal or any other priviliges<br>leaving either 'nil' or simply '' at the end.</div><div> </div><div>Closes #714</div><hr><div>Issue:<br><a href="https://github.com/tarantool/tarantool/issues/714">https://github.com/tarantool/tarantool/issues/714</a> <br>Branch:<br><a href="https://github.com/tarantool/tarantool/tree/eljashm/gh-714-box-schema-user-grant-invalid-error">https://github.com/tarantool/tarantool/tree/eljashm/gh-714-box-schema-user-grant-invalid-error</a> </div><div> </div><div> src/box/errcode.h        |  2 +-<br> src/box/lua/schema.lua   |  3 +++<br> test/box/access.result   | 30 ++++++++++++++++++++++++++++--<br> test/box/access.test.lua | 14 ++++++++++++++<br> 4 files changed, 46 insertions(+), 3 deletions(-)</div><div> </div><div>diff --git a/src/box/errcode.h b/src/box/errcode.h<br>index 6f6e28c6c..cac8447e2 100644<br>--- a/src/box/errcode.h<br>+++ b/src/box/errcode.h</div><div>@@ -141,7 +141,7 @@ struct errcode_record {<br>     /* 86 */_(ER_SESSION_CLOSED,        "Session is closed") \<br>     /* 87 */_(ER_ROLE_LOOP,            "Granting role '%s' to role '%s' would create a loop") \<br>     /* 88 */_(ER_GRANT,            "Incorrect grant arguments: %s") \<br>-    /* 89 */_(ER_PRIV_GRANTED,        "User '%s' already has %s access on %s '%s'") \<br>+    /* 89 */_(ER_PRIV_GRANTED,        "User '%s' already has %s access on %s%s") \<br>     /* 90 */_(ER_ROLE_GRANTED,        "User '%s' already has role '%s'") \<br>     /* 91 */_(ER_PRIV_NOT_GRANTED,        "User '%s' does not have %s access on %s '%s'") \<br>     /* 92 */_(ER_ROLE_NOT_GRANTED,        "User '%s' does not have role '%s'") \</div><div> </div><div>diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua<br>index 50c96a335..228f8798a 100644<br>--- a/src/box/lua/schema.lua<br>+++ b/src/box/lua/schema.lua<br>@@ -2408,6 +2408,9 @@ local function grant(uid, name, privilege, object_type,<br>                privilege == 'execute' then<br>                 box.error(box.error.ROLE_GRANTED, name, object_name)<br>             else<br>+                if object_type ~= 'universe' then<br>+                    object_name = ' \''..object_name..'\''<br>+                end<br>                 box.error(box.error.PRIV_GRANTED, name, privilege,<br>                           object_type, object_name)<br>             end</div><div> </div><div>diff --git a/test/box/access.result b/test/box/access.result<br>index 9554991ad..be8b1c521 100644<br>--- a/test/box/access.result<br>+++ b/test/box/access.result<br>@@ -532,7 +532,7 @@ box.space._priv:select{id}<br> ...<br> box.schema.user.grant('user', 'read', 'universe')<br> ---<br>-- error: User 'user' already has read access on universe ''<br>+- error: User 'user' already has read access on universe<br> ...<br> box.space._priv:select{id}<br> ---<br>@@ -738,7 +738,7 @@ box.schema.user.grant('guest', 'read,write,execute', 'universe')<br> ...<br> box.schema.user.grant('guest', 'read,write,execute', 'universe')<br> ---<br>-- error: User 'guest' already has read,write,execute access on universe ''<br>+- error: User 'guest' already has read,write,execute access on universe<br> ...<br> box.schema.user.grant('guest', 'read,write,execute', 'universe', '', { if_not_exists = true })<br> ---<br>@@ -2108,3 +2108,29 @@ box.space._priv:delete{1, 'universe', 0}<br> ---<br> - error: 'Incorrect grant arguments: can''t revoke universe from the admin user'<br> ...<br>+--<br>+-- gh-714: box.schema.user.grant error should be versatile,<br>+-- i.e. error on universally granted privileges shouldn't<br>+-- include any redundant details and/or symbols<br>+--<br>+box.schema.user.grant('guest', 'read,write,execute', 'universe')<br>+---<br>+...<br>+box.schema.user.grant('guest', 'read,write,execute', 'universe')<br>+---<br>+- error: User 'guest' already has read,write,execute access on universe<br>+...<br>+-- expected behavior of grant() error shouldn't change otherwise<br>+sp = box.schema.create_space('not_universe')<br>+---<br>+...<br>+box.schema.user.grant('guest', 'read,write,execute', 'space', 'not_universe')<br>+---<br>+...<br>+box.schema.user.grant('guest', 'read,write,execute', 'space', 'not_universe')<br>+---<br>+- error: User 'guest' already has read,write,execute access on space 'not_universe'<br>+...<br>+sp:drop()<br>+---<br>+...</div><div> </div><div>diff --git a/test/box/access.test.lua b/test/box/access.test.lua<br>index 759827721..46373b71a 100644<br>--- a/test/box/access.test.lua<br>+++ b/test/box/access.test.lua<br>@@ -806,3 +806,17 @@ box.schema.user.drop("user3")<br> -- instance could not bootstrap nor recovery.<br> --<br> box.space._priv:delete{1, 'universe', 0}<br>+<br>+--<br>+-- gh-714: box.schema.user.grant error should be versatile,<br>+-- i.e. error on universally granted privileges shouldn't<br>+-- include any redundant details and/or symbols<br>+--<br>+box.schema.user.grant('guest', 'read,write,execute', 'universe')<br>+box.schema.user.grant('guest', 'read,write,execute', 'universe')<br>+<br>+-- expected behavior of grant() error shouldn't change otherwise<br>+sp = box.schema.create_space('not_universe')<br>+box.schema.user.grant('guest', 'read,write,execute', 'space', 'not_universe')<br>+box.schema.user.grant('guest', 'read,write,execute', 'space', 'not_universe')<br>+sp:drop()<br>-- <br>2.24.0</div></div><div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Maria Khaydich</div></div></div></BODY></HTML>