Skip to content

Commit

Permalink
RDART-963: Update to new base url (#1620)
Browse files Browse the repository at this point in the history
* Update to new base url

* Fix tests
  • Loading branch information
nirinchev authored Apr 8, 2024
1 parent 8cce315 commit 67d17a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
* Improve file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size (Core 14.4.0).
* Add better hint to error message, if opening native library fails. (Issue [#1595](https://github.com/realm/realm-dart/issues/1595))
* Added support for specifying schema version on `Configuration.flexibleSync`. This allows you to take advantage of an upcoming server-side feature that will allow schema migrations for synchronized Realms. (Issue [#1599](https://github.com/realm/realm-dart/issues/1599))
* The default base url in `AppConfiguration` has been updated to point to `services.cloud.mongodb.com`. See https://www.mongodb.com/docs/atlas/app-services/domain-migration/ for more information. (Issue [#1549](https://github.com/realm/realm-dart/issues/1549))

### Fixed
* Using valid const, but non-literal expressions, such as negation of numbers, as an initializer would fail. (Issue [#1606](https://github.com/realm/realm-dart/issues/1606))
* Backlinks mistakenly included in EJson serialization. ([Issue #1616](https://github.com/realm/realm-dart/issues/1616))
* Fix an assertion failure "m_lock_info && m_lock_info->m_file.get_path() == m_filename" that appears to be related to opening a Realm while the file is in the process of being closed on another thread (Core 14.5.0).
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included) (Core 14.5.0).
* Null pointer exception may be triggered when logging out and async commits callbacks not executed (Core 14.5.0)
* Fix an assertion failure "m_lock_info && m_lock_info->m_file.get_path() == m_filename" that appears to be related to opening a Realm while the file is in the process of being closed on another thread. (Core 14.5.0)
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). (Core 14.5.0)
* Null pointer exception may be triggered when logging out and async commits callbacks not executed. (Core 14.5.0)

### Compatibility
* Realm Studio: 15.0.0 or later.
Expand Down
6 changes: 3 additions & 3 deletions packages/realm_dart/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class AppConfiguration {

/// The [baseUrl] is the [Uri] used to reach the MongoDB Atlas.
///
/// [baseUrl] only needs to be set if for some reason your application isn't hosted on realm.mongodb.com.
/// This can be the case if you're testing locally or are using a pre-production environment.
/// [baseUrl] only needs to be set if for some reason your application isn't hosted on services.cloud.mongodb.com.
/// This can be the case if you're synchronizing with an edge server.
final Uri baseUrl;

/// The [defaultRequestTimeout] for HTTP requests. Defaults to 60 seconds.
Expand Down Expand Up @@ -124,7 +124,7 @@ class AppConfiguration {
this.metadataPersistenceMode = MetadataPersistenceMode.plaintext,
this.maxConnectionTimeout = const Duration(minutes: 2),
HttpClient? httpClient,
}) : baseUrl = baseUrl ?? Uri.parse('https://realm.mongodb.com'),
}) : baseUrl = baseUrl ?? Uri.parse(realmCore.getDefaultBaseUrl()),
baseFilePath = baseFilePath ?? Directory(_path.dirname(Configuration.defaultRealmPath)),
httpClient = httpClient ?? _defaultClient {
if (appId == '') {
Expand Down
4 changes: 4 additions & 0 deletions packages/realm_dart/lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,10 @@ class _RealmCore {
return AppHandle._(realmAppPtr);
}

String getDefaultBaseUrl() {
return _realmLib.realm_app_get_default_base_url().cast<Utf8>().toRealmDartString()!;
}

AppHandle? getApp(String id, String? baseUrl) {
return using((arena) {
final out_app = arena<Pointer<realm_app>>();
Expand Down
9 changes: 7 additions & 2 deletions packages/realm_dart/test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
final defaultAppConfig = AppConfiguration('myapp');
expect(defaultAppConfig.appId, 'myapp');
expect(defaultAppConfig.baseFilePath.path, Configuration.defaultStoragePath);
expect(defaultAppConfig.baseUrl, Uri.parse('https://realm.mongodb.com'));
expect(defaultAppConfig.baseUrl, Uri.parse('https://services.cloud.mongodb.com'));
expect(defaultAppConfig.defaultRequestTimeout, const Duration(minutes: 1));
expect(defaultAppConfig.metadataPersistenceMode, MetadataPersistenceMode.plaintext);

Expand All @@ -46,7 +46,7 @@ void main() {
test('AppConfiguration can be created with defaults', () {
final appConfig = AppConfiguration('myapp1');
expect(appConfig.appId, 'myapp1');
expect(appConfig.baseUrl, Uri.parse('https://realm.mongodb.com'));
expect(appConfig.baseUrl, Uri.parse('https://services.cloud.mongodb.com'));
expect(appConfig.defaultRequestTimeout, const Duration(minutes: 1));
expect(appConfig.metadataPersistenceMode, MetadataPersistenceMode.plaintext);
expect(appConfig.maxConnectionTimeout, const Duration(minutes: 2));
Expand Down Expand Up @@ -87,6 +87,11 @@ void main() {
expect(app.id, configuration.appId);
});

test('AppConfiguration.baseUrl points to the correct value', () {
final configuration = AppConfiguration('abc');
expect(configuration.baseUrl, Uri.parse('https://services.cloud.mongodb.com'));
});

baasTest('App log in', (configuration) async {
final app = App(configuration);
final credentials = Credentials.anonymous();
Expand Down

0 comments on commit 67d17a4

Please sign in to comment.