Kneth/allow partial in urls (#1704)
* Adding _disablePartialSyncUrlChecks.
This commit is contained in:
parent
8dc5149770
commit
2f20006e47
|
@ -36,6 +36,7 @@
|
|||
* Updated to Realm Core 5.4.0.
|
||||
* Updated to Realm Sync 3.0.0-rc.1.
|
||||
* Tested against Realm Object Server 3.0.0-alpha.8.
|
||||
* Added `_disablePartialSyncUrlChecks` to `Realm.Configuration`.
|
||||
|
||||
2.2.15 Release notes (2018-3-9)
|
||||
=============================================================
|
||||
|
|
|
@ -379,6 +379,7 @@ declare namespace Realm.Sync {
|
|||
open_ssl_verify_callback?: SSLVerifyCallback;
|
||||
error?: ErrorCallback;
|
||||
partial?: boolean;
|
||||
_disablePartialSyncUrlChecks?:boolean;
|
||||
}
|
||||
|
||||
type ProgressNotificationCallback = (transferred: number, transferable: number) => void;
|
||||
|
|
|
@ -823,7 +823,19 @@ void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constr
|
|||
is_partial = Value::validated_to_boolean(ctx, partial_value);
|
||||
}
|
||||
|
||||
bool disable_partial_sync_url_checks = false;
|
||||
ValueType disable_partial_sync_url_checks_value = Object::get_property(ctx, sync_config_object, "_disablePartialSyncUrlChecks");
|
||||
if (!Value::is_undefined(ctx, disable_partial_sync_url_checks_value)) {
|
||||
disable_partial_sync_url_checks = Value::validated_to_boolean(ctx, disable_partial_sync_url_checks_value);
|
||||
}
|
||||
|
||||
if (disable_partial_sync_url_checks) {
|
||||
config.sync_config = std::make_shared<SyncConfig>(shared_user, std::move(""));
|
||||
config.sync_config->reference_realm_url = std::move(raw_realm_url);
|
||||
}
|
||||
else {
|
||||
config.sync_config = std::make_shared<SyncConfig>(shared_user, std::move(raw_realm_url));
|
||||
}
|
||||
config.sync_config->bind_session_handler = std::move(bind);
|
||||
config.sync_config->error_handler = std::move(error_handler);
|
||||
config.sync_config->client_validate_ssl = client_validate_ssl;
|
||||
|
|
|
@ -749,6 +749,36 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
|
||||
testOpenPartialSyncUrl() {
|
||||
if (!isNodeProccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
const username = uuid();
|
||||
return Realm.Sync.User.register('http://localhost:9080', username, 'password')
|
||||
.then(user => {
|
||||
let config1 = {
|
||||
sync: {
|
||||
user: user,
|
||||
url: `realm://localhost:9080/~/default/__partial/`,
|
||||
partial: true,
|
||||
_disablePartialSyncUrlChecks: true
|
||||
}
|
||||
};
|
||||
const realm = new Realm(config1);
|
||||
TestCase.assertFalse(realm.isClosed);
|
||||
|
||||
let config2 = {
|
||||
sync: {
|
||||
user: user,
|
||||
url: `realm://localhost:9080/~/default/__partial/`, // <--- not allowed URL
|
||||
partial: true,
|
||||
}
|
||||
};
|
||||
TestCase.assertThrows(() => new Realm(config2));
|
||||
});
|
||||
},
|
||||
|
||||
testPartialSyncAnonymous_SubscriptionListener() {
|
||||
// FIXME: try to enable for React Native
|
||||
if (!isNodeProccess) {
|
||||
|
|
Loading…
Reference in New Issue