|
| 1 | +#coding:utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +ID: issue-7723 |
| 5 | +ISSUE: https://github.com/FirebirdSQL/firebird/issues/7723 |
| 6 | +TITLE: Wrong error message on login if the user doesn't exists and WireCrypt is disabled |
| 7 | +DESCRIPTION: |
| 8 | +NOTES: |
| 9 | + [29.08.2023] pzotov |
| 10 | + 1. Cursom alias must be specified in the databases.conf with: |
| 11 | + AuthServer = Srp256 // NOT just 'Srp'! |
| 12 | + Otherwise ticket issue can not be reproduced without server restart. The reason is unknown. |
| 13 | + 2. Custom driver config objects are created here, one with WireCrypt = Disabled and second with Enabled. |
| 14 | + 3. It is supposed that no user with name 'tmp$non_existing_7723' exists. |
| 15 | +
|
| 16 | + Confirmed on 5.0.0.1169, 4.0.4.2979 |
| 17 | + Checked on 5.0.0.1177, 4.0.4.2982 -- all OK. |
| 18 | +""" |
| 19 | + |
| 20 | +import time |
| 21 | + |
| 22 | +import pytest |
| 23 | +from firebird.qa import * |
| 24 | +from firebird.driver import driver_config, connect, NetProtocol, DatabaseError |
| 25 | + |
| 26 | +# Name of alias for self-security DB in the QA_root/files/qa-databases.conf. |
| 27 | +# This file must be copied manually to each testing FB homw folder, with replacing |
| 28 | +# databases.conf there: |
| 29 | +# |
| 30 | +REQUIRED_ALIAS = 'tmp_gh_7723_alias' |
| 31 | + |
| 32 | +db = db_factory(filename = '#' + REQUIRED_ALIAS) |
| 33 | +act = python_act('db') |
| 34 | + |
| 35 | +@pytest.mark.version('>=4.0.4') |
| 36 | +def test_1(act: Action, capsys): |
| 37 | + |
| 38 | + srv_cfg = driver_config.register_server(name = 'test_srv_gh_7723', config = '') |
| 39 | + for wc in ('Disabled', 'Enabled'): |
| 40 | + db_cfg_name = f'tmp_7723__wirecrypt_{wc}' |
| 41 | + db_cfg_object = driver_config.register_database(name = db_cfg_name) |
| 42 | + db_cfg_object.server.value = srv_cfg.name |
| 43 | + db_cfg_object.protocol.value = NetProtocol.INET |
| 44 | + db_cfg_object.database.value = str(act.db.db_path) |
| 45 | + |
| 46 | + db_cfg_object.config.value = f""" |
| 47 | + WireCrypt = {wc} |
| 48 | + """ |
| 49 | + try: |
| 50 | + connect(db_cfg_name, user = 'tmp$non_existing_7723', password = '123') |
| 51 | + except DatabaseError as exc: |
| 52 | + print(f"WireCrypt = {wc}. Connect failed with:") # {str(exc)}") |
| 53 | + for x in exc.gds_codes: |
| 54 | + print('* gdscode:',x) |
| 55 | + print('* sqlcode:', exc.sqlcode) |
| 56 | + print('* sqlstate:', exc.sqlstate) |
| 57 | + print('* text:', exc.__str__()) |
| 58 | + |
| 59 | + act.expected_stdout = """ |
| 60 | + WireCrypt = Disabled. Connect failed with: |
| 61 | + * gdscode: 335544472 |
| 62 | + * sqlcode: -902 |
| 63 | + * sqlstate: 28000 |
| 64 | + * text: Your user name and password are not defined. Ask your database administrator to set up a Firebird login. |
| 65 | +
|
| 66 | + WireCrypt = Enabled. Connect failed with: |
| 67 | + * gdscode: 335544472 |
| 68 | + * sqlcode: -902 |
| 69 | + * sqlstate: 28000 |
| 70 | + * text: Your user name and password are not defined. Ask your database administrator to set up a Firebird login. |
| 71 | + """ |
| 72 | + |
| 73 | + act.stdout = capsys.readouterr().out |
| 74 | + assert act.clean_stdout == act.clean_expected_stdout |
0 commit comments