Kneth/allow partial in urls (#1704)

* Adding _disablePartialSyncUrlChecks.
This commit is contained in:
Kenneth Geisshirt 2018-03-13 08:27:47 +01:00 committed by GitHub
parent 8dc5149770
commit 2f20006e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 1 deletions

View File

@ -36,6 +36,7 @@
* Updated to Realm Core 5.4.0. * Updated to Realm Core 5.4.0.
* Updated to Realm Sync 3.0.0-rc.1. * Updated to Realm Sync 3.0.0-rc.1.
* Tested against Realm Object Server 3.0.0-alpha.8. * Tested against Realm Object Server 3.0.0-alpha.8.
* Added `_disablePartialSyncUrlChecks` to `Realm.Configuration`.
2.2.15 Release notes (2018-3-9) 2.2.15 Release notes (2018-3-9)
============================================================= =============================================================

1
lib/index.d.ts vendored
View File

@ -379,6 +379,7 @@ declare namespace Realm.Sync {
open_ssl_verify_callback?: SSLVerifyCallback; open_ssl_verify_callback?: SSLVerifyCallback;
error?: ErrorCallback; error?: ErrorCallback;
partial?: boolean; partial?: boolean;
_disablePartialSyncUrlChecks?:boolean;
} }
type ProgressNotificationCallback = (transferred: number, transferable: number) => void; type ProgressNotificationCallback = (transferred: number, transferable: number) => void;

View File

@ -823,7 +823,19 @@ void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constr
is_partial = Value::validated_to_boolean(ctx, partial_value); is_partial = Value::validated_to_boolean(ctx, partial_value);
} }
config.sync_config = std::make_shared<SyncConfig>(shared_user, std::move(raw_realm_url)); 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->bind_session_handler = std::move(bind);
config.sync_config->error_handler = std::move(error_handler); config.sync_config->error_handler = std::move(error_handler);
config.sync_config->client_validate_ssl = client_validate_ssl; config.sync_config->client_validate_ssl = client_validate_ssl;

View File

@ -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() { testPartialSyncAnonymous_SubscriptionListener() {
// FIXME: try to enable for React Native // FIXME: try to enable for React Native
if (!isNodeProccess) { if (!isNodeProccess) {