2
2
3
3
import static org .junit .Assert .assertEquals ;
4
4
import static org .junit .Assert .assertFalse ;
5
+ import static org .junit .Assert .assertNotNull ;
5
6
import static org .junit .Assert .assertNull ;
6
7
import static org .junit .Assert .fail ;
7
8
17
18
import java .io .IOException ;
18
19
import java .io .InputStream ;
19
20
import java .nio .charset .Charset ;
21
+
20
22
import org .junit .Test ;
21
23
22
24
public class UserRecordTest {
@@ -92,7 +94,7 @@ public void testAllProviderInfo() throws IOException {
92
94
.put ("photoUrl" , "http://photo.url" )
93
95
.put ("providerId" , "providerId" )
94
96
.build ()
95
- )
97
+ )
96
98
);
97
99
String json = JSON_FACTORY .toString (resp );
98
100
UserRecord userRecord = parseUser (json );
@@ -108,6 +110,37 @@ public void testAllProviderInfo() throws IOException {
108
110
}
109
111
}
110
112
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
+
111
144
@ Test
112
145
public void testUserMetadata () throws IOException {
113
146
ImmutableMap <String , Object > resp = ImmutableMap .<String , Object >of (
0 commit comments