6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/bugs/core_0479_test.py

283 lines
7.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 20:45:21 +01:00
"""
ID: issue-827
ISSUE: 827
TITLE: Grants overwrite previous rdb$security_classes entries
DESCRIPTION:
Test attempts to create all kinds of objects (<K>) that can be 'target' for GRANT ON <K> statement.
Length of each object is equal to implementation maximum for 2.5.x, 3.0.x and 4.0.
Pairs of objects differ only in last character.
After all, we check that no dupicates are created in rdb$security_classes table for field rdb$security_class.
NOTE-1: for 3.0.x and 4.0 we create objects as quoted, in UTF8, - for additional checking
that we have no problem with non-ascii characters.
NOTE-2: max length in 4.0 is 63 utf8 CHARACTERS (not bytes).
JIRA: CORE-479
FBTEST: bugs.core_0479
2022-01-18 20:45:21 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
db = db_factory(charset='utf8')
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
# version: 3.0
2021-04-26 20:07:00 +02:00
test_script_1 = """
set bail on;
create or alter view v_check as
select sc.rdb$security_class, r.obj_type, min(r.obj_name) as obj_1, max(r.obj_name) as obj_2
from rdb$security_classes sc
left join
(
select r.rdb$relation_name as obj_name, r.rdb$security_class as sec_class, 'table/view' as obj_type
from rdb$relations r
2022-01-16 10:03:34 +01:00
2021-04-26 20:07:00 +02:00
union all
select p.rdb$procedure_name, p.rdb$security_class, 'stored proc'
from rdb$procedures p
union all
select p.rdb$function_name, p.rdb$security_class, 'stored func'
from rdb$functions p
union all
select p.rdb$package_name, p.rdb$security_class, 'package'
from rdb$packages p
union all
select r.rdb$role_name as obj_name, r.rdb$security_class as sec_class, 'role' as obj_type
from rdb$roles r
) r on sc.rdb$security_class = r.sec_class
group by 1,2
having count(*) > 1
;
-----------------------------------------------------------------
-- tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêŹ
-- tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêŻ
recreate table
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
(x int)
;
recreate table
"TÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
(x int)
;
-----------------------------------------------------------------
create view
"vÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
2022-01-16 10:03:34 +01:00
as select * from
2021-04-26 20:07:00 +02:00
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
;
create view
"VÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
2022-01-16 10:03:34 +01:00
as select * from
2021-04-26 20:07:00 +02:00
"TÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
;
-----------------------------------------------------------------
2022-01-16 10:03:34 +01:00
create procedure
2021-04-26 20:07:00 +02:00
"pÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
as begin
end;
2022-01-16 10:03:34 +01:00
create procedure
2021-04-26 20:07:00 +02:00
"PÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
as begin
end;
-----------------------------------------------------------------
set term ^;
create function
"fÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
returns int
as begin
return 1;
end
^
create function
"FÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
returns int
as begin
return 1;
end
^
-----------------------------------------------------------------
2022-01-16 10:03:34 +01:00
create package
2021-04-26 20:07:00 +02:00
"gÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
as begin end
^
2022-01-16 10:03:34 +01:00
create package
2021-04-26 20:07:00 +02:00
"GÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
as begin end
^
set term ;^
-----------------------------------------------------------------
create role
"rÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
;
create role
"RÁÃÀÅĂÂÄĀČĒĻŅŠŪŽ"
;
commit;
SET LIST ON;
SET COUNT ON;
2022-01-16 10:03:34 +01:00
select * from v_check;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
act_1 = isql_act('db', test_script_1)
2021-04-26 20:07:00 +02:00
expected_stdout_1 = """
Records affected: 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0,<4.0')
2021-04-28 12:42:11 +02:00
def test_1(act_1: Action):
2021-04-26 20:07:00 +02:00
act_1.expected_stdout = expected_stdout_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00
# version: 4.0
test_script_2 = """
set bail on;
create or alter view v_check as
select sc.rdb$security_class, r.obj_type, min(r.obj_name) as obj_1, max(r.obj_name) as obj_2
from rdb$security_classes sc
left join
(
select r.rdb$relation_name as obj_name, r.rdb$security_class as sec_class, 'table/view' as obj_type
from rdb$relations r
2022-01-16 10:03:34 +01:00
2021-04-26 20:07:00 +02:00
union all
select p.rdb$procedure_name, p.rdb$security_class, 'stored proc'
from rdb$procedures p
union all
select p.rdb$function_name, p.rdb$security_class, 'stored func'
from rdb$functions p
union all
select p.rdb$package_name, p.rdb$security_class, 'package'
from rdb$packages p
union all
select r.rdb$role_name as obj_name, r.rdb$security_class as sec_class, 'role' as obj_type
from rdb$roles r
) r on sc.rdb$security_class = r.sec_class
group by 1,2
having count(*) > 1
;
-----------------------------------------------------------------
recreate table
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
(x int)
;
recreate table
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
(x int)
;
-----------------------------------------------------------------
recreate view
"vÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
2022-01-16 10:03:34 +01:00
as select * from
2021-04-26 20:07:00 +02:00
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
;
recreate view
"vÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
2022-01-16 10:03:34 +01:00
as select * from
2021-04-26 20:07:00 +02:00
"tÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
;
-----------------------------------------------------------------
2022-01-16 10:03:34 +01:00
create procedure
2021-04-26 20:07:00 +02:00
"pÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
as begin
end;
2022-01-16 10:03:34 +01:00
create procedure
2021-04-26 20:07:00 +02:00
"pÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
as begin
end;
-----------------------------------------------------------------
set term ^;
create function
"fÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
returns int
as begin
return 1;
end
^
create function
"fÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
returns int
as begin
return 1;
end
^
-----------------------------------------------------------------
2022-01-16 10:03:34 +01:00
create package
2021-04-26 20:07:00 +02:00
"gÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
as begin end
^
2022-01-16 10:03:34 +01:00
create package
2021-04-26 20:07:00 +02:00
"gÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
as begin end
^
set term ;^
-----------------------------------------------------------------
create role
"rÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŹ"
;
create role
"rÁÃÀÅĂÂÄĀČĒĻŅŠŪŽĪáéíóúýàèìòùâêîôûãñõäëïöüÿçšδθλξσψωąęłźżњћџăşţŻ"
;
commit;
SET LIST ON;
SET COUNT ON;
2022-01-16 10:03:34 +01:00
select * from v_check;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
act_2 = isql_act('db', test_script_2)
2021-04-26 20:07:00 +02:00
expected_stdout_2 = """
Records affected: 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2021-04-28 12:42:11 +02:00
def test_2(act_2: Action):
2021-04-26 20:07:00 +02:00
act_2.expected_stdout = expected_stdout_2
act_2.execute()
2021-12-22 20:23:11 +01:00
assert act_2.clean_stdout == act_2.clean_expected_stdout
2021-04-26 20:07:00 +02:00