Skip to content

Commit b4bb526

Browse files
New test procedures can check cipher provider name
if_built_with_openssl and if_built_with_libtomcrypt act as replacements for do_test, only performing the test when the current sqlcipher testfixture binary was compiled with the specific crypto library.
1 parent 4ded3fc commit b4bb526

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/crypto.test

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ proc setup {file key} {
6262
db close
6363
}
6464

65+
proc get_cipher_provider {} {
66+
sqlite_orig db test.db
67+
return [execsql {
68+
PRAGMA key = 'test';
69+
PRAGMA cipher_provider;
70+
}];
71+
}
72+
73+
proc if_built_with_openssl {name cmd expected} {
74+
if {[get_cipher_provider] == "openssl"} {
75+
do_test $name $cmd $expected
76+
}
77+
}
78+
79+
proc if_built_with_libtomcrypt {name cmd expected} {
80+
if {[get_cipher_provider] == "libtomcrypt"} {
81+
do_test $name $cmd $expected
82+
}
83+
}
84+
6585
# The database is initially empty.
6686
# set an hex key create some basic data
6787
# create table and insert operations should work
@@ -1735,7 +1755,7 @@ file delete -force test.db
17351755

17361756
# verify the pragma cipher
17371757
# reports the default value
1738-
do_test verify-pragma-cipher-default {
1758+
if_built_with_openssl verify-pragma-cipher-default {
17391759
sqlite_orig db test.db
17401760
execsql {
17411761
PRAGMA key = 'test';
@@ -1747,7 +1767,7 @@ file delete -force test.db
17471767

17481768
# verify the pragma cipher
17491769
# reports a change in value
1750-
do_test verify-pragma-cipher-changed {
1770+
if_built_with_openssl verify-pragma-cipher-changed {
17511771
sqlite_orig db test.db
17521772
execsql {
17531773
PRAGMA key = 'test';
@@ -1856,4 +1876,14 @@ do_test 2.0-beta-to-2.0-migration {
18561876
db close
18571877
file delete -force test.db
18581878

1879+
if_built_with_libtomcrypt verify-default-cipher {
1880+
sqlite_orig db test.db
1881+
execsql {
1882+
PRAGMA key='test';
1883+
PRAGMA cipher;
1884+
}
1885+
} {rijndael}
1886+
db close
1887+
file delete -force test.db
1888+
18591889
finish_test

0 commit comments

Comments
 (0)