Skip to content

Commit c05d02e

Browse files
author
Christopher J. Brody
committed
test JSON1/FTS5; reproduce storesafe#43
1 parent da48449 commit c05d02e

File tree

3 files changed

+130
-10
lines changed

3 files changed

+130
-10
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
130130
- Windows version may crash in certain cases when invalid (bogus) function parameters are given, for example: `db.readTransaction('bogus');`
131131
- Uses libTomCrypt for encryption which *may* be inferior to OpenSSL for encryption and apparently runs much more slowly
132132
- WAL/MMAP *disabled* for Windows Phone 8.1
133-
- JSON1 not working for Windows
134133
- **NOTE:** libTomCrypt may have inferior entropy (randomness) for encryption. It is desired to replace libTomCrypt with a recent build of the OpenSSL crypto library.
135134
- Android version:
136135
- ARM (v5/v6/v7/v7a) and x86 CPUs
@@ -139,7 +138,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
139138
- NOTE: 64-bit CPUs such as `x64_64`, ARM-64, and MIPS are currently not supported by the SQLCipher for Android build (support for these CPUs is for future consideration).
140139
- ICU case-insensitive matching and other Unicode string manipulations is no longer supported for Android.
141140
- FTS3, FTS4, FTS5, and R-Tree support is tested working OK for all target platforms in this version branch Android/iOS/Windows
142-
- JSON1 support for Android/iOS (not working for Windows)
141+
- JSON1 support for Android/iOS/macOS/Windows
143142
- iOS version:
144143
- iOS versions supported: 8.x/9.x/10.x see [deviations section](#deviations) below for differences in case of WKWebView)
145144
- REGEXP is no longer supported for iOS.
@@ -154,7 +153,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
154153

155154
- macOS ("osx" platform) is now supported
156155
- The [brodybits / Cordova-sqlite-bootstrap-test](https://github.com/brodybits/Cordova-sqlite-bootstrap-test) project is a CC0 (public domain) starting point to reproduce issues with this plugin and may be used as a quick way to start developing a new app.
157-
- SQLCipher version `3.4.0`/`3.5.4` for Android/iOS/macOS/Windows with FTS5 (all platforms) and JSON1 (Android/iOS)
156+
- SQLCipher version `3.4.0`/`3.5.4` for Android/iOS/macOS/Windows with FTS5 and JSON1
158157
- Windows 10 UWP is now supported by this version - along with Windows 8.1 and Windows Phone 8.1
159158
- Self-test functions to verify proper installation and operation of this plugin
160159
- More explicit `openDatabase` and `deleteDatabase` `iosDatabaseLocation` option
@@ -407,6 +406,7 @@ See **Security of sensitive data** in the [Security](#security) section above.
407406

408407
- iOS/macOS version does not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing
409408
- As described below, auto-vacuum is NOT enabled by default.
409+
- Cannot read encrypted database with CORRECT password directly after attempt to open with INCORRECT password ref: [litehelpers/Cordova-sqlcipher-adapter#43](https://github.com/litehelpers/Cordova-sqlcipher-adapter/issues/43)
410410
- INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) does not report proper rowsAffected on Android
411411
- If a sql statement fails for which there is no error handler or the error handler does not return `false` to signal transaction recovery, the plugin fires the remaining sql callbacks before aborting the transaction.
412412
- In case of an error, the error `code` member is bogus on Android and Windows (fixed for Android in [litehelpers / Cordova-sqlite-enterprise-free](https://github.com/litehelpers/Cordova-sqlite-enterprise-free), available under a different licensing scheme *without SQLCipher*).
@@ -422,7 +422,6 @@ See **Security of sensitive data** in the [Security](#security) section above.
422422
- When a database is opened and deleted without closing, the iOS/macOS version is known to leak resources.
423423
- It is NOT possible to open multiple databases with the same name but in different locations (iOS/macOS).
424424
- Incorrect or missing rowsAffected in results for INSERT/UPDATE/DELETE SQL statements with extra semicolon(s) in the beginning for Android ~~in case the `androidDatabaseImplementation: 2` (built-in android.database implementation) option is used~~.
425-
- JSON1 feature is not working for Windows
426425
- It is NOT possible to open multiple databases with the same name but in different locations (iOS version).
427426
- Problems reported with PhoneGap Build in the past:
428427
- PhoneGap Build Hydration.

spec/www/spec/cipher.js

+124
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,130 @@ describe('encryption test(s)', function() {
183183
});
184184
});
185185

186+
it(suiteName + ' Attempt to open encrypted DB with INCORRECT password THEN OPEN & READ with CORRECT PASSWORD [PLUGIN BROKEN: MUST CLOSE THEN TRY AGAIN]', function (done) {
187+
if (isWindows) pending('SKIP for Windows: CALLBACK NOT RECEIVED');
188+
189+
var dbName = 'Encrypted-DB-attempt-incorrect-password-then-correct-password.db';
190+
var test_data = 'test-data';
191+
192+
window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db1) {
193+
expect(db1).toBeDefined();
194+
// CREATE TABLE to put some contents into the DB:
195+
db1.transaction(function(tx) {
196+
tx.executeSql('DROP TABLE IF EXISTS tt');
197+
tx.executeSql('CREATE TABLE IF NOT EXISTS tt (test_data)');
198+
tx.executeSql('INSERT INTO tt (test_data) VALUES (?)', [test_data]);
199+
}, function(error) {
200+
// NOT EXPECTED:
201+
expect(false).toBe(true);
202+
expect(error.message).toBe('--');
203+
done();
204+
}, function() {
205+
db1.close(function () {
206+
207+
window.sqlitePlugin.openDatabase({name: dbName, key: 'another-password', location: 'default'}, function (db2) {
208+
// NOT EXPECTED:
209+
expect(false).toBe(true);
210+
done();
211+
}, function (error) {
212+
// EXPECTED RESULT:
213+
expect(error).toBeDefined();
214+
// FUTURE TBD CHECK code/message
215+
216+
window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db3) {
217+
// EXPECTED RESULT:
218+
expect(db3).toBeDefined();
219+
//* ** ALT 1:
220+
db3.transaction(function(tx) {
221+
tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
222+
expect('PLUGIN FIXED PLEASE UPDATE THIS TEST').toBe('--');
223+
expect(rs).toBeDefined();
224+
expect(rs.rows).toBeDefined();
225+
expect(rs.rows.length).toBe(1);
226+
expect(rs.rows.item(0).test_data).toBe(test_data);
227+
done();
228+
}, function (ignored, error) {
229+
// NOT EXPECTED:
230+
expect(false).toBe(true);
231+
expect(error.message).toBe('--');
232+
done();
233+
});
234+
235+
}, function (error) {
236+
// TEST GETS HERE [Android/iOS/macOS]:
237+
//expect(false).toBe(true);
238+
//expect(error.message).toBe('--');
239+
expect(error).toBeDefined();
240+
db3.close(function() {
241+
expect('PLUGIN BEHAVIOR CHANGED PLEASE UPDATE THIS TEST AND CHECK STORED DATA HERE').toBe('--');
242+
done();
243+
}, function(error) {
244+
// TBD ???:
245+
//expect(error).toBeDefined();
246+
expect(error).not.toBeDefined();
247+
// TRY AGAIN:
248+
window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db4) {
249+
// EXPECTED RESULT:
250+
expect(db4).toBeDefined();
251+
//* ** ALT 1:
252+
db4.transaction(function(tx) {
253+
tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
254+
expect(rs).toBeDefined();
255+
expect(rs.rows).toBeDefined();
256+
expect(rs.rows.length).toBe(1);
257+
expect(rs.rows.item(0).test_data).toBe(test_data);
258+
done();
259+
}, function (ignored, error) {
260+
// NOT EXPECTED:
261+
expect(false).toBe(true);
262+
expect(error.message).toBe('--');
263+
done();
264+
});
265+
}, function (error) {
266+
// NOT EXPECTED:
267+
expect(false).toBe(true);
268+
expect(error.message).toBe('--');
269+
done();
270+
});
271+
});
272+
});
273+
});
274+
// */
275+
/* ** FUTURE TBD ALT 2 [NO SQL CALLBACK RECEIVED]:
276+
expect('check1').toBe('--'); // TEST ALT 2 GETS HERE
277+
db3.executeSql('SELECT * FROM tt', null, function(rs) {
278+
// NOT TRIGGERED Android/iOS:
279+
expect(rs).toBeDefined();
280+
// FUTURE TBD CHECK rs
281+
done();
282+
}, function (error) {
283+
// NOT TRIGGERED Android/iOS:
284+
// NOT EXPECTED:
285+
expect(false).toBe(true);
286+
expect(error.message).toBe('--');
287+
done();
288+
});
289+
expect('check2').toBe('--'); // TEST ALT 2 GETS HERE
290+
// */
291+
});
292+
293+
});
294+
295+
}, function (error) {
296+
// NOT EXPECTED:
297+
expect(false).toBe(true);
298+
expect(error.message).toBe('--');
299+
done();
300+
});
301+
});
302+
}, function (error) {
303+
// NOT EXPECTED:
304+
expect(false).toBe(true);
305+
expect(error.message).toBe('--');
306+
done();
307+
});
308+
});
309+
186310
test_it(suiteName + 'Attempt to open and read unencrypted DB with password key', function () {
187311

188312
var dbName = 'Open-and-read-unencrypted-DB-with-password.db';

spec/www/spec/db-tx-sql-features-test.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ var mytests = function() {
168168

169169
// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
170170
it(suiteName + 'Basic JSON1 json test', function(done) {
171-
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
172-
pending('SKIP: NOT IMPLEMENTED for this version');
171+
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
173172

174173
var db = openDatabase('basic-json1-json-test.db', '1.0', 'Test', DEFAULT_SIZE);
175174

@@ -198,8 +197,7 @@ var mytests = function() {
198197

199198
// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
200199
it(suiteName + 'JSON1 json_object test', function(done) {
201-
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
202-
pending('SKIP: NOT IMPLEMENTED for this version');
200+
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
203201

204202
var db = openDatabase('json1-json-object-test.db', '1.0', 'Test', DEFAULT_SIZE);
205203

@@ -229,8 +227,7 @@ var mytests = function() {
229227

230228
// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
231229
it(suiteName + 'create virtual table using FTS5', function(done) {
232-
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
233-
pending('SKIP: NOT IMPLEMENTED for this version');
230+
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
234231

235232
var db = openDatabase('virtual-table-using-fts5.db', '1.0', 'Test', DEFAULT_SIZE);
236233

0 commit comments

Comments
 (0)