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

Create custom error code for InvalidPassword response #4851

Merged
merged 3 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 how-to-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ To run the [app] tests against the local image, you need to configure a build wi
```
mkdir build.sync.ninja
cmake -B build.sync.ninja -G Ninja -DREALM_ENABLE_AUTH_TESTS=1 -DREALM_MONGODB_ENDPOINT=http://localhost:9090
cmake --build build.sync.ninja --target tests
cmake --build build.sync.ninja --target realm-object-store-tests
./build.sync.ninja/test/object-store/realm-object-store-tests -d=1
```
### Developing inside a container
Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/sync/generic_network_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static const std::map<std::string, ServiceErrorCode> service_error_map = {
{"AuthError", ServiceErrorCode::auth_error},
{"BadRequest", ServiceErrorCode::bad_request},
{"AccountNameInUse", ServiceErrorCode::account_name_in_use},
{"InvalidPassword", ServiceErrorCode::invalid_email_password},
{"Unknown", ServiceErrorCode::unknown},
};

Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/sync/generic_network_transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum class ServiceErrorCode {
auth_error = 47,
bad_request = 48,
account_name_in_use = 49,
invalid_email_password = 50,

unknown = -1,
none = 0
Expand Down
12 changes: 12 additions & 0 deletions test/object-store/sync/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@ TEST_CASE("app: UsernamePasswordProviderClient integration", "[sync][app]") {
CHECK(user->user_profile().email() == email);
}

SECTION("cannot login with wrong password") {
app->log_in_with_credentials(realm::app::AppCredentials::username_password(email, "boogeyman"),
[&](std::shared_ptr<realm::SyncUser> user, Optional<app::AppError> error) {
CHECK(!user);
REQUIRE(error);
REQUIRE(error->error_code.value() ==
int(ServiceErrorCode::invalid_email_password));
processed = true;
});
CHECK(processed);
}

SECTION("confirm user") {
app->provider_client<App::UsernamePasswordProviderClient>().confirm_user(
"a_token", "a_token_id", [&](Optional<app::AppError> error) {
Expand Down