File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/test/java/com/google/firebase/auth Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -336,7 +336,20 @@ public void testLastRefreshTime() throws Exception {
336336 // Login to cause the lastRefreshTimestamp to be set.
337337 signInWithPassword (newUserRecord .getEmail (), "password" );
338338
339- UserRecord userRecord = auth .getUser (newUserRecord .getUid ());
339+ // Attempt to retrieve the user 3 times (with a small delay between each
340+ // attempt). Occassionally, this call retrieves the user data without the
341+ // lastLoginTime/lastRefreshTime set; possibly because it's hitting a
342+ // different server than the login request uses.
343+ UserRecord userRecord = null ;
344+ for (int i = 0 ; i < 3 ; i ++) {
345+ userRecord = auth .getUser (newUserRecord .getUid ());
346+
347+ if (userRecord .getUserMetadata ().getLastRefreshTimestamp () != 0 ) {
348+ break ;
349+ }
350+
351+ TimeUnit .SECONDS .sleep ((long )Math .pow (2 , i ));
352+ }
340353
341354 // Ensure the lastRefreshTimestamp is approximately "now" (with a tollerance of 10 minutes).
342355 long now = System .currentTimeMillis ();
You can’t perform that action at this time.
0 commit comments