From 6d16c5e595910e7f8d7a7e68bab147edccb96318 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Mon, 7 Sep 2026 02:27:35 +0000 Subject: [PATCH 1/4] fix(auth,windows): complete reauthenticateWithCredential on success Call ReauthenticateAndRetrieveData so the Pigeon callback receives an AuthResult on success instead of leaving the Dart Future pending. --- .../windows/firebase_auth_plugin.cpp | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/firebase_auth/firebase_auth/windows/firebase_auth_plugin.cpp b/packages/firebase_auth/firebase_auth/windows/firebase_auth_plugin.cpp index 7322e7a1879b..c6435554c858 100644 --- a/packages/firebase_auth/firebase_auth/windows/firebase_auth_plugin.cpp +++ b/packages/firebase_auth/firebase_auth/windows/firebase_auth_plugin.cpp @@ -1039,17 +1039,22 @@ void FirebaseAuthPlugin::ReauthenticateWithCredential( firebase::auth::Auth* firebaseAuth = GetAuthFromPigeon(app); firebase::auth::User user = firebaseAuth->current_user(); - firebase::Future future = - user.Reauthenticate(getCredentialFromArguments(input, app)); + firebase::Future future = + user.ReauthenticateAndRetrieveData( + getCredentialFromArguments(input, app)); - future.OnCompletion([result](const firebase::Future& completed_future) { - // We are probably in a different thread right now. - if (completed_future.error() == 0) { - // TODO: wrong return type - } else { - result(FirebaseAuthPlugin::ParseError(completed_future)); - } - }); + future.OnCompletion( + [result](const firebase::Future& + completed_future) { + // We are probably in a different thread right now. + if (completed_future.error() == 0) { + InternalUserCredential credential = + ParseAuthResult(completed_future.result()); + result(credential); + } else { + result(FirebaseAuthPlugin::ParseError(completed_future)); + } + }); } void FirebaseAuthPlugin::ReauthenticateWithProvider( From fac33bc310ee83eb5e315e3eec12bfd0ccfcf377 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Mon, 7 Sep 2026 02:32:12 +0000 Subject: [PATCH 2/4] test(auth,windows): run reauthenticateWithCredential success e2e Lift the success case out of the desktop-skipped group so Windows CI covers the previously hanging path without enabling error-message assertions. --- .../firebase_auth_user_e2e_test.dart | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart index 0339d95da4d2..1628e7715ebb 100644 --- a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart +++ b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart @@ -298,33 +298,40 @@ void main() { defaultTargetPlatform == TargetPlatform.macOS), ); + // Kept outside the skipped group so Windows covers the success path + // that previously hung. Remaining cases stay skipped on desktop + // because they assert platform-specific error messages. + test( + 'reauthenticateWithCredential() should reauthenticate correctly', + () async { + // Setup + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: email, + password: testPassword, + ); + final initialUser = FirebaseAuth.instance.currentUser; + + // Test + AuthCredential credential = EmailAuthProvider.credential( + email: email, + password: testPassword, + ); + await FirebaseAuth.instance.currentUser! + .reauthenticateWithCredential(credential); + + // Assertions + final currentUser = FirebaseAuth.instance.currentUser; + expect(currentUser, isNot(equals(null))); + expect(initialUser, isNot(equals(null))); + expect(currentUser?.email, equals(email)); + expect(currentUser?.uid, equals(initialUser?.uid)); + }, + skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS, + ); + group( 'reauthenticateWithCredential()', () { - test('should reauthenticate correctly', () async { - // Setup - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: email, - password: testPassword, - ); - final initialUser = FirebaseAuth.instance.currentUser; - - // Test - AuthCredential credential = EmailAuthProvider.credential( - email: email, - password: testPassword, - ); - await FirebaseAuth.instance.currentUser! - .reauthenticateWithCredential(credential); - - // Assertions - final currentUser = FirebaseAuth.instance.currentUser; - expect(currentUser, isNot(equals(null))); - expect(initialUser, isNot(equals(null))); - expect(currentUser?.email, equals(email)); - expect(currentUser?.uid, equals(initialUser?.uid)); - }); - test('should throw user-mismatch ', () async { // Setup String emailAlready = generateRandomEmail(); From 33f842cb024705d1967a4235c5efb80c9de6dd1e Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Mon, 7 Sep 2026 02:35:38 +0000 Subject: [PATCH 3/4] test(auth,windows): run reauthenticateWithCredential e2e group Enable the group on Windows and skip only the sign-in case that does not exercise reauthenticateWithCredential. macOS remains skipped. --- .../firebase_auth_user_e2e_test.dart | 114 +++++++++--------- 1 file changed, 55 insertions(+), 59 deletions(-) diff --git a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart index 1628e7715ebb..2da369bd64b8 100644 --- a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart +++ b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart @@ -298,40 +298,33 @@ void main() { defaultTargetPlatform == TargetPlatform.macOS), ); - // Kept outside the skipped group so Windows covers the success path - // that previously hung. Remaining cases stay skipped on desktop - // because they assert platform-specific error messages. - test( - 'reauthenticateWithCredential() should reauthenticate correctly', - () async { - // Setup - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: email, - password: testPassword, - ); - final initialUser = FirebaseAuth.instance.currentUser; - - // Test - AuthCredential credential = EmailAuthProvider.credential( - email: email, - password: testPassword, - ); - await FirebaseAuth.instance.currentUser! - .reauthenticateWithCredential(credential); - - // Assertions - final currentUser = FirebaseAuth.instance.currentUser; - expect(currentUser, isNot(equals(null))); - expect(initialUser, isNot(equals(null))); - expect(currentUser?.email, equals(email)); - expect(currentUser?.uid, equals(initialUser?.uid)); - }, - skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS, - ); - group( 'reauthenticateWithCredential()', () { + test('should reauthenticate correctly', () async { + // Setup + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: email, + password: testPassword, + ); + final initialUser = FirebaseAuth.instance.currentUser; + + // Test + AuthCredential credential = EmailAuthProvider.credential( + email: email, + password: testPassword, + ); + await FirebaseAuth.instance.currentUser! + .reauthenticateWithCredential(credential); + + // Assertions + final currentUser = FirebaseAuth.instance.currentUser; + expect(currentUser, isNot(equals(null))); + expect(initialUser, isNot(equals(null))); + expect(currentUser?.email, equals(email)); + expect(currentUser?.uid, equals(initialUser?.uid)); + }); + test('should throw user-mismatch ', () async { // Setup String emailAlready = generateRandomEmail(); @@ -435,38 +428,41 @@ void main() { fail('should have thrown an error'); }); - test('should throw wrong-password ', () async { - // Setup - final email = generateRandomEmail(); - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: email, - password: testPassword, - ); + test( + 'should throw wrong-password ', + () async { + // Setup + final email = generateRandomEmail(); + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: email, + password: testPassword, + ); - await FirebaseAuth.instance.signOut(); + await FirebaseAuth.instance.signOut(); - await expectLater( - FirebaseAuth.instance.signInWithEmailAndPassword( - email: email, - password: 'wrong password', - ), - throwsA( - isA() - .having((e) => e.code, 'code', equals('wrong-password')) - .having( - (e) => e.message, - 'message', - equals( - 'The password is invalid or the user does not have a password.', + await expectLater( + FirebaseAuth.instance.signInWithEmailAndPassword( + email: email, + password: 'wrong password', + ), + throwsA( + isA() + .having((e) => e.code, 'code', equals('wrong-password')) + .having( + (e) => e.message, + 'message', + equals( + 'The password is invalid or the user does not have a password.', + ), ), - ), - ), - ); - }); + ), + ); + }, + // Exercises signInWithEmailAndPassword, not reauthenticateWithCredential. + skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.windows, + ); }, - skip: !kIsWeb && - (defaultTargetPlatform == TargetPlatform.windows || - defaultTargetPlatform == TargetPlatform.macOS), + skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS, ); group('reload()', () { From 2dbb85ea4b3b0d59f335e42ada68eb474fd205d6 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Mon, 7 Sep 2026 08:12:32 +0000 Subject: [PATCH 4/4] test(auth): fix Windows and macOS reauthenticate e2e skips Accept the Windows C++ SDK user-mismatch message without a trailing period, and skip the unrelated sign-in case on macOS as well so its test-level skip does not override the group skip. --- .../firebase_auth_user_e2e_test.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart index 2da369bd64b8..a092f79f5970 100644 --- a/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart +++ b/packages/firebase_auth/firebase_auth/example/integration_test/firebase_auth_user_e2e_test.dart @@ -352,8 +352,14 @@ void main() { expect(e.code, equals('user-mismatch')); expect( e.message, - equals( - 'The supplied credentials do not correspond to the previously signed in user.', + anyOf( + equals( + 'The supplied credentials do not correspond to the previously signed in user.', + ), + // Windows C++ SDK omits the trailing period. + equals( + 'The supplied credentials do not correspond to the previously signed in user', + ), ), ); await FirebaseAuth.instance.currentUser!.delete(); //clean up @@ -459,7 +465,10 @@ void main() { ); }, // Exercises signInWithEmailAndPassword, not reauthenticateWithCredential. - skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.windows, + // A test-level skip overrides the group skip, so include macOS here too. + skip: !kIsWeb && + (defaultTargetPlatform == TargetPlatform.windows || + defaultTargetPlatform == TargetPlatform.macOS), ); }, skip: !kIsWeb && defaultTargetPlatform == TargetPlatform.macOS,