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_5793_test.py

59 lines
1.6 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-6056
ISSUE: 6056
TITLE: Error returned from DbCryptPlugin::setKey() is not shown
DESCRIPTION:
Test issues: 'alter database encrypt ...' with NON existing key and check exception that will raise.
2022-01-26 21:10:46 +01:00
JIRA: CORE-5793
FBTEST: bugs.core_5793
NOTES:
[12.06.2022] pzotov
Checked on 4.0.1.2692, 3.0.8.33535 - both on Linux and Windows.
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-26 21:10:46 +01:00
from firebird.qa import *
from firebird.driver import DatabaseError
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
act = python_act('db')
2021-04-26 20:07:00 +02:00
ENCRYPTION_PLUGIN = 'fbSampleDbCrypt'
ENCRYPTION_HOLDER = 'fbSampleKeyHolder'
ENCRYPTION_BADKEY = 'NoSuchKey'
fb3x_checked_stdout = f"""
unsuccessful metadata update
-ALTER DATABASE failed
-Missing correct crypt key
-Plugin {ENCRYPTION_HOLDER}:
-Crypt key {ENCRYPTION_BADKEY} not set
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
fb4x_checked_stdout = f"""
unsuccessful metadata update
-ALTER DATABASE failed
-Missing database encryption key for your attachment
-Plugin {ENCRYPTION_HOLDER}:
-Crypt key {ENCRYPTION_BADKEY} not set
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.encryption
@pytest.mark.version('>=3.0.4')
def test_1(act: Action, capsys):
with act.db.connect() as con:
sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}" key "{ENCRYPTION_BADKEY}"'
try:
con.execute_immediate(sttm)
except DatabaseError as e:
print( e.__str__() )
act.expected_stdout = fb3x_checked_stdout if act.is_version('<4') else fb4x_checked_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout