Skip to content

Commit

Permalink
test JSON1/FTS5; reproduce storesafe#43
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Oct 11, 2016
1 parent da48449 commit c05d02e
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 10 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
- Windows version may crash in certain cases when invalid (bogus) function parameters are given, for example: `db.readTransaction('bogus');`
- Uses libTomCrypt for encryption which *may* be inferior to OpenSSL for encryption and apparently runs much more slowly
- WAL/MMAP *disabled* for Windows Phone 8.1
- JSON1 not working for Windows
- **NOTE:** libTomCrypt may have inferior entropy (randomness) for encryption. It is desired to replace libTomCrypt with a recent build of the OpenSSL crypto library.
- Android version:
- ARM (v5/v6/v7/v7a) and x86 CPUs
Expand All @@ -139,7 +138,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.
- 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).
- ICU case-insensitive matching and other Unicode string manipulations is no longer supported for Android.
- FTS3, FTS4, FTS5, and R-Tree support is tested working OK for all target platforms in this version branch Android/iOS/Windows
- JSON1 support for Android/iOS (not working for Windows)
- JSON1 support for Android/iOS/macOS/Windows
- iOS version:
- iOS versions supported: 8.x/9.x/10.x see [deviations section](#deviations) below for differences in case of WKWebView)
- REGEXP is no longer supported for iOS.
Expand All @@ -154,7 +153,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation.

- macOS ("osx" platform) is now supported
- 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.
- SQLCipher version `3.4.0`/`3.5.4` for Android/iOS/macOS/Windows with FTS5 (all platforms) and JSON1 (Android/iOS)
- SQLCipher version `3.4.0`/`3.5.4` for Android/iOS/macOS/Windows with FTS5 and JSON1
- Windows 10 UWP is now supported by this version - along with Windows 8.1 and Windows Phone 8.1
- Self-test functions to verify proper installation and operation of this plugin
- More explicit `openDatabase` and `deleteDatabase` `iosDatabaseLocation` option
Expand Down Expand Up @@ -407,6 +406,7 @@ See **Security of sensitive data** in the [Security](#security) section above.

- 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
- As described below, auto-vacuum is NOT enabled by default.
- 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)
- INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) does not report proper rowsAffected on Android
- 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.
- 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*).
Expand All @@ -422,7 +422,6 @@ See **Security of sensitive data** in the [Security](#security) section above.
- When a database is opened and deleted without closing, the iOS/macOS version is known to leak resources.
- It is NOT possible to open multiple databases with the same name but in different locations (iOS/macOS).
- 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~~.
- JSON1 feature is not working for Windows
- It is NOT possible to open multiple databases with the same name but in different locations (iOS version).
- Problems reported with PhoneGap Build in the past:
- PhoneGap Build Hydration.
Expand Down
124 changes: 124 additions & 0 deletions spec/www/spec/cipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,130 @@ describe('encryption test(s)', function() {
});
});

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) {
if (isWindows) pending('SKIP for Windows: CALLBACK NOT RECEIVED');

var dbName = 'Encrypted-DB-attempt-incorrect-password-then-correct-password.db';
var test_data = 'test-data';

window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db1) {
expect(db1).toBeDefined();
// CREATE TABLE to put some contents into the DB:
db1.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS tt');
tx.executeSql('CREATE TABLE IF NOT EXISTS tt (test_data)');
tx.executeSql('INSERT INTO tt (test_data) VALUES (?)', [test_data]);
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
}, function() {
db1.close(function () {

window.sqlitePlugin.openDatabase({name: dbName, key: 'another-password', location: 'default'}, function (db2) {
// NOT EXPECTED:
expect(false).toBe(true);
done();
}, function (error) {
// EXPECTED RESULT:
expect(error).toBeDefined();
// FUTURE TBD CHECK code/message

window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db3) {
// EXPECTED RESULT:
expect(db3).toBeDefined();
//* ** ALT 1:
db3.transaction(function(tx) {
tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
expect('PLUGIN FIXED PLEASE UPDATE THIS TEST').toBe('--');
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).test_data).toBe(test_data);
done();
}, function (ignored, error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});

}, function (error) {
// TEST GETS HERE [Android/iOS/macOS]:
//expect(false).toBe(true);
//expect(error.message).toBe('--');
expect(error).toBeDefined();
db3.close(function() {
expect('PLUGIN BEHAVIOR CHANGED PLEASE UPDATE THIS TEST AND CHECK STORED DATA HERE').toBe('--');
done();
}, function(error) {
// TBD ???:
//expect(error).toBeDefined();
expect(error).not.toBeDefined();
// TRY AGAIN:
window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db4) {
// EXPECTED RESULT:
expect(db4).toBeDefined();
//* ** ALT 1:
db4.transaction(function(tx) {
tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).test_data).toBe(test_data);
done();
}, function (ignored, error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});
}, function (error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});
});
});
});
// */
/* ** FUTURE TBD ALT 2 [NO SQL CALLBACK RECEIVED]:
expect('check1').toBe('--'); // TEST ALT 2 GETS HERE
db3.executeSql('SELECT * FROM tt', null, function(rs) {
// NOT TRIGGERED Android/iOS:
expect(rs).toBeDefined();
// FUTURE TBD CHECK rs
done();
}, function (error) {
// NOT TRIGGERED Android/iOS:
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});
expect('check2').toBe('--'); // TEST ALT 2 GETS HERE
// */
});

});

}, function (error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});
});
}, function (error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
done();
});
});

test_it(suiteName + 'Attempt to open and read unencrypted DB with password key', function () {

var dbName = 'Open-and-read-unencrypted-DB-with-password.db';
Expand Down
9 changes: 3 additions & 6 deletions spec/www/spec/db-tx-sql-features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ var mytests = function() {

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

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

Expand Down Expand Up @@ -198,8 +197,7 @@ var mytests = function() {

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

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

Expand Down Expand Up @@ -229,8 +227,7 @@ var mytests = function() {

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

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

Expand Down

0 comments on commit c05d02e

Please sign in to comment.