Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest Core #3585

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/templates/test-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: test-ios
_: #@ template.replace(testDefinition())
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we this and the others to 13?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13 doesn't have the xamarin tooling. We could manually install it, but I'd rather just use 12 while possible and then either deprecate Xamarin or add a step to manually install at that point.

name: Xamarin.iOS
timeout-minutes: 90
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/templates/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: test-macos
_: #@ template.replace(testDefinition())
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
name: Xamarin.macOS
timeout-minutes: 60
steps:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/templates/test-net-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/templates/test-tvos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: test-tvos
_: #@ template.replace(testDefinition())
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
name: Xamarin.tvOS
timeout-minutes: 45
steps:
Expand Down
7 changes: 4 additions & 3 deletions .github/templates/test-weaver.yml
Original file line number Diff line number Diff line change
@@ -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")

---
Expand All @@ -18,14 +18,15 @@ 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
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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DOTNET_NOLOGO: true
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
name: Xamarin.iOS
timeout-minutes: 90
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DOTNET_NOLOGO: true
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
name: Xamarin.macOS
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-net-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-tvos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
DOTNET_NOLOGO: true
jobs:
test-xamarin:
runs-on: macos-latest
runs-on: macos-12
name: Xamarin.tvOS
timeout-minutes: 45
steps:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test-weaver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tests/Realm.Tests/Sync/SyncMigrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void Migration_FailsWithFutureVersion()
SyncTestHelpers.RunBaasTestAsync(async () =>
{
var ex = await TestHelpers.AssertThrows<SessionException>(() => 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\""));
});
}

Expand Down
5 changes: 1 addition & 4 deletions Tests/Realm.Tests/Sync/UserManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

await DefaultApp.RemoveUserAsync(second);

// TODO: validate that the refresh token is invalidated.

Check warning on line 140 in Tests/Realm.Tests/Sync/UserManagementTests.cs

View workflow job for this annotation

GitHub Actions / Verify TODOs

Tests/Realm.Tests/Sync/UserManagementTests.cs#L140

TODO entry doesn't have a link to Github issue or Jira ticket validate that the refresh token is invalidated.
Assert.That(second.State, Is.EqualTo(UserState.Removed));
Assert.That(second.AccessToken, Is.Empty);
Assert.That(second.RefreshToken, Is.Empty);
Expand Down Expand Up @@ -374,10 +374,7 @@
var user = await GetUserAsync();

var ex = await TestHelpers.AssertThrows<AppException>(() => 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"));
});
}

Expand Down
2 changes: 1 addition & 1 deletion wrappers/realm-core
Submodule realm-core updated 190 files
48 changes: 22 additions & 26 deletions wrappers/src/app_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
#include <realm/sync/config.hpp>
#include <realm/object-store/thread_safe_reference.hpp>
#include <realm/object-store/sync/sync_session.hpp>
#include <realm/object-store/sync/app_user.hpp>

using namespace realm;
using namespace realm::binding;
using namespace app;

using SharedSyncUser = std::shared_ptr<SyncUser>;
using SharedSyncUser = std::shared_ptr<app::User>;

using UserCallbackT = void(void* tcs_ptr, SharedSyncUser* user, MarshaledAppError err);
using VoidCallbackT = void(void* tcs_ptr, MarshaledAppError err);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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<std::array<char, 64>*>(encryption_key);
sync_client_config.custom_encryption_key = std::vector<char>(key.begin(), key.end());
config.custom_encryption_key = std::vector<char>(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);
});
Expand Down Expand Up @@ -242,20 +241,17 @@ 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->create_fake_user_for_testing(id, access_token, refresh_token);
return new SharedSyncUser(user);
});
}

REALM_EXPORT void shared_app_set_fake_sync_route_for_testing(SharedApp& app,
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);
});
}

Expand All @@ -281,7 +277,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);
});
}

Expand Down Expand Up @@ -317,7 +313,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);
});
}
Expand Down
5 changes: 3 additions & 2 deletions wrappers/src/app_cs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#include <realm/object-store/sync/app.hpp>
#include <realm/object-store/sync/sync_user.hpp>
#include <realm/object-store/sync/sync_manager.hpp>
#include <realm/object-store/sync/app_user.hpp>

using namespace realm;
using namespace realm::app;

using SharedSyncUser = std::shared_ptr<SyncUser>;
using SharedSyncUser = std::shared_ptr<app::User>;

namespace realm {
namespace binding {
Expand Down Expand Up @@ -146,7 +147,7 @@ namespace binding {
}

inline auto get_user_callback_handler(void* tcs_ptr) {
return [tcs_ptr](std::shared_ptr<SyncUser> user, util::Optional<AppError> err) {
return [tcs_ptr](std::shared_ptr<app::User> user, util::Optional<AppError> err) {
if (err) {
auto& err_copy = *err;
MarshaledAppError app_error(err_copy);
Expand Down
5 changes: 5 additions & 0 deletions wrappers/src/marshalling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() };
Expand Down
3 changes: 2 additions & 1 deletion wrappers/src/shared_realm_cs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
#include <realm/object-store/sync/sync_manager.hpp>
#include <realm/object-store/sync/sync_session.hpp>
#include <realm/sync/config.hpp>
#include <realm/object-store/sync/app_user.hpp>

namespace realm::binding {
using SharedSyncUser = std::shared_ptr<SyncUser>;
using SharedSyncUser = std::shared_ptr<app::User>;

struct Configuration
{
Expand Down
5 changes: 3 additions & 2 deletions wrappers/src/sync_session_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <realm/object-store/sync/sync_session.hpp>
#include "sync_session_cs.hpp"
#include <realm/sync/client_base.hpp>
#include <realm/object-store/sync/app_user.hpp>

namespace realm::binding {
enum class NotifiableProperty : uint8_t {
Expand All @@ -43,13 +44,13 @@ std::function<NotifyBeforeClientResetCallbackT> s_notify_before_callback;
std::function<NotifyAfterClientResetCallbackT> s_notify_after_callback;

extern "C" {
REALM_EXPORT std::shared_ptr<SyncUser>* realm_syncsession_get_user(const SharedSyncSession& session)
REALM_EXPORT std::shared_ptr<app::User>* realm_syncsession_get_user(const SharedSyncSession& session)
{
if (session->user() == nullptr) {
return nullptr;
}

return new std::shared_ptr<SyncUser>(session->user());
return new std::shared_ptr<app::User>(std::dynamic_pointer_cast<app::User>(session->user()));
}

enum class CSharpSessionState : uint8_t {
Expand Down
Loading
Loading