Skip to content

Commit 6913152

Browse files
author
Michael Wilkerson-Barker
committed
Merge branch 'master' of github.com:realm/realm-core into release/14.6.0-again
2 parents adbefab + 9894889 commit 6913152

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
- SyncUser::session_for_on_disk_path() -> SyncManager::get_existing_session()
3333
- SyncUser::all_sessions() -> SyncManager::get_all_sessions_for(User&)
3434
- SyncManager::immediately_run_file_actions() -> App::immediately_run_file_actions()
35-
- realm_sync_user_subscription_token -> realm_app_user_subscription_token ([PR #7300](https://github.com/realm/realm-core/pull/7300)).
35+
- realm_sync_user_subscription_token -> realm_app_user_subscription_token
36+
- SyncManager::get_user -> App::create_fake_user_for_testing
37+
([PR #7300](https://github.com/realm/realm-core/pull/7300)).
3638
* The `ClientAppDeallocated` error code no longer exists as this error code can no longer occur. ([PR #7300](https://github.com/realm/realm-core/pull/7300)).
3739
* Some fields have moved from SyncClientConfig to AppConfig. AppConfig now has a SyncClientConfig field rather than it being passed separately to App::get_app(). ([PR #7300](https://github.com/realm/realm-core/pull/7300)).
3840
* Sync user management has been removed from SyncManager. This functionality was already additionally available on App. ([PR #7300](https://github.com/realm/realm-core/pull/7300)).

src/realm/object-store/sync/app.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,22 @@ void App::link_user(const std::shared_ptr<User>& user, const AppCredentials& cre
977977
log_in_with_credentials(credentials, user, std::move(completion));
978978
}
979979

980+
std::shared_ptr<User> App::create_fake_user_for_testing(const std::string& user_id, const std::string& access_token,
981+
const std::string& refresh_token)
982+
{
983+
std::shared_ptr<User> user;
984+
{
985+
m_metadata_store->create_user(user_id, refresh_token, access_token, "fake_device");
986+
util::CheckedLockGuard lock(m_user_mutex);
987+
user_data_updated(user_id); // FIXME: needs to be callback from metadata store
988+
user = get_user_for_id(user_id);
989+
}
990+
991+
switch_user(user);
992+
return user;
993+
}
994+
995+
980996
void App::refresh_custom_data(const std::shared_ptr<User>& user,
981997
UniqueFunction<void(Optional<AppError>)>&& completion)
982998
{

src/realm/object-store/sync/app.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ class App : public std::enable_shared_from_this<App>,
184184
util::UniqueFunction<void(std::optional<AppError>)>&& completion)
185185
REQUIRES(!m_route_mutex, !m_user_mutex);
186186

187+
/// Creates a fake user with the provided access and refresh tokens. No validation is done to ensure that the
188+
/// credentials are actually valid and as such, this should only be used for testing purposes.
189+
/// @param user_id The id of the user that will be created
190+
/// @param access_token The access token of the user
191+
/// @param refresh_token The refresh token of the user
192+
std::shared_ptr<User> create_fake_user_for_testing(const std::string& user_id, const std::string& access_token,
193+
const std::string& refresh_token);
194+
187195
// MARK: - Provider Clients
188196

189197
/// A struct representing a user API key as returned by the App server.

0 commit comments

Comments
 (0)