mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\functional\database\create\test_02.py: Added (temporary ?) 'credentials = False' to prevent ISQL from using '-USER ... -PASS ...'. IMO, this is bug; see https://github.com/FirebirdSQL/firebird/issues/8385
This commit is contained in:
parent
f869ab0158
commit
ef33e8f8a6
@ -5,19 +5,35 @@ ID: create-database-02
|
|||||||
TITLE: Create database: non sysdba user
|
TITLE: Create database: non sysdba user
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
FBTEST: functional.database.create.02
|
FBTEST: functional.database.create.02
|
||||||
|
NOTES:
|
||||||
|
[13.01.2025] pzotov
|
||||||
|
Added (temporary ?) 'credentials = False' to prevent ISQL from using '-USER ... -PASS ...'.
|
||||||
|
This is needed since 6.0.0.570, otherwise we get (on attempting to create DB):
|
||||||
|
Statement failed, SQLSTATE = 28000
|
||||||
|
Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
|
||||||
|
-Different logins in connect and attach packets - client library error
|
||||||
|
(IMO, this is bug; see https://github.com/FirebirdSQL/firebird/issues/8385)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import locale
|
||||||
|
from pathlib import Path
|
||||||
import pytest
|
import pytest
|
||||||
from firebird.qa import *
|
from firebird.qa import *
|
||||||
|
|
||||||
db = db_factory()
|
db = db_factory()
|
||||||
|
act = python_act('db', substitutions = [('[ \t]+', ' ')])
|
||||||
|
|
||||||
test_script = """
|
tmp_user = user_factory('db', name='tmp$boss', password='123')
|
||||||
|
test_db = temp_file('tmp4test.fdb')
|
||||||
|
|
||||||
|
@pytest.mark.version('>=3.0')
|
||||||
|
def test_1(act: Action, tmp_user: User, test_db: Path):
|
||||||
|
|
||||||
|
test_script = f"""
|
||||||
set wng off;
|
set wng off;
|
||||||
set bail on;
|
set bail on;
|
||||||
create or alter user ozzy password 'osb' revoke admin role;
|
connect '{act.db.dsn}' user {act.db.user} password '{act.db.password}';
|
||||||
commit;
|
revoke all on all from {tmp_user.name};
|
||||||
revoke all on all from ozzy;
|
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
-- ::: NB ::: do NOT miss specification of 'USER' or 'ROLE' clause in
|
-- ::: NB ::: do NOT miss specification of 'USER' or 'ROLE' clause in
|
||||||
@ -27,38 +43,29 @@ test_script = """
|
|||||||
-- -GRANT failed
|
-- -GRANT failed
|
||||||
-- -feature is not supported
|
-- -feature is not supported
|
||||||
-- -Only grants to USER or ROLE are supported for CREATE DATABASE
|
-- -Only grants to USER or ROLE are supported for CREATE DATABASE
|
||||||
grant create database to USER ozzy;
|
grant create database to USER {tmp_user.name};
|
||||||
-- ^^^^
|
-- ^^^^
|
||||||
grant drop database to USER ozzy;
|
grant drop database to USER {tmp_user.name};
|
||||||
-- ^^^^
|
-- ^^^^
|
||||||
commit;
|
commit;
|
||||||
|
create database 'localhost:{test_db}' user {tmp_user.name} password '{tmp_user.password}';
|
||||||
create database 'localhost:$(DATABASE_LOCATION)tmp.ozzy$db$987456321.tmp' user 'OZZY' password 'osb';
|
|
||||||
|
|
||||||
set list on;
|
set list on;
|
||||||
select
|
select
|
||||||
a.mon$user "Who am I ?"
|
a.mon$user "Who am I ?"
|
||||||
,iif( m.mon$database_name containing 'tmp.ozzy$db$987456321.tmp' , 'YES', 'NO! ' || m.mon$database_name) "Am I on just created DB ?"
|
,iif( m.mon$database_name containing '{test_db}' , 'YES', 'NO! ' || m.mon$database_name) "Am I on just created DB ?"
|
||||||
from mon$database m, mon$attachments a where a.mon$attachment_id = current_connection;
|
from mon$database m cross join mon$attachments a
|
||||||
|
where a.mon$attachment_id = current_connection;
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
drop database;
|
drop database;
|
||||||
connect '$(DSN)' user 'SYSDBA' password 'masterkey';
|
set echo on;
|
||||||
revoke create database from user ozzy;
|
-- Done.
|
||||||
revoke drop database from user ozzy;
|
"""
|
||||||
drop user ozzy;
|
|
||||||
commit;
|
|
||||||
"""
|
|
||||||
|
|
||||||
act = isql_act('db', test_script)
|
act.expected_stdout = f"""
|
||||||
|
Who am I ? {tmp_user.name.upper()}
|
||||||
expected_stdout = """
|
|
||||||
Who am I ? OZZY
|
|
||||||
Am I on just created DB ? YES
|
Am I on just created DB ? YES
|
||||||
"""
|
-- Done.
|
||||||
|
"""
|
||||||
@pytest.mark.version('>=3.0')
|
act.isql(switches=['-q'], input=test_script, connect_db=False, combine_output = True, credentials = False, io_enc = locale.getpreferredencoding())
|
||||||
def test_1(act: Action):
|
|
||||||
act.expected_stdout = expected_stdout
|
|
||||||
act.execute()
|
|
||||||
assert act.clean_stdout == act.clean_expected_stdout
|
assert act.clean_stdout == act.clean_expected_stdout
|
||||||
|
Loading…
Reference in New Issue
Block a user