Skip to content
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 auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func (c *Client) getUser(ctx context.Context, request *identitytoolkit.Identityt
return nil, err
}
if len(resp.Users) == 0 {
return nil, fmt.Errorf("cannot find user from params: %v", request)
return nil, fmt.Errorf("cannot find user given params: id:%v, phone:%v, email: %v", request.LocalId, request.PhoneNumber, request.Email)
}

eu, err := makeExportedUser(resp.Users[0])
Expand Down
25 changes: 16 additions & 9 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,24 @@ func TestGetNonExistingUser(t *testing.T) {
s := echoServer([]byte(resp), t)
defer s.Close()

user, err := s.Client.GetUser(context.Background(), "ignored_id")
if user != nil || err == nil {
t.Errorf("GetUser(non-existing) = (%v, %v); want = (nil, error)", user, err)
want := "cannot find user given params: id:[%s], phone:[%s], email: [%s]"

we := fmt.Sprintf(want, "id-nonexisting", "", "")
user, err := s.Client.GetUser(context.Background(), "id-nonexisting")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUser(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
user, err = s.Client.GetUserByEmail(context.Background(), "[email protected]")
if user != nil || err == nil {
t.Errorf("GetUserByEmail(non-existing) = (%v, %v); want = (nil, error)", user, err)

we = fmt.Sprintf(want, "", "", "[email protected]")
user, err = s.Client.GetUserByEmail(context.Background(), "[email protected]")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUserByEmail(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+1234567890")
if user != nil || err == nil {
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %v); want = (nil, error)", user, err)

we = fmt.Sprintf(want, "", "+12345678901", "")
user, err = s.Client.GetUserByPhoneNumber(context.Background(), "+12345678901")
if user != nil || err == nil || err.Error() != we {
t.Errorf("GetUserPhoneNumber(non-existing) = (%v, %q); want = (nil, %q)", user, err, we)
}
}

Expand Down
5 changes: 4 additions & 1 deletion integration/auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func TestUserManagement(t *testing.T) {
}{
{"Create test users", testCreateUsers},
{"Get user", testGetUser},
{"Get user by phone", testGetUserByPhoneNumber},
{"Get user by email", testGetUserByEmail},
{"Iterate users", testUserIterator},
{"Paged iteration", testPager},
{"Disable user account", testDisableUser},
Expand Down Expand Up @@ -96,7 +98,8 @@ func testCreateUsers(t *testing.T) {
UID(uid).
Email(uid + "[email protected]").
DisplayName("display_name").
Password("password")
Password("password").
PhoneNumber("+12223334444")

if u, err = client.CreateUser(context.Background(), params); err != nil {
t.Fatal(err)
Expand Down