22
33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertFalse ;
5+ import static org .junit .Assert .assertNotNull ;
56import static org .junit .Assert .assertNull ;
67import static org .junit .Assert .fail ;
78
1718import java .io .IOException ;
1819import java .io .InputStream ;
1920import java .nio .charset .Charset ;
21+
2022import org .junit .Test ;
2123
2224public class UserRecordTest {
@@ -92,7 +94,7 @@ public void testAllProviderInfo() throws IOException {
9294 .put ("photoUrl" , "http://photo.url" )
9395 .put ("providerId" , "providerId" )
9496 .build ()
95- )
97+ )
9698 );
9799 String json = JSON_FACTORY .toString (resp );
98100 UserRecord userRecord = parseUser (json );
@@ -108,6 +110,37 @@ public void testAllProviderInfo() throws IOException {
108110 }
109111 }
110112
113+ @ Test
114+ public void testPhoneMultiFactors () throws IOException {
115+ ImmutableMap <String , Object > resp = ImmutableMap .<String , Object >of (
116+ "localId" , "user" ,
117+ "mfaInfo" , ImmutableList .of (
118+ ImmutableMap .builder ()
119+ .put ("mfaEnrollmentId" , "53HG4HG45HG8G04GJ40J4G3J" )
120+ .put ("displayName" , "Display Name" )
121+ .put ("factorId" , "phone" )
122+ .put ("enrollmentTime" , "Fri, 22 Sep 2017 01:49:58 GMT" )
123+ .put ("phoneInfo" , "+16505551234" )
124+ .build ()
125+ )
126+ );
127+ String json = JSON_FACTORY .toString (resp );
128+ UserRecord userRecord = parseUser (json );
129+ assertEquals ("user" , userRecord .getUid ());
130+
131+ assertNotNull (userRecord .getMultiFactor ());
132+ PhoneMultiFactorInfo [] enrolledFactors = userRecord .getMultiFactor ().getEnrolledFactors ();
133+ assertEquals (1 , enrolledFactors .length );
134+ for (PhoneMultiFactorInfo multiFactorInfo : enrolledFactors ) {
135+ assertEquals ("53HG4HG45HG8G04GJ40J4G3J" , multiFactorInfo .getUid ());
136+ assertEquals ("Display Name" , multiFactorInfo .getDisplayName ());
137+ assertEquals ("phone" , multiFactorInfo .getFactorId ());
138+ assertEquals ("Fri, 22 Sep 2017 01:49:58 GMT" , multiFactorInfo .getEnrollmentTime ());
139+ assertEquals ("+16505551234" , multiFactorInfo .getPhoneNumber ());
140+ assertNull (multiFactorInfo .getUnobfuscatedPhoneNumber ());
141+ }
142+ }
143+
111144 @ Test
112145 public void testUserMetadata () throws IOException {
113146 ImmutableMap <String , Object > resp = ImmutableMap .<String , Object >of (
0 commit comments