Skip to content

Commit

Permalink
chore: Update tests for getting and deleting provider uid via phone n…
Browse files Browse the repository at this point in the history
…umber and email.
  • Loading branch information
jonathanedey committed Jan 28, 2025
1 parent af8eed9 commit 455c241
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,23 @@ public void testGetUserByProviderUidWithPhone() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement(
TestUtils.loadResource("getUser.json"));
UserRecord userRecord = FirebaseAuth.getInstance()
.getUserByProviderUidAsync("phone", "+1234567890").get();
.getUserByProviderUidAsync(new String("phone"), "+1234567890").get();
checkUserRecord(userRecord);
checkRequestHeaders(interceptor);
GenericJson parsed = parseRequestContent(interceptor);
assertEquals(ImmutableList.of("+1234567890"), parsed.get("phoneNumber"));
}

@Test
public void testGetUserByProviderUidWithEmail() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement(
TestUtils.loadResource("getUser.json"));
UserRecord userRecord = FirebaseAuth.getInstance()
.getUserByProviderUidAsync("email", "[email protected]").get();
.getUserByProviderUidAsync(new String("email"), "[email protected]").get();
checkUserRecord(userRecord);
checkRequestHeaders(interceptor);
GenericJson parsed = parseRequestContent(interceptor);
assertEquals(ImmutableList.of("[email protected]"), parsed.get("email"));
}

@Test
Expand Down Expand Up @@ -1248,20 +1252,22 @@ public void testDeleteProviderAndPhone() {

@Test
public void testDoubleDeletePhoneProvider() throws Exception {
String providerId = new String("phone");
UserRecord.UpdateRequest update = new UserRecord.UpdateRequest("uid")
.setPhoneNumber(null);

try {
update.setProvidersToUnlink(ImmutableList.of("phone"));
update.setProvidersToUnlink(ImmutableList.of(providerId));
fail("No error thrown for double delete phone provider");
} catch (IllegalArgumentException expected) {
}
}

@Test
public void testDoubleDeletePhoneProviderReverseOrder() throws Exception {
String providerId = new String("phone");
UserRecord.UpdateRequest update = new UserRecord.UpdateRequest("uid")
.setProvidersToUnlink(ImmutableList.of("phone"));
.setProvidersToUnlink(ImmutableList.of(providerId));

try {
update.setPhoneNumber(null);
Expand Down

0 comments on commit 455c241

Please sign in to comment.