6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_5926_test.py

79 lines
3.0 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6183
ISSUE: 6183
TITLE: Attempt to create mapping with non-ascii user name which is encoded in
SINGLE-BYTE codepage leads to '-Malformed string'
2022-01-26 21:10:46 +01:00
DESCRIPTION:
NB: different data are used for FB 3.x and 4.x because DDL in 4.x allows to store names with length up to 63 character.
See variables 'mapping_name' and 'non_ascii_user_name'.
FB 3.x restricts max_length of DB object name with value = 31 (bytes, not character!).
JIRA: CORE-5926
FBTEST: bugs.core_5926
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-10 19:50:31 +01:00
from pathlib import Path
2022-01-26 21:10:46 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory(charset='WIN1252')
2021-12-10 19:50:31 +01:00
2022-01-26 21:10:46 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RDB$MAP_USING P
RDB$MAP_DB <null>
RDB$MAP_FROM_TYPE USER
RDB$MAP_TO_TYPE 0
Records affected: 1
2021-12-10 19:50:31 +01:00
"""
2021-04-26 20:07:00 +02:00
2021-12-10 19:50:31 +01:00
test_script = temp_file('test_script.sql')
2021-04-26 20:07:00 +02:00
@pytest.mark.intl
2021-12-10 19:50:31 +01:00
@pytest.mark.version('>=3.0.4')
2022-01-26 21:10:46 +01:00
def test_1(act: Action, test_script: Path):
if act.is_version('<4'):
2021-12-10 19:50:31 +01:00
# Maximal length of user name in FB 3.x is 31 (charset unicode_fss).
#mapping_name = 'áâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
mapping_name = 'áâãäåæçèéêëìíîï1'
# mapping_name = 'áâãäåæçèéêëìíîïð'
non_ascii_user_name = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞ'
ascii_only_user_name = 'ABCDEFGHIJKLMNOPQRSTUWYXYZ12345'
else:
# Maximal length of user name in FB 4.x is 63 (charset utf8).
#
mapping_name = 'áâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿŒ'
non_ascii_user_name = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿŒœŠšŸŽžƒ'
ascii_only_user_name = 'ABCDEFGHIJKLMNOPQRSTUWYXYZ12345ABCDEFGHIJKLMNOPQRSTUWYXYZ123456'
#
plugin_for_mapping = 'Srp'
test_script.write_text(f"""
create or alter mapping "{mapping_name}" using plugin {plugin_for_mapping} from user '{non_ascii_user_name}' to user "{ascii_only_user_name}";
commit;
-- show mapping;
set count on;
set list on;
select
rdb$map_using
,rdb$map_db
,rdb$map_from_type
,rdb$map_to_type
-- ,rdb$map_plugin
-- 03.03.2021: do NOT show because it differs for FB 3.x and 4.x: ,rdb$map_from
-- 03.03.2021: do NOT show because it differs for FB 3.x and 4.x: ,rdb$map_to
from rdb$auth_mapping
where
upper(rdb$map_name) = upper('{mapping_name}')
and rdb$map_plugin = upper('{plugin_for_mapping}')
and rdb$map_from = '{non_ascii_user_name}'
and rdb$map_to containing '{ascii_only_user_name}'
;
commit;
""", encoding='cp1252')
2022-01-26 21:10:46 +01:00
act.expected_stdout = expected_stdout
act.isql(switches=['-b', '-q'], input_file=test_script, charset='WIN1252')
assert act.clean_stdout == act.clean_expected_stdout