Skip to content

Commit

Permalink
Added support for updating the base url
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaafanador3 committed Apr 29, 2024
1 parent e718cc8 commit 355eeac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Enhancements
* Updated default base URL to be `https://services.cloud.mongodb.com` to support the new domains (was `https://realm.mongodb.com`)
* Added support for updating Atlas Device Sync's base url, in case the need to roam between servers (cloud and/or edge server).

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10.
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(REALM_NO_TESTS)
set(REALM_BUILD_LIB_ONLY)
set(REALM_INSTALL_LIBEXECDIR)
set(REALM_ENABLE_ENCRYPTION 1)
set(REALM_ENABLE_EXPERIMENTAL)

set(CMAKE_DEBUG_POSTFIX "-dbg")

Expand Down
4 changes: 4 additions & 0 deletions include/cpprealm/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ class App {
void clear_cached_apps();
std::optional<App> get_cached_app(const std::string& app_id, const std::optional<std::string>& base_url);
std::string get_base_url() const;

#ifdef AD_ENABLE_EXPERIMENTAL
[[nodiscard]] std::future<void> App::update_base_url(std::string base_url) const;
#endif
private:
std::shared_ptr<app::App> m_app;
App(std::shared_ptr<app::App>&& a) : m_app(std::move(a)) { }
Expand Down
14 changes: 14 additions & 0 deletions src/cpprealm/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,18 @@ namespace realm {
return std::nullopt;
}

#ifdef AD_ENABLE_EXPERIMENTAL
[[nodiscard]] std::future<void> App::update_base_url(std::string base_url) const {
std::promise<void> p;
std::future<void> f = p.get_future();
m_app->update_base_url(base_url, ([p = std::move(p)](auto err) mutable {
if (err) {
p.set_exception(std::make_exception_ptr(app_error(std::move(*err))));
} else {
p.set_value();
}
});
return f;
}
#endif
}
7 changes: 7 additions & 0 deletions tests/sync/app_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ TEST_CASE("app", "[app]") {
CHECK(with_url_provided_app.get_base_url() == "https://foobar.com");
}

SECTION("update_base_url") {
auto app = realm::App(realm::App::configuration({"NA", "https://foobar.com"}));
CHECK(app.get_base_url() == "https://foobar.com");
app.update_base_url("https://barfoo.com").get();

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Sync Release (gcc 8)

‘class realm::App’ has no member named ‘update_base_url’; did you mean ‘get_base_url’?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Debug (preset default, Xcode 13.1)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Sync Debug (preset macos, Xcode 15.0)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Debug (preset default, Xcode 15.0)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Sync Debug (preset default, Xcode 15.0)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Debug (preset macos, Xcode 15.0)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Sync Debug (gcc 8)

‘class realm::App’ has no member named ‘update_base_url’; did you mean ‘get_base_url’?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (clang 15)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (clang 15)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (gcc 8.3)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (gcc 8.3)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (gcc 12.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (gcc 9.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (gcc 11.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (gcc 10.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (gcc 9.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (gcc 11.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Release (gcc 12.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Linux Debug (gcc 10.1)

'class realm::App' has no member named 'update_base_url'; did you mean 'get_base_url'?

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Windows Sync Debug

'update_base_url': is not a member of 'realm::App' [D:\a\realm-cpp\realm-cpp\.build\cmake-preset-windows-x64\tests\cpprealm_sync_tests.vcxproj]

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Windows Debug

'update_base_url': is not a member of 'realm::App' [D:\a\realm-cpp\realm-cpp\.build\cmake-preset-windows-x64\tests\cpprealm_sync_tests.vcxproj]

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / macOS Debug (preset macos, Xcode 13.1)

no member named 'update_base_url' in 'realm::App'

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Windows Sync Release

'update_base_url': is not a member of 'realm::App' [D:\a\realm-cpp\realm-cpp\.build\cmake-preset-windows-x64\tests\cpprealm_sync_tests.vcxproj]

Check failure on line 85 in tests/sync/app_tests.cpp

View workflow job for this annotation

GitHub Actions / Windows Release

'update_base_url': is not a member of 'realm::App' [D:\a\realm-cpp\realm-cpp\.build\cmake-preset-windows-x64\tests\cpprealm_sync_tests.vcxproj]
CHECK(app.get_base_url() == "https://barfoo.com");
}

SECTION("get_current_user") {
auto user = app.login(realm::App::credentials::anonymous()).get();

Expand Down

0 comments on commit 355eeac

Please sign in to comment.