From 3edae2207a0e869c3b14e7e85a0f9e9e88ec1d19 Mon Sep 17 00:00:00 2001 From: nirinchev Date: Thu, 25 Apr 2024 13:55:32 +0200 Subject: [PATCH 1/6] Update to latest Core --- wrappers/realm-core | 2 +- wrappers/src/app_cs.cpp | 53 ++++++++++++++++---------------- wrappers/src/app_cs.hpp | 5 +-- wrappers/src/marshalling.hpp | 5 +++ wrappers/src/shared_realm_cs.hpp | 3 +- wrappers/src/sync_user_cs.cpp | 24 ++++++++------- 6 files changed, 51 insertions(+), 41 deletions(-) diff --git a/wrappers/realm-core b/wrappers/realm-core index 316889b967..b2e42c88a9 160000 --- a/wrappers/realm-core +++ b/wrappers/realm-core @@ -1 +1 @@ -Subproject commit 316889b967f845fbc10b4422f96c7eadd47136f2 +Subproject commit b2e42c88a950e8631a7cd1cb55f73dea62ca698f diff --git a/wrappers/src/app_cs.cpp b/wrappers/src/app_cs.cpp index a5b1b766fb..29709e5402 100644 --- a/wrappers/src/app_cs.cpp +++ b/wrappers/src/app_cs.cpp @@ -33,12 +33,13 @@ #include #include #include +#include using namespace realm; using namespace realm::binding; using namespace app; -using SharedSyncUser = std::shared_ptr; +using SharedSyncUser = std::shared_ptr; using UserCallbackT = void(void* tcs_ptr, SharedSyncUser* user, MarshaledAppError err); using VoidCallbackT = void(void* tcs_ptr, MarshaledAppError err); @@ -73,7 +74,7 @@ namespace realm { uint64_t request_timeout_ms; - realm::SyncClientConfig::MetadataMode metadata_mode; + app::AppConfig::MetadataMode metadata_mode; bool metadata_mode_has_value; @@ -128,7 +129,7 @@ extern "C" { REALM_EXPORT SharedApp* shared_app_create(AppConfiguration app_config, uint8_t* encryption_key, NativeException::Marshallable& ex) { return handle_errors(ex, [&]() { - App::Config config; + app::AppConfig config; config.app_id = Utf16StringAccessor(app_config.app_id, app_config.app_id_len); config.device_info.framework_name = s_framework; @@ -147,38 +148,36 @@ extern "C" { config.default_request_timeout_ms = app_config.request_timeout_ms; } - SyncClientConfig sync_client_config; - sync_client_config.base_file_path = Utf16StringAccessor(app_config.base_file_path, app_config.base_file_path_len); - sync_client_config.timeouts.connection_linger_time = app_config.sync_connection_linger_time_ms; - sync_client_config.timeouts.connect_timeout = app_config.sync_connect_timeout_ms; - sync_client_config.timeouts.fast_reconnect_limit = app_config.sync_fast_reconnect_limit; - sync_client_config.timeouts.ping_keepalive_period = app_config.sync_ping_keep_alive_period_ms; - sync_client_config.timeouts.pong_keepalive_timeout = app_config.sync_pong_keep_alive_timeout_ms; + config.base_file_path = Utf16StringAccessor(app_config.base_file_path, app_config.base_file_path_len); + config.sync_client_config.timeouts.connection_linger_time = app_config.sync_connection_linger_time_ms; + config.sync_client_config.timeouts.connect_timeout = app_config.sync_connect_timeout_ms; + config.sync_client_config.timeouts.fast_reconnect_limit = app_config.sync_fast_reconnect_limit; + config.sync_client_config.timeouts.ping_keepalive_period = app_config.sync_ping_keep_alive_period_ms; + config.sync_client_config.timeouts.pong_keepalive_timeout = app_config.sync_pong_keep_alive_timeout_ms; if (app_config.managed_websocket_provider) { - sync_client_config.socket_provider = make_websocket_provider(app_config.managed_websocket_provider); + config.sync_client_config.socket_provider = make_websocket_provider(app_config.managed_websocket_provider); } if (app_config.metadata_mode_has_value) { - sync_client_config.metadata_mode = app_config.metadata_mode; + config.metadata_mode = app_config.metadata_mode; } else { #if REALM_PLATFORM_APPLE && !TARGET_OS_SIMULATOR && !TARGET_OS_MACCATALYST - sync_client_config.metadata_mode = SyncManager::MetadataMode::Encryption; + config.metadata_mode = app::AppConfig::MetadataMode::Encryption; #else - sync_client_config.metadata_mode = SyncManager::MetadataMode::NoEncryption; + config.metadata_mode = app::AppConfig::MetadataMode::NoEncryption; #endif } if (encryption_key) { auto& key = *reinterpret_cast*>(encryption_key); - sync_client_config.custom_encryption_key = std::vector(key.begin(), key.end()); + config.custom_encryption_key = std::vector(key.begin(), key.end()); } SharedApp app = App::get_app(app_config.use_cache ? realm::app::App::CacheMode::Enabled : realm::app::App::CacheMode::Disabled, - std::move(config), - std::move(sync_client_config)); + std::move(config)); return new SharedApp(app); }); @@ -242,12 +241,14 @@ extern "C" { Utf16StringAccessor id(id_buf, id_len); Utf16StringAccessor refresh_token(refresh_token_buf, refresh_token_len); Utf16StringAccessor access_token(access_token_buf, access_token_len); - return new SharedSyncUser( - app->sync_manager()->get_user( - id, - refresh_token, - access_token, - "testing")); + + auto user = app::User::make(app, id); + user->update_data_for_testing([&](app::UserData& data) { + data.access_token = RealmJWT(access_token.to_string()); + data.refresh_token = RealmJWT(refresh_token.to_string()); + }); + + return new SharedSyncUser(user); }); } @@ -255,7 +256,7 @@ extern "C" { NativeException::Marshallable& ex) { return handle_errors(ex, [&]() { - app->sync_manager()->set_sync_route("realm://www.test.com:1000"); + app->sync_manager()->set_sync_route("realm://www.test.com:1000", true); }); } @@ -281,7 +282,7 @@ extern "C" { { return handle_errors(ex, [&]() { std::string path(Utf16StringAccessor(pathbuffer, pathbuffer_len)); - return app->sync_manager()->immediately_run_file_actions(path); + return app->immediately_run_file_actions(path); }); } @@ -317,7 +318,7 @@ extern "C" { REALM_EXPORT size_t shared_app_get_base_file_path(SharedApp& app, uint16_t* buffer, size_t buffer_length, NativeException::Marshallable& ex) { return handle_errors(ex, [&]() { - std::string base_file_path(app->sync_manager()->config().base_file_path); + std::string base_file_path(app->config().base_file_path); return stringdata_to_csharpstringbuffer(base_file_path, buffer, buffer_length); }); } diff --git a/wrappers/src/app_cs.hpp b/wrappers/src/app_cs.hpp index b24d99704a..8136ac73b5 100644 --- a/wrappers/src/app_cs.hpp +++ b/wrappers/src/app_cs.hpp @@ -24,11 +24,12 @@ #include #include #include +#include using namespace realm; using namespace realm::app; -using SharedSyncUser = std::shared_ptr; +using SharedSyncUser = std::shared_ptr; namespace realm { namespace binding { @@ -146,7 +147,7 @@ namespace binding { } inline auto get_user_callback_handler(void* tcs_ptr) { - return [tcs_ptr](std::shared_ptr user, util::Optional err) { + return [tcs_ptr](std::shared_ptr user, util::Optional err) { if (err) { auto& err_copy = *err; MarshaledAppError app_error(err_copy); diff --git a/wrappers/src/marshalling.hpp b/wrappers/src/marshalling.hpp index 78df9ce1cc..b1bff56675 100644 --- a/wrappers/src/marshalling.hpp +++ b/wrappers/src/marshalling.hpp @@ -235,6 +235,11 @@ static inline realm_string_t to_capi(StringData data) return realm_string_t{ data.data(), data.size() }; } +static inline realm_string_t to_capi(std::string_view data) +{ + return realm_string_t{ data.data(), data.size() }; +} + static inline realm_string_t to_capi(const std::string& str) { return realm_string_t{ str.data(), str.length() }; diff --git a/wrappers/src/shared_realm_cs.hpp b/wrappers/src/shared_realm_cs.hpp index 59ff549cc4..85edbb9318 100644 --- a/wrappers/src/shared_realm_cs.hpp +++ b/wrappers/src/shared_realm_cs.hpp @@ -27,9 +27,10 @@ #include #include #include +#include namespace realm::binding { -using SharedSyncUser = std::shared_ptr; +using SharedSyncUser = std::shared_ptr; struct Configuration { diff --git a/wrappers/src/sync_user_cs.cpp b/wrappers/src/sync_user_cs.cpp index af3b28c076..7f9093b375 100644 --- a/wrappers/src/sync_user_cs.cpp +++ b/wrappers/src/sync_user_cs.cpp @@ -30,12 +30,12 @@ #include #include "app_cs.hpp" #include "marshalling.hpp" +#include using namespace realm; using namespace realm::binding; -using namespace app; -using SharedSyncUser = std::shared_ptr; +using SharedSyncUser = std::shared_ptr; using SharedSyncSession = std::shared_ptr; using UserChangedCallbackT = void(void* managed_user_handle); @@ -79,8 +79,10 @@ inline AuthProvider to_auth_provider(const std::string& provider) { return (AuthProvider)999; } } +} -void to_json(nlohmann::json& j, const SyncUserIdentity& i) +namespace realm::app { +void to_json(nlohmann::json& j, const UserIdentity& i) { j = nlohmann::json{ { "Id", i.id }, @@ -107,8 +109,8 @@ extern "C" { REALM_EXPORT size_t realm_syncuser_get_id(SharedSyncUser& user, uint16_t* buffer, size_t buffer_length, NativeException::Marshallable& ex) { return handle_errors(ex, [&] { - std::string identity(user->identity()); - return stringdata_to_csharpstringbuffer(identity, buffer, buffer_length); + std::string user_id(user->user_id()); + return stringdata_to_csharpstringbuffer(user_id, buffer, buffer_length); }); } @@ -164,17 +166,17 @@ extern "C" { }); } - REALM_EXPORT Subscribable::Token* realm_syncuser_register_changed_callback(SharedSyncUser& user, void* managed_user_handle, NativeException::Marshallable& ex) + REALM_EXPORT Subscribable::Token* realm_syncuser_register_changed_callback(SharedSyncUser& user, void* managed_user_handle, NativeException::Marshallable& ex) { return handle_errors(ex, [&] { auto token = user->subscribe([managed_user_handle](const SyncUser&) { s_user_changed_callback(managed_user_handle); }); - return new Subscribable::Token(std::move(token)); + return new Subscribable::Token(std::move(token)); }); } - REALM_EXPORT void realm_syncuser_unregister_property_changed_callback(SharedSyncUser& user, Subscribable::Token& token, NativeException::Marshallable& ex) + REALM_EXPORT void realm_syncuser_unregister_property_changed_callback(SharedSyncUser& user, Subscribable::Token& token, NativeException::Marshallable& ex) { handle_errors(ex, [&] { user->unsubscribe(token); @@ -252,7 +254,7 @@ extern "C" { // If the user is detached from the sync manager, we'll hit an assert, so this early check avoids that. if (user->state() != SyncUser::State::Removed) { - if (auto shared_app = user->sync_manager()->app().lock()) { + if (auto shared_app = user->app()) { return new SharedApp(shared_app); } } @@ -353,11 +355,11 @@ extern "C" { if (partition_buf) { Utf16StringAccessor partition(partition_buf, partition_len); auto sync_config = SyncConfig(user, partition); - path = user->sync_manager()->path_for_realm(std::move(sync_config)); + path = user->path_for_realm(std::move(sync_config)); } else { auto sync_config = SyncConfig(user, realm::SyncConfig::FLXSyncEnabled{}); - path = user->sync_manager()->path_for_realm(std::move(sync_config), "default"); + path = user->path_for_realm(std::move(sync_config), "default"); } return stringdata_to_csharpstringbuffer(path, pathbuffer, pathbuffer_len); From e9ab8a6b7ea47c850af7b76b54deebef44a6610a Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 25 Apr 2024 15:26:44 +0200 Subject: [PATCH 2/6] Don't use macos-latest --- .github/templates/test-ios.yml | 2 +- .github/templates/test-macos.yml | 4 ++-- .github/templates/test-net-core.yml | 2 +- .github/templates/test-tvos.yml | 2 +- .github/templates/test-weaver.yml | 4 ++-- .github/workflows/test-ios.yml | 2 +- .github/workflows/test-macos.yml | 4 ++-- .github/workflows/test-net-core.yml | 2 +- .github/workflows/test-tvos.yml | 2 +- .github/workflows/test-weaver.yml | 4 ++-- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml index 4397ce2eed..72ed913539 100644 --- a/.github/templates/test-ios.yml +++ b/.github/templates/test-ios.yml @@ -7,7 +7,7 @@ name: test-ios _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.iOS timeout-minutes: 90 steps: diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml index 079ec0999a..487a741571 100644 --- a/.github/templates/test-macos.yml +++ b/.github/templates/test-macos.yml @@ -7,7 +7,7 @@ name: test-macos _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.macOS timeout-minutes: 60 steps: @@ -17,7 +17,7 @@ jobs: run: #@ "Tests/Tests.XamarinMac/bin/" + configuration + "/Tests.XamarinMac.app/Contents/MacOS/Tests.XamarinMac --headless --result=${{ github.workspace }}/TestResults.XamarinMac.xml --labels=All" + baasTestArgs("xamarinmacos") - #@ publishTestsResults("TestResults.XamarinMac.xml", "Xamarin.macOS") test-maui: - runs-on: macos-12 + runs-on: macos-13 name: Maui.MacCatalyst timeout-minutes: 60 steps: diff --git a/.github/templates/test-net-core.yml b/.github/templates/test-net-core.yml index d516caded5..875583ebc3 100644 --- a/.github/templates/test-net-core.yml +++ b/.github/templates/test-net-core.yml @@ -18,7 +18,7 @@ jobs: runtime: win-x64 - runner: ubuntu-latest runtime: linux-x64 - - runner: macos-latest + - runner: macos-13 runtime: osx-x64 framework: ${{ fromJson(inputs.framework) }} include: diff --git a/.github/templates/test-tvos.yml b/.github/templates/test-tvos.yml index 6a4aea1502..09af7b2d2e 100644 --- a/.github/templates/test-tvos.yml +++ b/.github/templates/test-tvos.yml @@ -7,7 +7,7 @@ name: test-tvos _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.tvOS timeout-minutes: 45 steps: diff --git a/.github/templates/test-weaver.yml b/.github/templates/test-weaver.yml index 0452dd2ab2..61ea75d7d3 100644 --- a/.github/templates/test-weaver.yml +++ b/.github/templates/test-weaver.yml @@ -18,8 +18,8 @@ jobs: runtime: win-x64 - runner: ubuntu-latest runtime: linux-x64 - - runner: macos-latest - runtime: osx-x64 + - runner: macos-14 + runtime: osx-arm64 runs-on: ${{ matrix.os.runner }} name: Weaver timeout-minutes: 30 diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index 8d621c221b..ccdc815a50 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.iOS timeout-minutes: 90 steps: diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index c7d3b955ad..61d2f1b550 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.macOS timeout-minutes: 60 steps: @@ -61,7 +61,7 @@ jobs: path-replace-backslashes: true fail-on-error: false test-maui: - runs-on: macos-12 + runs-on: macos-13 name: Maui.MacCatalyst timeout-minutes: 60 steps: diff --git a/.github/workflows/test-net-core.yml b/.github/workflows/test-net-core.yml index 579ad97150..af8804c199 100755 --- a/.github/workflows/test-net-core.yml +++ b/.github/workflows/test-net-core.yml @@ -27,7 +27,7 @@ jobs: runtime: win-x64 - runner: ubuntu-latest runtime: linux-x64 - - runner: macos-latest + - runner: macos-13 runtime: osx-x64 framework: ${{ fromJson(inputs.framework) }} include: diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml index d7463ab641..46e1534c40 100755 --- a/.github/workflows/test-tvos.yml +++ b/.github/workflows/test-tvos.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-latest + runs-on: macos-13 name: Xamarin.tvOS timeout-minutes: 45 steps: diff --git a/.github/workflows/test-weaver.yml b/.github/workflows/test-weaver.yml index 73df913678..fc66fc87db 100755 --- a/.github/workflows/test-weaver.yml +++ b/.github/workflows/test-weaver.yml @@ -13,8 +13,8 @@ jobs: runtime: win-x64 - runner: ubuntu-latest runtime: linux-x64 - - runner: macos-latest - runtime: osx-x64 + - runner: macos-14 + runtime: osx-arm64 runs-on: ${{ matrix.os.runner }} name: Weaver timeout-minutes: 30 From 4fe6b28e2d59e93a2fd6a7fbee816de449ecef6d Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 25 Apr 2024 16:00:25 +0200 Subject: [PATCH 3/6] Use macos-12 --- .github/templates/test-ios.yml | 2 +- .github/templates/test-macos.yml | 2 +- .github/templates/test-tvos.yml | 2 +- .github/templates/test-weaver.yml | 3 ++- .github/workflows/test-ios.yml | 2 +- .github/workflows/test-macos.yml | 2 +- .github/workflows/test-tvos.yml | 2 +- .github/workflows/test-weaver.yml | 4 ++++ 8 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/templates/test-ios.yml b/.github/templates/test-ios.yml index 72ed913539..1ed5d149fb 100644 --- a/.github/templates/test-ios.yml +++ b/.github/templates/test-ios.yml @@ -7,7 +7,7 @@ name: test-ios _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.iOS timeout-minutes: 90 steps: diff --git a/.github/templates/test-macos.yml b/.github/templates/test-macos.yml index 487a741571..2dd1bae7e3 100644 --- a/.github/templates/test-macos.yml +++ b/.github/templates/test-macos.yml @@ -7,7 +7,7 @@ name: test-macos _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.macOS timeout-minutes: 60 steps: diff --git a/.github/templates/test-tvos.yml b/.github/templates/test-tvos.yml index 09af7b2d2e..e5bcf537c7 100644 --- a/.github/templates/test-tvos.yml +++ b/.github/templates/test-tvos.yml @@ -7,7 +7,7 @@ name: test-tvos _: #@ template.replace(testDefinition()) jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.tvOS timeout-minutes: 45 steps: diff --git a/.github/templates/test-weaver.yml b/.github/templates/test-weaver.yml index 61ea75d7d3..d774c7ace7 100644 --- a/.github/templates/test-weaver.yml +++ b/.github/templates/test-weaver.yml @@ -1,5 +1,5 @@ #@ load("@ytt:template", "template") -#@ load("common.lib.yml", "checkoutCode", "dotnetPublish", "setupWorkloads") +#@ load("common.lib.yml", "checkoutCode", "dotnetPublish", "setupWorkloads", "setupDotnet") #@ load("test.lib.yml", "publishTestsResults") --- @@ -26,6 +26,7 @@ jobs: steps: - #@ template.replace(checkoutCode()) - #@ template.replace(setupWorkloads("android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }}")) + - _: #@ template.replace(setupDotnet()) - #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}")) - name: Run Tests run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After diff --git a/.github/workflows/test-ios.yml b/.github/workflows/test-ios.yml index ccdc815a50..b6ac7b0b81 100755 --- a/.github/workflows/test-ios.yml +++ b/.github/workflows/test-ios.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.iOS timeout-minutes: 90 steps: diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 61d2f1b550..37b90a3db5 100755 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.macOS timeout-minutes: 60 steps: diff --git a/.github/workflows/test-tvos.yml b/.github/workflows/test-tvos.yml index 46e1534c40..ca734dc36a 100755 --- a/.github/workflows/test-tvos.yml +++ b/.github/workflows/test-tvos.yml @@ -13,7 +13,7 @@ env: DOTNET_NOLOGO: true jobs: test-xamarin: - runs-on: macos-13 + runs-on: macos-12 name: Xamarin.tvOS timeout-minutes: 45 steps: diff --git a/.github/workflows/test-weaver.yml b/.github/workflows/test-weaver.yml index fc66fc87db..d527b3eafb 100755 --- a/.github/workflows/test-weaver.yml +++ b/.github/workflows/test-weaver.yml @@ -34,6 +34,10 @@ jobs: dotnet-version: 7.0.x - name: Setup workloads run: dotnet workload install android ${{ (matrix.os.runner != 'ubuntu-latest' && 'tvos ios maccatalyst') || '' }} + - name: Configure .NET + uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + with: + dotnet-version: 6.0.x - name: Publish Tests/Weaver/Realm.Fody.Tests run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained - name: Output executable path From 2f398d29bd659ddc3aacf5425a22248c8fa53e3c Mon Sep 17 00:00:00 2001 From: nirinchev Date: Fri, 26 Apr 2024 13:26:28 +0200 Subject: [PATCH 4/6] Update Core to a version that allows creation of fake users --- Tests/Realm.Tests/Sync/SyncMigrationTests.cs | 2 +- wrappers/realm-core | 2 +- wrappers/src/app_cs.cpp | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Tests/Realm.Tests/Sync/SyncMigrationTests.cs b/Tests/Realm.Tests/Sync/SyncMigrationTests.cs index 1ab64c0b84..54c175bfe1 100644 --- a/Tests/Realm.Tests/Sync/SyncMigrationTests.cs +++ b/Tests/Realm.Tests/Sync/SyncMigrationTests.cs @@ -254,7 +254,7 @@ public void Migration_FailsWithFutureVersion() SyncTestHelpers.RunBaasTestAsync(async () => { var ex = await TestHelpers.AssertThrows(() => OpenRealm(ObjectId.GenerateNewId(), typeof(NullablesV0), schemaVersion: 3)); - Assert.That(ex.Message, Does.Contain("schema version in BIND 3 is greater than latest schema version 2")); + Assert.That(ex.Message, Does.Contain("Client provided invalid schema version: client presented schema version \"3\" is greater than latest schema version \"2\"")); }); } diff --git a/wrappers/realm-core b/wrappers/realm-core index b2e42c88a9..6fbe87a48c 160000 --- a/wrappers/realm-core +++ b/wrappers/realm-core @@ -1 +1 @@ -Subproject commit b2e42c88a950e8631a7cd1cb55f73dea62ca698f +Subproject commit 6fbe87a48c0073a330fbc1b8dca25e609f76c12a diff --git a/wrappers/src/app_cs.cpp b/wrappers/src/app_cs.cpp index 29709e5402..90fe1e144c 100644 --- a/wrappers/src/app_cs.cpp +++ b/wrappers/src/app_cs.cpp @@ -242,12 +242,7 @@ extern "C" { Utf16StringAccessor refresh_token(refresh_token_buf, refresh_token_len); Utf16StringAccessor access_token(access_token_buf, access_token_len); - auto user = app::User::make(app, id); - user->update_data_for_testing([&](app::UserData& data) { - data.access_token = RealmJWT(access_token.to_string()); - data.refresh_token = RealmJWT(refresh_token.to_string()); - }); - + auto user = app->create_fake_user_for_testing(id, access_token, refresh_token); return new SharedSyncUser(user); }); } From cd6e4eb885093da8634d7396238f016a3bde7e41 Mon Sep 17 00:00:00 2001 From: nirinchev Date: Fri, 26 Apr 2024 14:14:03 +0200 Subject: [PATCH 5/6] Bump core --- wrappers/realm-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/realm-core b/wrappers/realm-core index 6fbe87a48c..427a54e504 160000 --- a/wrappers/realm-core +++ b/wrappers/realm-core @@ -1 +1 @@ -Subproject commit 6fbe87a48c0073a330fbc1b8dca25e609f76c12a +Subproject commit 427a54e5046aa5d625343f36cb755bbc0c023163 From 187559d7555d2195af901bfb47a7bc1267bb9754 Mon Sep 17 00:00:00 2001 From: nirinchev Date: Fri, 26 Apr 2024 16:05:18 +0200 Subject: [PATCH 6/6] Fix user test --- Tests/Realm.Tests/Sync/UserManagementTests.cs | 5 +---- wrappers/src/sync_session_cs.cpp | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Tests/Realm.Tests/Sync/UserManagementTests.cs b/Tests/Realm.Tests/Sync/UserManagementTests.cs index 8a06bd77f3..8f66754b56 100644 --- a/Tests/Realm.Tests/Sync/UserManagementTests.cs +++ b/Tests/Realm.Tests/Sync/UserManagementTests.cs @@ -374,10 +374,7 @@ public void User_LinkCredentials_WhenAnonymous_Throws() var user = await GetUserAsync(); var ex = await TestHelpers.AssertThrows(() => user.LinkCredentialsAsync(Credentials.Anonymous())); - - // TODO: this should be bad request when https://jira.mongodb.org/browse/REALMC-7028 is fixed - Assert.That(ex.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError)); - Assert.That(ex.Message, Does.Contain("linking an anonymous identity is not allowed")); + Assert.That(ex.Message, Does.Contain("Cannot add anonymous credentials to an existing user")); }); } diff --git a/wrappers/src/sync_session_cs.cpp b/wrappers/src/sync_session_cs.cpp index 1b942043e8..73f87f2f3c 100644 --- a/wrappers/src/sync_session_cs.cpp +++ b/wrappers/src/sync_session_cs.cpp @@ -26,6 +26,7 @@ #include #include "sync_session_cs.hpp" #include +#include namespace realm::binding { enum class NotifiableProperty : uint8_t { @@ -43,13 +44,13 @@ std::function s_notify_before_callback; std::function s_notify_after_callback; extern "C" { -REALM_EXPORT std::shared_ptr* realm_syncsession_get_user(const SharedSyncSession& session) +REALM_EXPORT std::shared_ptr* realm_syncsession_get_user(const SharedSyncSession& session) { if (session->user() == nullptr) { return nullptr; } - return new std::shared_ptr(session->user()); + return new std::shared_ptr(std::dynamic_pointer_cast(session->user())); } enum class CSharpSessionState : uint8_t {