1 @message |
Encryption problem
assert
GEN_7FFFFFFF FOUND.
GEN_BA0BAB FOUND.
GEN_BADF00D FOUND.
GEN_C0FFEE FOUND.
GEN_CACA0 FOUND.
GEN_DEC0DE FOUND.
GEN_DECADE FOUND.
+ unsuccessful metadata update
+ -ALTER DATABASE failed
+ -Missing correct crypt key
+ -Plugin fbSampleDbCrypt:
+ -Crypt key Red not set
+ Nothing to be tested: DB not encrypted.
- GEN_7FFFFFFF NOT FOUND.
- GEN_BA0BAB NOT FOUND.
- GEN_BADF00D NOT FOUND.
- GEN_C0FFEE NOT FOUND.
- GEN_CACA0 NOT FOUND.
- GEN_DEC0DE NOT FOUND.
- GEN_DECADE NOT FOUND.
LOG DETAILS:
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 act = <firebird.qa.plugin.Action object at [hex]>
2024-04-21 05:23:45.857 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 @pytest.mark.encryption
2024-04-21 05:23:45.857 @pytest.mark.version('>=3.0.5')
2024-04-21 05:23:45.857 def test_1(act: Action, capsys):
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 encryption_started = False
2024-04-21 05:23:45.857 encryption_finished = False
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 with act.db.connect() as con:
2024-04-21 05:23:45.857 cur=con.cursor()
2024-04-21 05:23:45.857 get_current_seq_values='''
2024-04-21 05:23:45.857 execute block returns( gen_name rdb$generator_name, gen_curr bigint) as
2024-04-21 05:23:45.857 declare g_incr smallint;
2024-04-21 05:23:45.857 begin
2024-04-21 05:23:45.857 for
2024-04-21 05:23:45.857 select trim(rdb$generator_name)
2024-04-21 05:23:45.857 from rdb$generators
2024-04-21 05:23:45.857 where rdb$system_flag is distinct from 1
2024-04-21 05:23:45.857 order by rdb$generator_id
2024-04-21 05:23:45.857 into gen_name
2024-04-21 05:23:45.857 do begin
2024-04-21 05:23:45.857 execute statement 'select gen_id(' || gen_name || ', 0) from rdb$database' into gen_curr;
2024-04-21 05:23:45.857 suspend;
2024-04-21 05:23:45.857 end
2024-04-21 05:23:45.857 end
2024-04-21 05:23:45.857 '''
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 # Obtain current values of user generators:
2024-04-21 05:23:45.857 cur.execute(get_current_seq_values)
2024-04-21 05:23:45.857 current_seq_name_val_dict={}
2024-04-21 05:23:45.857 for r in cur:
2024-04-21 05:23:45.857 current_seq_name_val_dict[ r[0] ] = r[1]
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 # Obtain page size and number of generators page:
2024-04-21 05:23:45.857 cur.execute('select m.mon$page_size,min(rdb$page_number) from mon$database m cross join rdb$pages p where p.rdb$page_type = 9 group by 1')
2024-04-21 05:23:45.857 pg_size, gen_page_number = -1,-1
2024-04-21 05:23:45.857 for r in cur:
2024-04-21 05:23:45.857 pg_size=r[0]
2024-04-21 05:23:45.857 gen_page_number=r[1]
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 # Read gen page, convert it to hex and check whether generator values can be found there or no:
2024-04-21 05:23:45.857 # Expected result: YES for all values because DB not encrypted now.
2024-04-21 05:23:45.857 # ~~~~~~~~~~~~~~~
2024-04-21 05:23:45.857 show_gen_page_readable_outcome(act.db.db_path, gen_page_number, pg_size, current_seq_name_val_dict)
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 #---------------------------------------
2024-04-21 05:23:45.857 t1=py_dt.datetime.now()
2024-04-21 05:23:45.857 d1 = t1-t1
2024-04-21 05:23:45.857 sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}" key "{ENCRYPTION_KEY}"'
2024-04-21 05:23:45.857 try:
2024-04-21 05:23:45.857 con.execute_immediate(sttm)
2024-04-21 05:23:45.857 con.commit()
2024-04-21 05:23:45.857 encryption_started = True
2024-04-21 05:23:45.857 except DatabaseError as e:
2024-04-21 05:23:45.857 # -ALTER DATABASE failed
2024-04-21 05:23:45.857 # -Crypt plugin fbSampleDbCrypt failed to load
2024-04-21 05:23:45.857 # ==> no sense to do anything else, encryption_started remains False.
2024-04-21 05:23:45.857 print( e.__str__() )
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 while encryption_started:
2024-04-21 05:23:45.857 t2=py_dt.datetime.now()
2024-04-21 05:23:45.857 d1=t2-t1
2024-04-21 05:23:45.857 if d1.seconds*1000 + d1.microseconds//1000 > MAX_WAITING_ENCR_FINISH:
2024-04-21 05:23:45.857 print(f'TIMEOUT EXPIRATION: encryption took {d1.seconds*1000 + d1.microseconds//1000} ms which exceeds limit = {MAX_WAITING_ENCR_FINISH} ms.')
2024-04-21 05:23:45.857 break
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 # Possible output:
2024-04-21 05:23:45.857 # Database not encrypted
2024-04-21 05:23:45.857 # Database encrypted, crypt thread not complete
2024-04-21 05:23:45.857 act.isql(switches=['-q'], input = 'show database;', combine_output = True)
2024-04-21 05:23:45.857 if 'Database encrypted' in act.stdout:
2024-04-21 05:23:45.857 if 'not complete' in act.stdout:
2024-04-21 05:23:45.857 pass
2024-04-21 05:23:45.857 else:
2024-04-21 05:23:45.857 encryption_finished = True
2024-04-21 05:23:45.857 break
2024-04-21 05:23:45.857 act.reset()
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 if encryption_finished:
2024-04-21 05:23:45.857 # Read again gen page, convert it to hex and check whether generator values can be found there or no.
2024-04-21 05:23:45.857 # Expected result: NOT for all values because DB was encrypted.
2024-04-21 05:23:45.857 # ~~~~~~~~~~~~~~~~
2024-04-21 05:23:45.857 show_gen_page_readable_outcome(act.db.db_path, gen_page_number, pg_size, current_seq_name_val_dict)
2024-04-21 05:23:45.857 else:
2024-04-21 05:23:45.857 print('Nothing to be tested: DB not encrypted.')
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 act.expected_stdout = expected_stdout
2024-04-21 05:23:45.857 act.stdout = capsys.readouterr().out
2024-04-21 05:23:45.857 > assert act.clean_stdout == act.clean_expected_stdout
2024-04-21 05:23:45.857 E assert
2024-04-21 05:23:45.857 E GEN_7FFFFFFF FOUND.
2024-04-21 05:23:45.857 E GEN_BA0BAB FOUND.
2024-04-21 05:23:45.857 E GEN_BADF00D FOUND.
2024-04-21 05:23:45.857 E GEN_C0FFEE FOUND.
2024-04-21 05:23:45.857 E GEN_CACA0 FOUND.
2024-04-21 05:23:45.857 E GEN_DEC0DE FOUND.
2024-04-21 05:23:45.857 E GEN_DECADE FOUND.
2024-04-21 05:23:45.857 E + unsuccessful metadata update
2024-04-21 05:23:45.857 E + -ALTER DATABASE failed
2024-04-21 05:23:45.857 E + -Missing correct crypt key
2024-04-21 05:23:45.857 E + -Plugin fbSampleDbCrypt:
2024-04-21 05:23:45.857 E + -Crypt key Red not set
2024-04-21 05:23:45.857 E + Nothing to be tested: DB not encrypted.
2024-04-21 05:23:45.857 E - GEN_7FFFFFFF NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_BA0BAB NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_BADF00D NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_C0FFEE NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_CACA0 NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_DEC0DE NOT FOUND.
2024-04-21 05:23:45.857 E - GEN_DECADE NOT FOUND.
2024-04-21 05:23:45.857
2024-04-21 05:23:45.857 tests\bugs\core_6163_test.py:217: AssertionError
2024-04-21 05:23:45.857 ---------------------------- Captured stdout setup ----------------------------
2024-04-21 05:23:45.857 Cached db: db-12.0-None-None-NONE.fdb [page_size=None, sql_dialect=None, charset='NONE'
|
2 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.encryption
@pytest.mark.version('>=3.0.5')
def test_1(act: Action, capsys):
encryption_started = False
encryption_finished = False
with act.db.connect() as con:
cur=con.cursor()
get_current_seq_values='''
execute block returns( gen_name rdb$generator_name, gen_curr bigint) as
declare g_incr smallint;
begin
for
select trim(rdb$generator_name)
from rdb$generators
where rdb$system_flag is distinct from 1
order by rdb$generator_id
into gen_name
do begin
execute statement 'select gen_id(' || gen_name || ', 0) from rdb$database' into gen_curr;
suspend;
end
end
'''
# Obtain current values of user generators:
cur.execute(get_current_seq_values)
current_seq_name_val_dict={}
for r in cur:
current_seq_name_val_dict[ r[0] ] = r[1]
# Obtain page size and number of generators page:
cur.execute('select m.mon$page_size,min(rdb$page_number) from mon$database m cross join rdb$pages p where p.rdb$page_type = 9 group by 1')
pg_size, gen_page_number = -1,-1
for r in cur:
pg_size=r[0]
gen_page_number=r[1]
# Read gen page, convert it to hex and check whether generator values can be found there or no:
# Expected result: YES for all values because DB not encrypted now.
# ~~~~~~~~~~~~~~~
show_gen_page_readable_outcome(act.db.db_path, gen_page_number, pg_size, current_seq_name_val_dict)
#---------------------------------------
t1=py_dt.datetime.now()
d1 = t1-t1
sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}" key "{ENCRYPTION_KEY}"'
try:
con.execute_immediate(sttm)
con.commit()
encryption_started = True
except DatabaseError as e:
# -ALTER DATABASE failed
# -Crypt plugin fbSampleDbCrypt failed to load
# ==> no sense to do anything else, encryption_started remains False.
print( e.__str__() )
while encryption_started:
t2=py_dt.datetime.now()
d1=t2-t1
if d1.seconds*1000 + d1.microseconds//1000 > MAX_WAITING_ENCR_FINISH:
print(f'TIMEOUT EXPIRATION: encryption took {d1.seconds*1000 + d1.microseconds//1000} ms which exceeds limit = {MAX_WAITING_ENCR_FINISH} ms.')
break
# Possible output:
# Database not encrypted
# Database encrypted, crypt thread not complete
act.isql(switches=['-q'], input = 'show database;', combine_output = True)
if 'Database encrypted' in act.stdout:
if 'not complete' in act.stdout:
pass
else:
encryption_finished = True
break
act.reset()
if encryption_finished:
# Read again gen page, convert it to hex and check whether generator values can be found there or no.
# Expected result: NOT for all values because DB was encrypted.
# ~~~~~~~~~~~~~~~~
show_gen_page_readable_outcome(act.db.db_path, gen_page_number, pg_size, current_seq_name_val_dict)
else:
print('Nothing to be tested: DB not encrypted.')
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
> assert act.clean_stdout == act.clean_expected_stdout
E assert
E GEN_7FFFFFFF FOUND.
E GEN_BA0BAB FOUND.
E GEN_BADF00D FOUND.
E GEN_C0FFEE FOUND.
E GEN_CACA0 FOUND.
E GEN_DEC0DE FOUND.
E GEN_DECADE FOUND.
E + unsuccessful metadata update
E + -ALTER DATABASE failed
E + -Missing correct crypt key
E + -Plugin fbSampleDbCrypt:
E + -Crypt key Red not set
E + Nothing to be tested: DB not encrypted.
E - GEN_7FFFFFFF NOT FOUND.
E - GEN_BA0BAB NOT FOUND.
E - GEN_BADF00D NOT FOUND.
E - GEN_C0FFEE NOT FOUND.
E - GEN_CACA0 NOT FOUND.
E - GEN_DEC0DE NOT FOUND.
E - GEN_DECADE NOT FOUND.
tests\bugs\core_6163_test.py:217: AssertionError
|