Skip to content

Commit 7354bc2

Browse files
fix???
1 parent 4564777 commit 7354bc2

File tree

1 file changed

+42
-44
lines changed

1 file changed

+42
-44
lines changed

test/suites/test_error_ext.py

+42-44
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def setUpClass(self):
3333
3434
box.schema.user.create('test', {password = 'test', if_not_exists = true})
3535
box.schema.user.grant('test', 'read,write,execute,create', 'universe')
36+
37+
box.schema.user.create('no_grants', {if_not_exists = true})
3638
""")
3739

3840
self.conn_encoding_utf8 = tarantool.Connection(
@@ -45,11 +47,16 @@ def setUpClass(self):
4547
encoding=None)
4648

4749
if self.adm.tnt_version >= pkg_resources.parse_version('2.10.0'):
50+
self.conn_encoding_utf8.eval(r"""
51+
local err = box.error.new(box.error.UNKNOWN)
52+
rawset(_G, 'simple_error', err)
53+
""")
54+
4855
# https://github.com/tarantool/tarantool/blob/125c13c81abb302708771ba04d59382d44a4a512/test/box-tap/extended_error.test.lua
4956
self.conn_encoding_utf8.eval(r"""
5057
local user = box.session.user()
5158
box.schema.func.create('forbidden_function', {body = 'function() end'})
52-
box.session.su('guest')
59+
box.session.su('no_grants')
5360
_, access_denied_error = pcall(function() box.func.forbidden_function:call() end)
5461
box.session.su(user)
5562
rawset(_G, 'access_denied_error', access_denied_error)
@@ -86,44 +93,34 @@ def setUp(self):
8693
'str_type': str,
8794
'python': tarantool.BoxError(
8895
type='ClientError',
89-
file='[string " local err = box.error.ne..."]',
96+
file='eval',
9097
line=1,
9198
message='Unknown error',
9299
errno=0,
93100
errcode=0,
94101
),
95102
'msgpack': (b'\x81\x00\x91\x86\x00\xab\x43\x6c\x69\x65\x6e\x74' +
96-
b'\x45\x72\x72\x6f\x72\x01\xd9\x3b\x5b\x73\x74\x72' +
97-
b'\x69\x6e\x67\x20\x22\x20\x20\x20\x20\x20\x20\x20' +
98-
b'\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20' +
99-
b'\x20\x20\x6c\x6f\x63\x61\x6c\x20\x65\x72\x72\x20' +
100-
b'\x3d\x20\x62\x6f\x78\x2e\x65\x72\x72\x6f\x72\x2e' +
101-
b'\x6e\x65\x2e\x2e\x2e\x22\x5d\x02\x01\x03\xad\x55' +
102-
b'\x6e\x6b\x6e\x6f\x77\x6e\x20\x65\x72\x72\x6f\x72' +
103-
b'\x04\x00\x05\x00'),
104-
'tarantool': "box.error.new(box.error.UNKNOWN)",
103+
b'\x45\x72\x72\x6f\x72\x01\xa4\x65\x76\x61\x6c\x02' +
104+
b'\x01\x03\xad\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x65' +
105+
b'\x72\x72\x6f\x72\x04\x00\x05\x00'),
106+
'tarantool': "simple_error",
105107
},
106108
'simple_error_for_encoding_none': {
107109
'conn': 'conn_encoding_none',
108110
'str_type': lambda obj: bytes(obj, encoding='utf8'),
109111
'python': tarantool.BoxError(
110112
type=b'ClientError',
111-
file=b'[string " local err = box.error.ne..."]',
113+
file=b'eval',
112114
line=1,
113115
message=b'Unknown error',
114116
errno=0,
115117
errcode=0,
116118
),
117119
'msgpack': (b'\x81\x00\x91\x86\x00\xab\x43\x6c\x69\x65\x6e\x74' +
118-
b'\x45\x72\x72\x6f\x72\x01\xda\x00\x3b\x5b\x73\x74' +
119-
b'\x72\x69\x6e\x67\x20\x22\x20\x20\x20\x20\x20\x20' +
120-
b'\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20' +
121-
b'\x20\x20\x20\x6c\x6f\x63\x61\x6c\x20\x65\x72\x72' +
122-
b'\x20\x3d\x20\x62\x6f\x78\x2e\x65\x72\x72\x6f\x72' +
123-
b'\x2e\x6e\x65\x2e\x2e\x2e\x22\x5d\x02\x01\x03\xad' +
124-
b'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x65\x72\x72\x6f' +
125-
b'\x72\x04\x00\x05\x00'),
126-
'tarantool': "box.error.new(box.error.UNKNOWN)",
120+
b'\x45\x72\x72\x6f\x72\x01\xa4\x65\x76\x61\x6c\x02' +
121+
b'\x01\x03\xad\x55\x6e\x6b\x6e\x6f\x77\x6e\x20\x65' +
122+
b'\x72\x72\x6f\x72\x04\x00\x05\x00'),
123+
'tarantool': "simple_error",
127124
},
128125
'error_with_fields_for_encoding_utf8': {
129126
'conn': 'conn_encoding_utf8',
@@ -132,7 +129,7 @@ def setUp(self):
132129
type='AccessDeniedError',
133130
file='/__w/sdk/sdk/tarantool-2.10/tarantool/src/box/func.c',
134131
line=535,
135-
message="Execute access to function 'forbidden_function' is denied for user 'guest'",
132+
message="Execute access to function 'forbidden_function' is denied for user 'no_grants'",
136133
errno=0,
137134
errcode=42,
138135
fields={
@@ -148,19 +145,20 @@ def setUp(self):
148145
b'\x2d\x32\x2e\x31\x30\x2f\x74\x61\x72\x61\x6e\x74' +
149146
b'\x6f\x6f\x6c\x2f\x73\x72\x63\x2f\x62\x6f\x78\x2f' +
150147
b'\x66\x75\x6e\x63\x2e\x63\x02\xcd\x02\x17\x03\xd9' +
151-
b'\x4a\x45\x78\x65\x63\x75\x74\x65\x20\x61\x63\x63' +
148+
b'\x4e\x45\x78\x65\x63\x75\x74\x65\x20\x61\x63\x63' +
152149
b'\x65\x73\x73\x20\x74\x6f\x20\x66\x75\x6e\x63\x74' +
153150
b'\x69\x6f\x6e\x20\x27\x66\x6f\x72\x62\x69\x64\x64' +
154151
b'\x65\x6e\x5f\x66\x75\x6e\x63\x74\x69\x6f\x6e\x27' +
155152
b'\x20\x69\x73\x20\x64\x65\x6e\x69\x65\x64\x20\x66' +
156-
b'\x6f\x72\x20\x75\x73\x65\x72\x20\x27\x67\x75\x65' +
157-
b'\x73\x74\x27\x04\x00\x05\x2a\x06\x83\xab\x6f\x62' +
158-
b'\x6a\x65\x63\x74\x5f\x74\x79\x70\x65\xa8\x66\x75' +
159-
b'\x6e\x63\x74\x69\x6f\x6e\xab\x6f\x62\x6a\x65\x63' +
160-
b'\x74\x5f\x6e\x61\x6d\x65\xb2\x66\x6f\x72\x62\x69' +
161-
b'\x64\x64\x65\x6e\x5f\x66\x75\x6e\x63\x74\x69\x6f' +
162-
b'\x6e\xab\x61\x63\x63\x65\x73\x73\x5f\x74\x79\x70' +
163-
b'\x65\xa7\x45\x78\x65\x63\x75\x74\x65'),
153+
b'\x6f\x72\x20\x75\x73\x65\x72\x20\x27\x6e\x6f\x5f' +
154+
b'\x67\x72\x61\x6e\x74\x73\x27\x04\x00\x05\x2a\x06' +
155+
b'\x83\xab\x6f\x62\x6a\x65\x63\x74\x5f\x74\x79\x70' +
156+
b'\x65\xa8\x66\x75\x6e\x63\x74\x69\x6f\x6e\xab\x6f' +
157+
b'\x62\x6a\x65\x63\x74\x5f\x6e\x61\x6d\x65\xb2\x66' +
158+
b'\x6f\x72\x62\x69\x64\x64\x65\x6e\x5f\x66\x75\x6e' +
159+
b'\x63\x74\x69\x6f\x6e\xab\x61\x63\x63\x65\x73\x73' +
160+
b'\x5f\x74\x79\x70\x65\xa7\x45\x78\x65\x63\x75\x74' +
161+
b'\x65'),
164162
'tarantool': "access_denied_error",
165163
'ignore_file_info': True,
166164
},
@@ -171,7 +169,7 @@ def setUp(self):
171169
type=b'AccessDeniedError',
172170
file=b'/__w/sdk/sdk/tarantool-2.10/tarantool/src/box/func.c',
173171
line=535,
174-
message=b"Execute access to function 'forbidden_function' is denied for user 'guest'",
172+
message=b"Execute access to function 'forbidden_function' is denied for user 'no_grants'",
175173
errno=0,
176174
errcode=42,
177175
fields={
@@ -187,19 +185,20 @@ def setUp(self):
187185
b'\x6c\x2d\x32\x2e\x31\x30\x2f\x74\x61\x72\x61\x6e' +
188186
b'\x74\x6f\x6f\x6c\x2f\x73\x72\x63\x2f\x62\x6f\x78' +
189187
b'\x2f\x66\x75\x6e\x63\x2e\x63\x02\xcd\x02\x17\x03' +
190-
b'\xda\x00\x4a\x45\x78\x65\x63\x75\x74\x65\x20\x61' +
188+
b'\xda\x00\x4e\x45\x78\x65\x63\x75\x74\x65\x20\x61' +
191189
b'\x63\x63\x65\x73\x73\x20\x74\x6f\x20\x66\x75\x6e' +
192190
b'\x63\x74\x69\x6f\x6e\x20\x27\x66\x6f\x72\x62\x69' +
193191
b'\x64\x64\x65\x6e\x5f\x66\x75\x6e\x63\x74\x69\x6f' +
194192
b'\x6e\x27\x20\x69\x73\x20\x64\x65\x6e\x69\x65\x64' +
195-
b'\x20\x66\x6f\x72\x20\x75\x73\x65\x72\x20\x27\x67' +
196-
b'\x75\x65\x73\x74\x27\x04\x00\x05\x2a\x06\x83\xab' +
197-
b'\x6f\x62\x6a\x65\x63\x74\x5f\x74\x79\x70\x65\xa8' +
198-
b'\x66\x75\x6e\x63\x74\x69\x6f\x6e\xab\x6f\x62\x6a' +
199-
b'\x65\x63\x74\x5f\x6e\x61\x6d\x65\xb2\x66\x6f\x72' +
200-
b'\x62\x69\x64\x64\x65\x6e\x5f\x66\x75\x6e\x63\x74' +
201-
b'\x69\x6f\x6e\xab\x61\x63\x63\x65\x73\x73\x5f\x74' +
202-
b'\x79\x70\x65\xa7\x45\x78\x65\x63\x75\x74\x65'),
193+
b'\x20\x66\x6f\x72\x20\x75\x73\x65\x72\x20\x27\x6e' +
194+
b'\x6f\x5f\x67\x72\x61\x6e\x74\x73\x27\x04\x00\x05' +
195+
b'\x2a\x06\x83\xab\x6f\x62\x6a\x65\x63\x74\x5f\x74' +
196+
b'\x79\x70\x65\xa8\x66\x75\x6e\x63\x74\x69\x6f\x6e' +
197+
b'\xab\x6f\x62\x6a\x65\x63\x74\x5f\x6e\x61\x6d\x65' +
198+
b'\xb2\x66\x6f\x72\x62\x69\x64\x64\x65\x6e\x5f\x66' +
199+
b'\x75\x6e\x63\x74\x69\x6f\x6e\xab\x61\x63\x63\x65' +
200+
b'\x73\x73\x5f\x74\x79\x70\x65\xa7\x45\x78\x65\x63' +
201+
b'\x75\x74\x65'),
203202
'tarantool': "access_denied_error",
204203
'ignore_file_info': True,
205204
},
@@ -286,7 +285,7 @@ def test_tarantool_decode(self):
286285
conn = getattr(self, case['conn'])
287286

288287
self.adm(f"""
289-
local err = {case['tarantool']}
288+
local err = rawget(_G, '{case['tarantool']}')
290289
box.space['test']:replace{{'{name}', err, 'payload'}}
291290
""")
292291

@@ -346,12 +345,11 @@ def test_tarantool_encode(self):
346345
[case['str_type'](name), case['python'], case['str_type']('payload')])
347346

348347
lua_eval = f"""
349-
local err = {case['tarantool']}
348+
local err = rawget(_G, '{case['tarantool']}')
350349
351350
local tuple = box.space['test']:get('{name}')
352351
assert(tuple ~= nil)
353352
354-
355353
local tuple_err = tuple[2]
356354
357355
local fields = {{'type', 'message', 'errno', 'errcode', 'fields'}}

0 commit comments

Comments
 (0)