@@ -130,6 +130,8 @@ box.once("init", function()
130130 -- grants for sql tests
131131 box .schema .user .grant (' test' , ' create,read,write,drop,alter' , ' space' )
132132 box .schema .user .grant (' test' , ' create' , ' sequence' )
133+
134+ box .schema .user .create (' no_grants' )
133135end )
134136
135137local function func_name ()
@@ -159,6 +161,45 @@ rawset(_G, 'push_func', push_func)
159161
160162box .space .test :truncate ()
161163
164+ local function tarantool_version_at_least (wanted_major , wanted_minor , wanted_patch )
165+ -- Borrowed from `determine_enabled_features()` from
166+ -- crud/common/utils.lua.
167+ local major_minor_patch = _TARANTOOL :split (' -' , 1 )[1 ]
168+ local major_minor_patch_parts = major_minor_patch :split (' .' , 2 )
169+
170+ local major = tonumber (major_minor_patch_parts [1 ])
171+ local minor = tonumber (major_minor_patch_parts [2 ])
172+ local patch = tonumber (major_minor_patch_parts [3 ])
173+
174+ if major < (wanted_major or 0 ) then return false end
175+ if major > (wanted_major or 0 ) then return true end
176+
177+ if minor < (wanted_minor or 0 ) then return false end
178+ if minor > (wanted_minor or 0 ) then return true end
179+
180+ if patch < (wanted_patch or 0 ) then return false end
181+ if patch > (wanted_patch or 0 ) then return true end
182+
183+ return true
184+ end
185+
186+ if tarantool_version_at_least (2 , 10 ) then
187+ local err = box .error .new (box .error .UNKNOWN )
188+ rawset (_G , ' simple_error' , err )
189+
190+ local user = box .session .user ()
191+ box .schema .func .create (' forbidden_function' , {body = ' function() end' })
192+ box .session .su (' no_grants' )
193+ local _ , access_denied_error = pcall (function () box .func .forbidden_function :call () end )
194+ box .session .su (user )
195+ rawset (_G , ' access_denied_error' , access_denied_error )
196+
197+ local e1 = box .error .new (box .error .UNKNOWN )
198+ local e2 = box .error .new (box .error .UNKNOWN )
199+ e2 :set_prev (e1 )
200+ rawset (_G , ' chained_error' , e2 )
201+ end
202+
162203-- box.schema.user.revoke('guest', 'read,write,execute', 'universe')
163204
164205-- Set listen only when every other thing is configured.
0 commit comments