Skip to content

Commit

Permalink
Create custom error code for InvalidPassword response
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Aug 18, 2021
1 parent 7fb546d commit 072ce41
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
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

0 comments on commit 072ce41

Please sign in to comment.