Skip to content

Commit

Permalink
Add app test and change
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Jul 17, 2024
1 parent e019c79 commit 2c9fb5d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/realm/object-store/sync/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,10 @@ void App::log_in_with_credentials(const AppCredentials& credentials, const std::
return completion(nullptr,
AppError(ErrorCodes::BadToken, "Could not log in user: received malformed JWT"));
}
switch_user(user);
get_profile(user, std::move(completion));
get_profile(user, [this, &completion](const std::shared_ptr<User>& user, Optional<AppError> error) {
switch_user(user);
completion(user, error);
});
},
false);
}
Expand Down
14 changes: 14 additions & 0 deletions test/object-store/sync/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4168,6 +4168,20 @@ TEST_CASE("app: custom user data integration tests", "[sync][app][user][function
TEST_CASE("app: jwt login and metadata tests", "[sync][app][user][metadata][function][baas]") {
TestAppSession session;
auto app = session.app();

bool first_log_in = true;
auto token = app->subscribe([&first_log_in, &app](auto&) {
if (first_log_in) {
// Read the current user to verify that doing so does not deadlock
auto user = app->current_user();
auto metadata = user->user_profile();
auto custom_data = *user->custom_data();
CHECK(custom_data["name"] == "Not Foo Bar");
CHECK(metadata["name"] == "Foo Bar");
first_log_in = false;
}
});

auto jwt = create_jwt(session.app()->app_id());

SECTION("jwt happy path") {
Expand Down

0 comments on commit 2c9fb5d

Please sign in to comment.