fix encryption tests
This commit is contained in:
parent
9dad53dd88
commit
a8ac2670ea
|
@ -69,24 +69,21 @@ module.exports = {
|
||||||
Realm.schemaVersion('encrypted.realm', 'asdf');
|
Realm.schemaVersion('encrypted.realm', 'asdf');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
|
||||||
|
testEncryptionWithSync: function() {
|
||||||
|
if (!global.enableSyncTests) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
if (global.enableSyncTests) {
|
return Realm.Sync.User.login('http://localhost:9080', "realm-admin", '').then(adminUser => {
|
||||||
module.exports.testEncryptionWithSync = function() {
|
|
||||||
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
|
||||||
if (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
new Realm({
|
new Realm({
|
||||||
encryptionKey: new Int8Array(64),
|
encryptionKey: new Int8Array(64),
|
||||||
sync: {
|
sync: {
|
||||||
user: user,
|
user: adminUser,
|
||||||
url: 'realm://localhost:9080'
|
url: 'realm://localhost:9080'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
user.logout(); // FIXME: clearTestState() doesn't clean up enough and Realm.Sync.User.current might not work
|
adminUser.logout(); // FIXME: clearTestState() doesn't clean up enough and Realm.Sync.User.current might not work
|
||||||
resolve();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
|
|
||||||
const Realm = require('realm');
|
const Realm = require('realm');
|
||||||
|
|
||||||
global.enableSyncTests = Realm.Sync;
|
|
||||||
|
if( typeof Realm.Sync !== 'undefined' && Realm.Sync !== null ) {
|
||||||
|
global.WARNING = "global is not available in React Native. Use it only in tests";
|
||||||
|
global.enableSyncTests = true;
|
||||||
|
}
|
||||||
|
|
||||||
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
||||||
function node_require(module) { return require(module); }
|
function node_require(module) { return require(module); }
|
||||||
|
|
Loading…
Reference in New Issue