6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_5747_test.py

111 lines
2.9 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6010
ISSUE: 6010
TITLE: User can grant usage privilege by himself
DESCRIPTION:
beside generator we also have to check the same issue about grant usage on exception.
JIRA: CORE-5747
FBTEST: bugs.core_5747
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
substitutions = [('no G privilege with grant option on object .*',
'no USAGE privilege with grant option on object'),
('GEN_FOR_DBA_ONLY', ''), ('EXC_FOR_DBA_ONLY', '')]
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
commit;
connect '$(DSN)' user sysdba password 'masterkey';
create or alter user tmp$c5747 password '123';
commit;
recreate sequence gen_for_dba_only;
recreate exception exc_for_dba_only 'Your names is: @1 - and you should not be able to use this exception!';
commit;
connect '$(DSN)' user tmp$c5747 password '123';
grant usage on generator gen_for_dba_only to tmp$c5747;
grant usage on exception exc_for_dba_only to tmp$c5747;
commit;
connect '$(DSN)' user tmp$c5747 password '123';
set list on;
2022-01-26 21:10:46 +01:00
2021-04-26 20:07:00 +02:00
select gen_id(gen_for_dba_only,1) as next_secret_system_sequence from rdb$database;
set term ^;
execute block as
begin
exception exc_for_dba_only using (current_user);
end
^
set term ;^
commit;
connect '$(DSN)' user sysdba password 'masterkey';
drop user tmp$c5747;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
act = isql_act('db', test_script, substitutions=substitutions)
# version: 3.0
2021-04-26 20:07:00 +02:00
expected_stderr_1 = """
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-GRANT failed
-no USAGE privilege with grant option on object
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-GRANT failed
-no USAGE privilege with grant option on object
Statement failed, SQLSTATE = 28000
no permission for USAGE access to GENERATOR
Statement failed, SQLSTATE = 28000
no permission for USAGE access to EXCEPTION
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.4,<4.0')
2022-01-26 21:10:46 +01:00
def test_1(act: Action):
act.expected_stderr = expected_stderr_1
act.execute()
assert act.clean_stderr == act.clean_expected_stderr
2021-04-26 20:07:00 +02:00
# version: 4.0
expected_stderr_2 = """
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-GRANT failed
-no USAGE privilege with grant option on object
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-GRANT failed
-no USAGE privilege with grant option on object
Statement failed, SQLSTATE = 28000
no permission for USAGE access to GENERATOR
-Effective user is TMP$C5747
Statement failed, SQLSTATE = 28000
no permission for USAGE access to EXCEPTION
-Effective user is TMP$C5747
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-26 21:10:46 +01:00
def test_2(act: Action):
act.expected_stderr = expected_stderr_2
act.execute()
assert act.clean_stderr == act.clean_expected_stderr