From a2a54885dfc68ddec3a9f74977db757d62d0b8b9 Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Tue, 27 Dec 2011 12:14:17 -0500 Subject: [PATCH] add test for behavior with multiple key operations --- test/crypto.test | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/crypto.test b/test/crypto.test index 35466c8d..2690241a 100644 --- a/test/crypto.test +++ b/test/crypto.test @@ -896,5 +896,33 @@ do_test rekey-then-key-as-first-ops { } {100} db close +file delete -force test.db + +setup test.db "'testkey'" +do_test multiple-key-calls-safe-1 { + sqlite_orig db test.db + execsql { + PRAGMA key = 'testkey'; + PRAGMA cache_size = 0; + SELECT name FROM sqlite_master WHERE type='table'; + } +} {t1} + +do_test multiple-key-calls-safe-2 { + catchsql { + PRAGMA key = 'wrong key'; + SELECT name FROM sqlite_master WHERE type='table'; + } +} {1 {file is encrypted or is not a database}} + +do_test multiple-key-calls-safe-3 { + execsql { + PRAGMA key = 'testkey'; + SELECT name FROM sqlite_master WHERE type='table'; + } +} {t1} + +db close +file delete -force test.db finish_test