From 627bca09c037e340f224e8f478c509978071b3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 3 Apr 2016 22:57:12 +0200 Subject: [PATCH] SQLCipher: test compatibility between Configuration.passphrase and PRAGMA key --- Tests/Public/Encryption/EncryptionTests.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Encryption/EncryptionTests.swift b/Tests/Public/Encryption/EncryptionTests.swift index 991fe8dc5..fbc094bd3 100644 --- a/Tests/Public/Encryption/EncryptionTests.swift +++ b/Tests/Public/Encryption/EncryptionTests.swift @@ -193,7 +193,21 @@ class EncryptionTests: GRDBTestCase { } } - func testPragmaCompatibility() { - + func testDatabaseQueueWithPragmaPassphraseToDatabaseQueueWithPassphrase() { + assertNoError { + do { + dbConfiguration.passphrase = nil + let dbQueue = try makeDatabaseQueue() + try dbQueue.execute("PRAGMA key = 'secret'") + try dbQueue.execute("CREATE TABLE data (value INTEGER)") + try dbQueue.execute("INSERT INTO data (value) VALUES (1)") + } + + do { + dbConfiguration.passphrase = "secret" + let dbQueue = try makeDatabaseQueue() + XCTAssertEqual(Int.fetchOne(dbQueue, "SELECT value FROM data")!, 1) + } + } } }