File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,7 @@ extension Connection {
5555 // the key provided is incorrect. To test that the database can be successfully opened with the
5656 // provided key, it is necessary to perform some operation on the database (i.e. read from it).
5757 private func cipher_key_check( ) throws {
58- try execute (
59- " CREATE TABLE \" __SQLCipher.swift__ \" ( \" cipher key check \" ); \n " +
60- " DROP TABLE \" __SQLCipher.swift__ \" ; "
61- )
58+ try scalar ( " SELECT count(*) FROM sqlite_master; " )
6259 }
6360}
6461#endif
Original file line number Diff line number Diff line change @@ -59,11 +59,12 @@ class CipherTests: XCTestCase {
5959
6060 try ! connA. key ( " hello " )
6161
62- let connB = try ! Connection ( path)
62+ let connB = try ! Connection ( path, readonly : true )
6363
6464 var rc : Int32 ?
6565 do {
6666 try connB. key ( " world " )
67+ XCTFail ( " expected exception " )
6768 } catch Result . error( _, let code, _) {
6869 rc = code
6970 } catch {
@@ -78,6 +79,10 @@ class CipherTests: XCTestCase {
7879 // sqlite> CREATE TABLE foo (bar TEXT);
7980 // sqlite> INSERT INTO foo (bar) VALUES ('world');
8081 let encryptedFile = fixture ( " encrypted " , withExtension: " sqlite " )
82+
83+ try ! FileManager . default. setAttributes ( [ FileAttributeKey . immutable : 1 ] , ofItemAtPath: encryptedFile)
84+ XCTAssertFalse ( FileManager . default. isWritableFile ( atPath: encryptedFile) )
85+
8186 let conn = try ! Connection ( encryptedFile)
8287 try ! conn. key ( " sqlcipher-test " )
8388 XCTAssertEqual ( 1 , try ! conn. scalar ( " SELECT count(*) FROM foo " ) as? Int64 )
You can’t perform that action at this time.
0 commit comments