From fd2418fd4a9c7e76fd69cb354e5e8dc4b54ed06b Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 27 Feb 2023 15:21:10 +0000 Subject: [PATCH 01/33] feat: iOS SDK 10.5.0 --- .../firebase_core/ios/firebase_sdk_version.rb | 2 +- .../firebase_messaging_e2e_test.dart | 34 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/packages/firebase_core/firebase_core/ios/firebase_sdk_version.rb b/packages/firebase_core/firebase_core/ios/firebase_sdk_version.rb index 69abc85daeaa..d28f4a899f17 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_sdk_version.rb +++ b/packages/firebase_core/firebase_core/ios/firebase_sdk_version.rb @@ -1,4 +1,4 @@ # https://firebase.google.com/support/release-notes/ios def firebase_sdk_version!() - '10.3.0' + '10.5.0' end diff --git a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart index 0587cbbab1a1..a905f2ce8138 100644 --- a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart +++ b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart @@ -120,15 +120,6 @@ void main() { }, skip: defaultTargetPlatform != TargetPlatform.android, ); - - test( - 'resolves null on ios if using simulator', - () async { - expect(await messaging.getAPNSToken(), null); - }, - skip: !(defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform != TargetPlatform.macOS), - ); }); group('getInitialMessage', () { @@ -141,21 +132,8 @@ void main() { 'getToken()', () { test('returns a token', () async { - final result = await messaging.requestPermission(); - - if (result.authorizationStatus == AuthorizationStatus.authorized) { final result = await messaging.getToken(); - expect(result, isA()); - } else { - await expectLater( - messaging.getToken(), - throwsA( - isA() - .having((e) => e.code, 'code', 'permission-blocked'), - ), - ); - } }); }, skip: skipManualTests, @@ -165,9 +143,6 @@ void main() { test( 'generate a new token after deleting', () async { - final result = await messaging.requestPermission(); - - if (result.authorizationStatus == AuthorizationStatus.authorized) { final token1 = await messaging.getToken(); await Future.delayed(const Duration(seconds: 3)); await messaging.deleteToken(); @@ -176,15 +151,6 @@ void main() { expect(token1, isA()); expect(token2, isA()); expect(token1, isNot(token2)); - } else { - await expectLater( - messaging.getToken(), - throwsA( - isA() - .having((e) => e.code, 'code', 'permission-blocked'), - ), - ); - } }, skip: skipManualTests, ); // only run for manual testing From 0f7db9f93af9da2bfe4a66e718daedadabc05c40 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 27 Feb 2023 15:21:53 +0000 Subject: [PATCH 02/33] chore: add fake APNS token so manually run tests work as intended --- .../ios/Classes/FLTFirebaseMessagingPlugin.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 5cec45179618..89ce94d01996 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -22,6 +22,7 @@ @implementation FLTFirebaseMessagingPlugin { NSObject *_registrar; NSData *_apnsToken; NSDictionary *_initialNotification; + bool simulatorToken; // Used to track if everything as been initialized before answering // to the initialNotification request @@ -52,6 +53,7 @@ - (instancetype)initWithFlutterMethodChannel:(FlutterMethodChannel *)channel _initialNotificationGathered = NO; _channel = channel; _registrar = registrar; + simulatorToken = false; // Application // Dart -> `getInitialNotification` // ObjC -> Initialize other delegates & observers @@ -998,6 +1000,17 @@ + (NSDictionary *)remoteMessageUserInfoToDict:(NSDictionary *)userInfo { - (void)ensureAPNSTokenSetting { FIRMessaging *messaging = [FIRMessaging messaging]; + // With iOS SDK >= 10.4, an APNS token is required for getting/deleting token. We set a dummy + // token for the simulator for test environments. A simulator will not work for receiving messages + // so it should only be used in a CI environment. If device is running, we already set the APNS + // token below so it works as intended. + if (simulatorToken == false) { + NSString *str = @"fake-apns-token-for-simulator"; + NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; + [[FIRMessaging messaging] setAPNSToken:data type:FIRMessagingAPNSTokenTypeSandbox]; + simulatorToken = true; + } + if (messaging.APNSToken == nil && _apnsToken != nil) { #ifdef DEBUG [[FIRMessaging messaging] setAPNSToken:_apnsToken type:FIRMessagingAPNSTokenTypeSandbox]; From 29968964420f70e058817bb115844297d8d0dada Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 27 Feb 2023 15:50:39 +0000 Subject: [PATCH 03/33] test(firebase_messaging): reinstate APNS token test --- .../firebase_messaging/firebase_messaging_e2e_test.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart index a905f2ce8138..03c9568caed7 100644 --- a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart +++ b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart @@ -120,6 +120,15 @@ void main() { }, skip: defaultTargetPlatform != TargetPlatform.android, ); + + test( + 'resolves dummy APNS token on ios if using simulator', + () async { + expect(await messaging.getAPNSToken(), isA()); + }, + skip: !(defaultTargetPlatform == TargetPlatform.iOS || + defaultTargetPlatform != TargetPlatform.macOS), + ); }); group('getInitialMessage', () { From 85182ee3e4b56eba5467842c5ef6d6227fc68ab1 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 27 Feb 2023 15:56:53 +0000 Subject: [PATCH 04/33] test(firebase_messaging, iOS): wrap APNS token setting in iOS simulator build for dummy token --- .../firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 89ce94d01996..19be3615035e 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -1004,12 +1004,14 @@ - (void)ensureAPNSTokenSetting { // token for the simulator for test environments. A simulator will not work for receiving messages // so it should only be used in a CI environment. If device is running, we already set the APNS // token below so it works as intended. +#if TARGET_IPHONE_SIMULATOR if (simulatorToken == false) { NSString *str = @"fake-apns-token-for-simulator"; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; [[FIRMessaging messaging] setAPNSToken:data type:FIRMessagingAPNSTokenTypeSandbox]; simulatorToken = true; } +#endif if (messaging.APNSToken == nil && _apnsToken != nil) { #ifdef DEBUG From 3cb893d05dab08354d883677d63110aa9949ae10 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 13:54:08 +0000 Subject: [PATCH 05/33] test(messaging, macOS): update test app. needs push service enable & e2e test update --- .../firebase_messaging_e2e_test.dart | 1 + tests/ios/Runner.xcodeproj/project.pbxproj | 22 +++---------------- tests/ios/Runner/Info.plist | 2 ++ tests/macos/Runner.xcodeproj/project.pbxproj | 6 +++++ tests/macos/Runner/DebugProfile.entitlements | 2 ++ tests/macos/Runner/Release.entitlements | 2 ++ 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart index 03c9568caed7..8dc7ccad2ef6 100644 --- a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart +++ b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart @@ -68,6 +68,7 @@ void main() { test( 'sets the value', () async { + await messaging.setAutoInitEnabled(true); expect(messaging.isAutoInitEnabled, isTrue); await messaging.setAutoInitEnabled(false); expect(messaging.isAutoInitEnabled, isFalse); diff --git a/tests/ios/Runner.xcodeproj/project.pbxproj b/tests/ios/Runner.xcodeproj/project.pbxproj index c3b86276b0e3..3b108edf1bb6 100644 --- a/tests/ios/Runner.xcodeproj/project.pbxproj +++ b/tests/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -142,7 +142,6 @@ 3B06AD1E1E4923F5004D2608 /* Thin Binary */, AC660AAB7696B4DD121B84D0 /* [CP] Embed Pods Frameworks */, 5F39B4E393588B005ADEE74A /* [firebase_crashlytics] Crashlytics Upload Symbols */, - 570B63470F19A77487B49310 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -203,6 +202,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -215,23 +215,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 570B63470F19A77487B49310 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 5F39B4E393588B005ADEE74A /* [firebase_crashlytics] Crashlytics Upload Symbols */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -276,6 +259,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/tests/ios/Runner/Info.plist b/tests/ios/Runner/Info.plist index fa98392a8edb..3dd732018fc0 100644 --- a/tests/ios/Runner/Info.plist +++ b/tests/ios/Runner/Info.plist @@ -67,5 +67,7 @@ https://flutterfiretests.page.link/** + UIApplicationSupportsIndirectInputEvents + diff --git a/tests/macos/Runner.xcodeproj/project.pbxproj b/tests/macos/Runner.xcodeproj/project.pbxproj index b94bb3235826..b1bd1e31e9ca 100644 --- a/tests/macos/Runner.xcodeproj/project.pbxproj +++ b/tests/macos/Runner.xcodeproj/project.pbxproj @@ -440,8 +440,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = YYX2P3XVJ7; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -566,9 +568,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = YYX2P3XVJ7; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -587,8 +591,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = YYX2P3XVJ7; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/tests/macos/Runner/DebugProfile.entitlements b/tests/macos/Runner/DebugProfile.entitlements index 3ba6c1266f21..b76b509eebbf 100644 --- a/tests/macos/Runner/DebugProfile.entitlements +++ b/tests/macos/Runner/DebugProfile.entitlements @@ -2,6 +2,8 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.cs.allow-jit diff --git a/tests/macos/Runner/Release.entitlements b/tests/macos/Runner/Release.entitlements index ee95ab7e582d..39bde1896e64 100644 --- a/tests/macos/Runner/Release.entitlements +++ b/tests/macos/Runner/Release.entitlements @@ -2,6 +2,8 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.network.client From 3f1f02ddff40e9336160f240cebe524fcd219aa3 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 16:41:53 +0000 Subject: [PATCH 06/33] ci: possible fix to provisioning profile for macOS --- .github/workflows/e2e_tests.yaml | 7 ++----- .github/workflows/scripts/install-custom-flutter.sh | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/scripts/install-custom-flutter.sh diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index c800ee38bbce..8ab78a6289f2 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -221,11 +221,8 @@ jobs: path: ~/.cache/firebase/emulators key: firebase-emulators-v1-${{ github.run_id }} restore-keys: firebase-emulators-v1 - - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d - with: - # TODO(Lyokone): upgrade to stable when https://github.com/flutter/flutter/issues/118469 is closed - flutter-version: '3.3.10' - cache: true + - name: Install Flutter + run: ./.github/workflows/scripts/install-custom-flutter.sh - uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a with: run-bootstrap: false diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh new file mode 100644 index 000000000000..c8f7e00f6864 --- /dev/null +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/_flutter" +echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 138528492ea90c6a53f536dd2706636c68535102 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 16:43:27 +0000 Subject: [PATCH 07/33] ci: format yaml --- .github/workflows/e2e_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index 8ab78a6289f2..86202b043f97 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -222,7 +222,7 @@ jobs: key: firebase-emulators-v1-${{ github.run_id }} restore-keys: firebase-emulators-v1 - name: Install Flutter - run: ./.github/workflows/scripts/install-custom-flutter.sh + run: ./.github/workflows/scripts/install-custom-flutter.sh - uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a with: run-bootstrap: false From a139b462754f94b841263514b1febc77eb7c62e1 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 16:51:13 +0000 Subject: [PATCH 08/33] ci: permission to execute script --- .github/workflows/scripts/install-custom-flutter.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/scripts/install-custom-flutter.sh diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh old mode 100644 new mode 100755 From 344125a2afbba7eaee9fc4cf0f974f334bc6c3c2 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 28 Feb 2023 17:24:35 +0000 Subject: [PATCH 09/33] Update install-custom-flutter.sh --- .github/workflows/scripts/install-custom-flutter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index c8f7e00f6864..d37292986f37 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,4 +1,4 @@ #!/bin/bash -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/_flutter" -echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/flutter" +echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH From 825e548dd546fa7f97ac413b1e5a5eba5f6310d5 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 17:38:35 +0000 Subject: [PATCH 10/33] ci: install melos --- .github/workflows/e2e_tests.yaml | 3 --- .github/workflows/scripts/install-custom-flutter.sh | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index 86202b043f97..8dcf30e5c22d 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -223,9 +223,6 @@ jobs: restore-keys: firebase-emulators-v1 - name: Install Flutter run: ./.github/workflows/scripts/install-custom-flutter.sh - - uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a - with: - run-bootstrap: false - name: "Bootstrap package" run: melos bootstrap --scope tests - name: "Install Tools" diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index d37292986f37..45a2ea05c941 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,4 +1,11 @@ #!/bin/bash -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/flutter" -echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/_flutter" +echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH + +flutter config --no-analytics +flutter pub global activate melos 2.9.0 +flutter pub global activate flutter_plugin_tools +echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH From d4158b47c2999f37bedfebae0f40204be9d6231b Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 28 Feb 2023 17:52:23 +0000 Subject: [PATCH 11/33] ci: flutter --- .github/workflows/scripts/install-custom-flutter.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index 45a2ea05c941..bfa69d3d0fe5 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,11 +1,11 @@ #!/bin/bash -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/_flutter" -echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/flutter" +echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH flutter config --no-analytics flutter pub global activate melos 2.9.0 flutter pub global activate flutter_plugin_tools echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/flutter/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH From b17a1048a02dcfc086d08a57a1f38c7dd0534f29 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 08:25:22 +0000 Subject: [PATCH 12/33] ci: get it working before updating to custom git branch --- .github/workflows/e2e_tests.yaml | 6 ++++-- .github/workflows/scripts/install-custom-flutter.sh | 11 +++-------- .github/workflows/scripts/install-tools.sh | 8 ++++++++ 3 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/scripts/install-tools.sh diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index 8dcf30e5c22d..5c6656620559 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -221,8 +221,10 @@ jobs: path: ~/.cache/firebase/emulators key: firebase-emulators-v1-${{ github.run_id }} restore-keys: firebase-emulators-v1 - - name: Install Flutter - run: ./.github/workflows/scripts/install-custom-flutter.sh + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-custom-flutter.sh stable + - name: "Install Tools" + run: ./.github/workflows/scripts/install-tools.sh - name: "Bootstrap package" run: melos bootstrap --scope tests - name: "Install Tools" diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index bfa69d3d0fe5..8ff1de86521d 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,11 +1,6 @@ #!/bin/bash -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning-profile" "$GITHUB_WORKSPACE/flutter" -echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH +BRANCH=$1 +git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH "$GITHUB_WORKSPACE/_flutter" +echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH -flutter config --no-analytics -flutter pub global activate melos 2.9.0 -flutter pub global activate flutter_plugin_tools -echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/flutter/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH diff --git a/.github/workflows/scripts/install-tools.sh b/.github/workflows/scripts/install-tools.sh new file mode 100644 index 000000000000..8e21e30b57c2 --- /dev/null +++ b/.github/workflows/scripts/install-tools.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +flutter config --no-analytics +flutter pub global activate melos 2.4.0 +flutter pub global activate flutter_plugin_tools +echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH +echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH From 24b30aad5c9129a878b9472a8bfa4ba5cf1c1a8d Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 08:39:59 +0000 Subject: [PATCH 13/33] ci: get it working before updating to custom git branch --- .github/workflows/e2e_tests.yaml | 2 +- .../workflows/scripts/{install-tools.sh => install-melos.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/scripts/{install-tools.sh => install-melos.sh} (100%) diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index 5c6656620559..90bfdc49d509 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -224,7 +224,7 @@ jobs: - name: "Install Flutter" run: ./.github/workflows/scripts/install-custom-flutter.sh stable - name: "Install Tools" - run: ./.github/workflows/scripts/install-tools.sh + run: ./.github/workflows/scripts/install-melos.sh - name: "Bootstrap package" run: melos bootstrap --scope tests - name: "Install Tools" diff --git a/.github/workflows/scripts/install-tools.sh b/.github/workflows/scripts/install-melos.sh similarity index 100% rename from .github/workflows/scripts/install-tools.sh rename to .github/workflows/scripts/install-melos.sh From 41532efbdaafa84f559e9406f01ec7406e4b294c Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 08:48:45 +0000 Subject: [PATCH 14/33] ci: permission --- .github/workflows/scripts/install-melos.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/scripts/install-melos.sh diff --git a/.github/workflows/scripts/install-melos.sh b/.github/workflows/scripts/install-melos.sh old mode 100644 new mode 100755 From c3763a535cfbd34651f1fa9f9278c124b0494bc1 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 08:53:58 +0000 Subject: [PATCH 15/33] ci: update to custom branch --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index 8ff1de86521d..bfe8770f049c 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/flutter/flutter.git --depth 1 -b $BRANCH "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From f553dfdbbe73494aa13ee4bbeb4ea13f3950dd27 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 09:03:00 +0000 Subject: [PATCH 16/33] ci: update to custom branch --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index bfe8770f049c..fa37db5f0add 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From b66768f37ed1b2f4fe33e200032387b3a1077483 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 09:12:29 +0000 Subject: [PATCH 17/33] ci: update to flutter repo --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index fa37db5f0add..3fa209f8dafd 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/flutter/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 479fa0ef7bb118af7c9f3b9a4b571740d81d2ff8 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 09:44:20 +0000 Subject: [PATCH 18/33] ci: update to invertase repo --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index 3fa209f8dafd..fa37db5f0add 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/flutter/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 4699e74416ae59bad6f591e10ae4a22162eeab3d Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 10:02:41 +0000 Subject: [PATCH 19/33] ci: update to macos-provisioning branch --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index fa37db5f0add..bfe8770f049c 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 46027c4518bd6f4f5e6afe44b4f8431f77a4f4e8 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 10:21:08 +0000 Subject: [PATCH 20/33] ci: update to stable branch which contains change to build commands --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index bfe8770f049c..fa37db5f0add 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "macos-provisioning" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 9a845f188c62203319919e668b688a147830f69b Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 10:46:19 +0000 Subject: [PATCH 21/33] ci: update to clone at specific tag --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index fa37db5f0add..ece2b7fa9c73 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "stable" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "3.7.6" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 9590fef6abb25e077ba1a2a30822e33cef1adaaa Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 1 Mar 2023 10:54:09 +0000 Subject: [PATCH 22/33] ci: update --- .github/workflows/scripts/install-custom-flutter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh index ece2b7fa9c73..cd08656eef46 100755 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ b/.github/workflows/scripts/install-custom-flutter.sh @@ -1,6 +1,6 @@ #!/bin/bash BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "3.7.6" "$GITHUB_WORKSPACE/_flutter" +git clone https://github.com/invertase/flutter --depth 1 -b "v3.7.6" "$GITHUB_WORKSPACE/_flutter" echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH From 342ffb23bf07afa89523bb3f3d22ce58c874f4e3 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 7 Mar 2023 11:31:28 +0000 Subject: [PATCH 23/33] Delete install-custom-flutter.sh --- .github/workflows/scripts/install-custom-flutter.sh | 6 ------ 1 file changed, 6 deletions(-) delete mode 100755 .github/workflows/scripts/install-custom-flutter.sh diff --git a/.github/workflows/scripts/install-custom-flutter.sh b/.github/workflows/scripts/install-custom-flutter.sh deleted file mode 100755 index cd08656eef46..000000000000 --- a/.github/workflows/scripts/install-custom-flutter.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -BRANCH=$1 -git clone https://github.com/invertase/flutter --depth 1 -b "v3.7.6" "$GITHUB_WORKSPACE/_flutter" -echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH - From 17324b0ca6677a7ded2b2c2d270ab984a2389328 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 7 Mar 2023 11:31:49 +0000 Subject: [PATCH 24/33] Delete install-melos.sh --- .github/workflows/scripts/install-melos.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 .github/workflows/scripts/install-melos.sh diff --git a/.github/workflows/scripts/install-melos.sh b/.github/workflows/scripts/install-melos.sh deleted file mode 100755 index 8e21e30b57c2..000000000000 --- a/.github/workflows/scripts/install-melos.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -flutter config --no-analytics -flutter pub global activate melos 2.4.0 -flutter pub global activate flutter_plugin_tools -echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/_flutter/.pub-cache/bin" >> $GITHUB_PATH -echo "$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH From 62492d01513a0a69e82491a11a71efdab995711a Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 7 Mar 2023 11:36:46 +0000 Subject: [PATCH 25/33] ci: revert macos workflow --- .github/workflows/e2e_tests.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e_tests.yaml b/.github/workflows/e2e_tests.yaml index 90bfdc49d509..c800ee38bbce 100644 --- a/.github/workflows/e2e_tests.yaml +++ b/.github/workflows/e2e_tests.yaml @@ -221,10 +221,14 @@ jobs: path: ~/.cache/firebase/emulators key: firebase-emulators-v1-${{ github.run_id }} restore-keys: firebase-emulators-v1 - - name: "Install Flutter" - run: ./.github/workflows/scripts/install-custom-flutter.sh stable - - name: "Install Tools" - run: ./.github/workflows/scripts/install-melos.sh + - uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d + with: + # TODO(Lyokone): upgrade to stable when https://github.com/flutter/flutter/issues/118469 is closed + flutter-version: '3.3.10' + cache: true + - uses: bluefireteam/melos-action@dd3c344d731938d2ab2567a261f54a19a68b5f6a + with: + run-bootstrap: false - name: "Bootstrap package" run: melos bootstrap --scope tests - name: "Install Tools" From 1466a89bea2ea82473c138b356972fe73c64dd04 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 7 Mar 2023 12:19:40 +0000 Subject: [PATCH 26/33] chore(messaging): allow certain iOS simulators to use actual `deviceToken` --- .../ios/Classes/FLTFirebaseMessagingPlugin.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 19be3615035e..bb7b613de9ac 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -1001,16 +1001,17 @@ - (void)ensureAPNSTokenSetting { FIRMessaging *messaging = [FIRMessaging messaging]; // With iOS SDK >= 10.4, an APNS token is required for getting/deleting token. We set a dummy - // token for the simulator for test environments. A simulator will not work for receiving messages - // so it should only be used in a CI environment. If device is running, we already set the APNS - // token below so it works as intended. + // token for the simulator for test environments. Historically, a simulator will not work for messaging. + // It will work if environment: iOS 16, running on macOS 13+ & silicon chip. We check the `_apnsToken` is nil. If it is, then the environment does not support and we set dummy token. #if TARGET_IPHONE_SIMULATOR - if (simulatorToken == false) { + if (simulatorToken == false && _apnsToken == nil) { NSString *str = @"fake-apns-token-for-simulator"; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; [[FIRMessaging messaging] setAPNSToken:data type:FIRMessagingAPNSTokenTypeSandbox]; - simulatorToken = true; } + // We set this either way. We set dummy token once as `_apnsToken` could be nil next time + // which could possibly set dummy token unnecessarily + simulatorToken = true; #endif if (messaging.APNSToken == nil && _apnsToken != nil) { From 3bba5d8961bcdf1e5204435875cdb7e9172bb864 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 7 Mar 2023 13:16:56 +0000 Subject: [PATCH 27/33] format --- .../ios/Classes/FLTFirebaseMessagingPlugin.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index 24e48a47aeec..c3937753d2bf 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -1001,8 +1001,10 @@ - (void)ensureAPNSTokenSetting { FIRMessaging *messaging = [FIRMessaging messaging]; // With iOS SDK >= 10.4, an APNS token is required for getting/deleting token. We set a dummy - // token for the simulator for test environments. Historically, a simulator will not work for messaging. - // It will work if environment: iOS 16, running on macOS 13+ & silicon chip. We check the `_apnsToken` is nil. If it is, then the environment does not support and we set dummy token. + // token for the simulator for test environments. Historically, a simulator will not work for + // messaging. It will work if environment: iOS 16, running on macOS 13+ & silicon chip. We check + // the `_apnsToken` is nil. If it is, then the environment does not support and we set dummy + // token. #if TARGET_IPHONE_SIMULATOR if (simulatorToken == false && _apnsToken == nil) { NSString *str = @"fake-apns-token-for-simulator"; From ba61a5f72a574641b6a75c666aea042d4cc6607d Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 7 Mar 2023 13:45:04 +0000 Subject: [PATCH 28/33] ci: remove test app aps entitlements for macOS --- tests/macos/Runner/DebugProfile.entitlements | 2 -- tests/macos/Runner/Release.entitlements | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/macos/Runner/DebugProfile.entitlements b/tests/macos/Runner/DebugProfile.entitlements index b76b509eebbf..3ba6c1266f21 100644 --- a/tests/macos/Runner/DebugProfile.entitlements +++ b/tests/macos/Runner/DebugProfile.entitlements @@ -2,8 +2,6 @@ - com.apple.developer.aps-environment - development com.apple.security.app-sandbox com.apple.security.cs.allow-jit diff --git a/tests/macos/Runner/Release.entitlements b/tests/macos/Runner/Release.entitlements index 39bde1896e64..ee95ab7e582d 100644 --- a/tests/macos/Runner/Release.entitlements +++ b/tests/macos/Runner/Release.entitlements @@ -2,8 +2,6 @@ - com.apple.developer.aps-environment - development com.apple.security.app-sandbox com.apple.security.network.client From 1eea3e877cff4cf8e849e2a25b9ac1e07ae5c00e Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 7 Mar 2023 14:01:14 +0000 Subject: [PATCH 29/33] ci: remove code signing team --- tests/macos/Runner.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/macos/Runner.xcodeproj/project.pbxproj b/tests/macos/Runner.xcodeproj/project.pbxproj index b1bd1e31e9ca..7ae45b4240bb 100644 --- a/tests/macos/Runner.xcodeproj/project.pbxproj +++ b/tests/macos/Runner.xcodeproj/project.pbxproj @@ -440,10 +440,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = YYX2P3XVJ7; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -568,11 +568,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = YYX2P3XVJ7; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -591,10 +591,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = YYX2P3XVJ7; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", From e307ab39cf26c9a1a4d06641945620652bf58ee5 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 8 Mar 2023 09:49:32 +0000 Subject: [PATCH 30/33] test(firebase_auth): skip macOS tests failing because of keychain sharing --- .../firebase_auth_instance_e2e_test.dart | 1459 +++++++++-------- .../firebase_auth_user_e2e_test.dart | 14 +- 2 files changed, 743 insertions(+), 730 deletions(-) diff --git a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart index c2eedf8d61cb..2bb5311974fb 100644 --- a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart +++ b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart @@ -16,854 +16,861 @@ import './test_utils.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('FirebaseAuth.instance', () { - Future commonSuccessCallback(currentUserCredential) async { - var currentUser = currentUserCredential.user; - - expect(currentUser, isInstanceOf()); - expect(currentUser.uid, isInstanceOf()); - expect(currentUser.email, equals(testEmail)); - expect(currentUser.isAnonymous, isFalse); - expect(currentUser.uid, equals(FirebaseAuth.instance.currentUser!.uid)); - - var additionalUserInfo = currentUserCredential.additionalUserInfo; - expect(additionalUserInfo, isInstanceOf()); - expect(additionalUserInfo.isNewUser, isFalse); - - await FirebaseAuth.instance.signOut(); - } - - group('authStateChanges()', () { - StreamSubscription? subscription; - StreamSubscription? subscription2; - - tearDown(() async { - await subscription?.cancel(); - await ensureSignedOut(); - - if (subscription2 != null) { - await Future.delayed(const Duration(seconds: 5)); - await subscription2.cancel(); - } - }); - - test('calls callback with the current user and when auth state changes', - () async { - await ensureSignedIn(testEmail); - String uid = FirebaseAuth.instance.currentUser!.uid; - - Stream stream = FirebaseAuth.instance.authStateChanges(); - int call = 0; - - subscription = stream.listen( - expectAsync1( - (User? user) { - call++; - if (call == 1) { - expect(user!.uid, isA()); - expect(user.uid, equals(uid)); // initial user - } else if (call == 2) { - expect(user, isNull); // logged out - } else if (call == 3) { - expect(user!.uid, isA()); - expect(user.uid != uid, isTrue); // anonymous user - } else { - fail('Should not have been called'); - } - }, - count: 3, - reason: 'Stream should only have been called 3 times', - ), - ); + group( + 'FirebaseAuth.instance', + () { + Future commonSuccessCallback(currentUserCredential) async { + var currentUser = currentUserCredential.user; + + expect(currentUser, isInstanceOf()); + expect(currentUser.uid, isInstanceOf()); + expect(currentUser.email, equals(testEmail)); + expect(currentUser.isAnonymous, isFalse); + expect(currentUser.uid, equals(FirebaseAuth.instance.currentUser!.uid)); + + var additionalUserInfo = currentUserCredential.additionalUserInfo; + expect(additionalUserInfo, isInstanceOf()); + expect(additionalUserInfo.isNewUser, isFalse); - // Prevent race condition where signOut is called before the stream hits await FirebaseAuth.instance.signOut(); - await FirebaseAuth.instance.signInAnonymously(); - }); - }); + } - group('idTokenChanges()', () { - StreamSubscription? subscription; - StreamSubscription? subscription2; + group('authStateChanges()', () { + StreamSubscription? subscription; + StreamSubscription? subscription2; - tearDown(() async { - await subscription?.cancel(); - await ensureSignedOut(); + tearDown(() async { + await subscription?.cancel(); + await ensureSignedOut(); - if (subscription2 != null) { - await Future.delayed(const Duration(seconds: 5)); - await subscription2.cancel(); - } - }); - - test('calls callback with the current user and when auth state changes', - () async { - await ensureSignedIn(testEmail); - String uid = FirebaseAuth.instance.currentUser!.uid; - - Stream stream = FirebaseAuth.instance.idTokenChanges(); - int call = 0; - - subscription = stream.listen( - expectAsync1( - (User? user) { - call++; - if (call == 1) { - expect(user!.uid, equals(uid)); // initial user - } else if (call == 2) { - expect(user, isNull); // logged out - } else if (call == 3) { - expect(user!.uid, isA()); - expect(user.uid != uid, isTrue); // anonymous user - } else { - fail('Should not have been called'); - } - }, - count: 3, - reason: 'Stream should only have been called 3 times', - ), - ); + if (subscription2 != null) { + await Future.delayed(const Duration(seconds: 5)); + await subscription2.cancel(); + } + }); - // Prevent race condition where signOut is called before the stream hits - await FirebaseAuth.instance.signOut(); - await FirebaseAuth.instance.signInAnonymously(); - }); - }); + test('calls callback with the current user and when auth state changes', + () async { + await ensureSignedIn(testEmail); + String uid = FirebaseAuth.instance.currentUser!.uid; + + Stream stream = FirebaseAuth.instance.authStateChanges(); + int call = 0; + + subscription = stream.listen( + expectAsync1( + (User? user) { + call++; + if (call == 1) { + expect(user!.uid, isA()); + expect(user.uid, equals(uid)); // initial user + } else if (call == 2) { + expect(user, isNull); // logged out + } else if (call == 3) { + expect(user!.uid, isA()); + expect(user.uid != uid, isTrue); // anonymous user + } else { + fail('Should not have been called'); + } + }, + count: 3, + reason: 'Stream should only have been called 3 times', + ), + ); - group('userChanges()', () { - late StreamSubscription subscription; - tearDown(() async { - await subscription.cancel(); + // Prevent race condition where signOut is called before the stream hits + await FirebaseAuth.instance.signOut(); + await FirebaseAuth.instance.signInAnonymously(); + }); }); - test('fires once on first initialization of FirebaseAuth', () async { - // Fixes a very specific bug: https://github.com/firebase/flutterfire/issues/3628 - // If the first initialization of FirebaseAuth involves the listeners userChanges() or idTokenChanges() - // the user will receive two events. Why? The native SDK listener will always fire an event upon initial - // listen. FirebaseAuth also sends an initial synthetic event. We send a synthetic event because, ordinarily, the user will - // not use a listener as the first occurrence of FirebaseAuth. We, therefore, mimic native behavior by sending an - // event. This test proves the logic of PR: https://github.com/firebase/flutterfire/pull/6560 - - // Requires a fresh app. - FirebaseApp second = await Firebase.initializeApp( - name: 'test-init', - options: DefaultFirebaseOptions.currentPlatform, - ); - - Stream stream = - FirebaseAuth.instanceFor(app: second).userChanges(); - - subscription = stream.listen( - expectAsync1( - (User? user) {}, - count: 1, - reason: 'Stream should only call once', - ), - ); - - await Future.delayed(const Duration(seconds: 2)); - }); + group('idTokenChanges()', () { + StreamSubscription? subscription; + StreamSubscription? subscription2; - test('calls callback with the current user and when user state changes', - () async { - await ensureSignedIn(testEmail); - - Stream stream = FirebaseAuth.instance.userChanges(); - int call = 0; - - subscription = stream.listen( - expectAsync1( - (User? user) { - call++; - if (call == 1) { - expect(user!.displayName, isNull); // initial user - } else if (call == 2) { - expect( - user!.displayName, - equals('updatedName'), - ); // updated profile - } else { - fail('Should not have been called'); - } - }, - count: 2, - reason: 'Stream should only have been called 2 times', - ), - ); + tearDown(() async { + await subscription?.cancel(); + await ensureSignedOut(); - await FirebaseAuth.instance.currentUser! - .updateDisplayName('updatedName'); + if (subscription2 != null) { + await Future.delayed(const Duration(seconds: 5)); + await subscription2.cancel(); + } + }); - expect( - FirebaseAuth.instance.currentUser!.displayName, - equals('updatedName'), - ); - }); - }); + test('calls callback with the current user and when auth state changes', + () async { + await ensureSignedIn(testEmail); + String uid = FirebaseAuth.instance.currentUser!.uid; + + Stream stream = FirebaseAuth.instance.idTokenChanges(); + int call = 0; + + subscription = stream.listen( + expectAsync1( + (User? user) { + call++; + if (call == 1) { + expect(user!.uid, equals(uid)); // initial user + } else if (call == 2) { + expect(user, isNull); // logged out + } else if (call == 3) { + expect(user!.uid, isA()); + expect(user.uid != uid, isTrue); // anonymous user + } else { + fail('Should not have been called'); + } + }, + count: 3, + reason: 'Stream should only have been called 3 times', + ), + ); - group('currentUser', () { - test('should return currentUser', () async { - await ensureSignedIn(testEmail); - var currentUser = FirebaseAuth.instance.currentUser; - expect(currentUser, isA()); - }); - }); - - group('applyActionCode', () { - test('throws if invalid code', () async { - try { - await FirebaseAuth.instance.applyActionCode('!!!!!!'); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('invalid-action-code')); - } catch (e) { - fail(e.toString()); - } - }); - }); - - group('checkActionCode()', () { - test('throws on invalid code', () async { - try { - await FirebaseAuth.instance.checkActionCode('!!!!!!'); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('invalid-action-code')); - } catch (e) { - fail(e.toString()); - } + // Prevent race condition where signOut is called before the stream hits + await FirebaseAuth.instance.signOut(); + await FirebaseAuth.instance.signInAnonymously(); + }); }); - }); - group('confirmPasswordReset()', () { - test('throws on invalid code', () async { - try { - await FirebaseAuth.instance - .confirmPasswordReset(code: '!!!!!!', newPassword: 'thingamajig'); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('invalid-action-code')); - } catch (e) { - fail(e.toString()); - } - }); - }); + group('userChanges()', () { + late StreamSubscription subscription; + tearDown(() async { + await subscription.cancel(); + }); - group('createUserWithEmailAndPassword', () { - test('should create a user with an email and password', () async { - var email = generateRandomEmail(); + test('fires once on first initialization of FirebaseAuth', () async { + // Fixes a very specific bug: https://github.com/firebase/flutterfire/issues/3628 + // If the first initialization of FirebaseAuth involves the listeners userChanges() or idTokenChanges() + // the user will receive two events. Why? The native SDK listener will always fire an event upon initial + // listen. FirebaseAuth also sends an initial synthetic event. We send a synthetic event because, ordinarily, the user will + // not use a listener as the first occurrence of FirebaseAuth. We, therefore, mimic native behavior by sending an + // event. This test proves the logic of PR: https://github.com/firebase/flutterfire/pull/6560 + + // Requires a fresh app. + FirebaseApp second = await Firebase.initializeApp( + name: 'test-init', + options: DefaultFirebaseOptions.currentPlatform, + ); - Function successCallback = (UserCredential newUserCredential) async { - expect(newUserCredential.user, isA()); - User newUser = newUserCredential.user!; + Stream stream = + FirebaseAuth.instanceFor(app: second).userChanges(); - expect(newUser.uid, isA()); - expect(newUser.email, equals(email)); - expect(newUser.emailVerified, isFalse); - expect(newUser.isAnonymous, isFalse); - expect(newUser.uid, equals(FirebaseAuth.instance.currentUser!.uid)); + subscription = stream.listen( + expectAsync1( + (User? user) {}, + count: 1, + reason: 'Stream should only call once', + ), + ); - var additionalUserInfo = newUserCredential.additionalUserInfo!; - expect(additionalUserInfo, isA()); - expect(additionalUserInfo.isNewUser, isTrue); + await Future.delayed(const Duration(seconds: 2)); + }); - await FirebaseAuth.instance.currentUser?.delete(); - }; + test('calls callback with the current user and when user state changes', + () async { + await ensureSignedIn(testEmail); + + Stream stream = FirebaseAuth.instance.userChanges(); + int call = 0; + + subscription = stream.listen( + expectAsync1( + (User? user) { + call++; + if (call == 1) { + expect(user!.displayName, isNull); // initial user + } else if (call == 2) { + expect( + user!.displayName, + equals('updatedName'), + ); // updated profile + } else { + fail('Should not have been called'); + } + }, + count: 2, + reason: 'Stream should only have been called 2 times', + ), + ); - await FirebaseAuth.instance - .createUserWithEmailAndPassword( - email: email, - password: testPassword, - ) - .then(successCallback as Function(UserCredential)); - }); + await FirebaseAuth.instance.currentUser! + .updateDisplayName('updatedName'); - test('fails if creating a user which already exists', () async { - await ensureSignedIn(testEmail); - try { - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: testEmail, - password: '123456', + expect( + FirebaseAuth.instance.currentUser!.displayName, + equals('updatedName'), ); - fail('Should have thrown FirebaseAuthException'); - } on FirebaseAuthException catch (e) { - expect(e.code, equals('email-already-in-use')); - } catch (e) { - fail(e.toString()); - } + }); }); - test('fails if creating a user with an invalid email', () async { - await ensureSignedIn(testEmail); - try { - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: '!!!!!', - password: '123456', - ); - fail('Should have thrown FirebaseAuthException'); - } on FirebaseAuthException catch (e) { - expect(e.code, equals('invalid-email')); - } catch (e) { - fail(e.toString()); - } + group('currentUser', () { + test('should return currentUser', () async { + await ensureSignedIn(testEmail); + var currentUser = FirebaseAuth.instance.currentUser; + expect(currentUser, isA()); + }); }); - test('fails if creating a user if providing a weak password', () async { - await ensureSignedIn(testEmail); - try { - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: generateRandomEmail(), - password: '1', - ); - fail('Should have thrown FirebaseAuthException'); - } on FirebaseAuthException catch (e) { - expect(e.code, equals('weak-password')); - } catch (e) { - fail(e.toString()); - } - }); - }); - - group('fetchSignInMethodsForEmail()', () { - test('should return password provider for an email address', () async { - var providers = - await FirebaseAuth.instance.fetchSignInMethodsForEmail(testEmail); - expect(providers, isList); - expect(providers.contains('password'), isTrue); + group('applyActionCode', () { + test('throws if invalid code', () async { + try { + await FirebaseAuth.instance.applyActionCode('!!!!!!'); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('invalid-action-code')); + } catch (e) { + fail(e.toString()); + } + }); }); - test('should return empty array for a not found email', () async { - var providers = await FirebaseAuth.instance - .fetchSignInMethodsForEmail(generateRandomEmail()); - - expect(providers, isList); - expect(providers, isEmpty); + group('checkActionCode()', () { + test('throws on invalid code', () async { + try { + await FirebaseAuth.instance.checkActionCode('!!!!!!'); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('invalid-action-code')); + } catch (e) { + fail(e.toString()); + } + }); }); - test('throws for a bad email address', () async { - try { - await FirebaseAuth.instance.fetchSignInMethodsForEmail('foobar'); - fail('Should have thrown'); - } on FirebaseAuthException catch (e) { - expect(e.code, equals('invalid-email')); - } catch (e) { - fail(e.toString()); - } - }); - }); - - group('isSignInWithEmailLink()', () { - test('should return true or false', () { - const emailLink1 = - 'https://www.example.com/action?mode=signIn&oobCode=oobCode'; - const emailLink2 = - 'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode'; - const emailLink3 = 'https://www.example.com/action?mode=signIn'; - const emailLink4 = - 'https://x59dg.app.goo.gl/?link=https://rnfirebase-b9ad4.firebaseapp.com/__/auth/action?apiKey%3Dfoo%26mode%3DsignIn%26oobCode%3Dbar'; - - expect( - FirebaseAuth.instance.isSignInWithEmailLink(emailLink1), - equals(true), - ); - expect( - FirebaseAuth.instance.isSignInWithEmailLink(emailLink2), - equals(false), - ); - expect( - FirebaseAuth.instance.isSignInWithEmailLink(emailLink3), - equals(false), - ); - expect( - FirebaseAuth.instance.isSignInWithEmailLink(emailLink4), - equals(true), - ); + group('confirmPasswordReset()', () { + test('throws on invalid code', () async { + try { + await FirebaseAuth.instance.confirmPasswordReset( + code: '!!!!!!', newPassword: 'thingamajig'); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('invalid-action-code')); + } catch (e) { + fail(e.toString()); + } + }); }); - }); - group('sendPasswordResetEmail()', () { - test('should not error', () async { - var email = generateRandomEmail(); + group('createUserWithEmailAndPassword', () { + test('should create a user with an email and password', () async { + var email = generateRandomEmail(); - try { - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: email, - password: testPassword, - ); + Function successCallback = (UserCredential newUserCredential) async { + expect(newUserCredential.user, isA()); + User newUser = newUserCredential.user!; - await FirebaseAuth.instance.sendPasswordResetEmail(email: email); - await FirebaseAuth.instance.currentUser!.delete(); - } catch (e) { - await FirebaseAuth.instance.currentUser!.delete(); - fail(e.toString()); - } - }); + expect(newUser.uid, isA()); + expect(newUser.email, equals(email)); + expect(newUser.emailVerified, isFalse); + expect(newUser.isAnonymous, isFalse); + expect(newUser.uid, equals(FirebaseAuth.instance.currentUser!.uid)); - test('fails if the user could not be found', () async { - try { - await FirebaseAuth.instance - .sendPasswordResetEmail(email: 'does-not-exist@bar.com'); - fail('Should have thrown'); - } on FirebaseAuthException catch (e) { - expect(e.code, equals('user-not-found')); - } catch (e) { - fail(e.toString()); - } - }); - }); + var additionalUserInfo = newUserCredential.additionalUserInfo!; + expect(additionalUserInfo, isA()); + expect(additionalUserInfo.isNewUser, isTrue); - group('sendSignInLinkToEmail()', () { - test('should send email successfully', () async { - const email = 'email-signin-test@example.com'; - const continueUrl = 'http://action-code-test.com'; + await FirebaseAuth.instance.currentUser?.delete(); + }; - await FirebaseAuth.instance.createUserWithEmailAndPassword( - email: email, - password: testPassword, - ); + await FirebaseAuth.instance + .createUserWithEmailAndPassword( + email: email, + password: testPassword, + ) + .then(successCallback as Function(UserCredential)); + }); - final actionCodeSettings = ActionCodeSettings( - url: continueUrl, - handleCodeInApp: true, - ); + test('fails if creating a user which already exists', () async { + await ensureSignedIn(testEmail); + try { + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: testEmail, + password: '123456', + ); + fail('Should have thrown FirebaseAuthException'); + } on FirebaseAuthException catch (e) { + expect(e.code, equals('email-already-in-use')); + } catch (e) { + fail(e.toString()); + } + }); - await FirebaseAuth.instance.sendSignInLinkToEmail( - email: email, - actionCodeSettings: actionCodeSettings, - ); + test('fails if creating a user with an invalid email', () async { + await ensureSignedIn(testEmail); + try { + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: '!!!!!', + password: '123456', + ); + fail('Should have thrown FirebaseAuthException'); + } on FirebaseAuthException catch (e) { + expect(e.code, equals('invalid-email')); + } catch (e) { + fail(e.toString()); + } + }); - // Confirm with the emulator that it triggered an email sending code. - final oobCode = (await emulatorOutOfBandCode( - email, - EmulatorOobCodeType.emailSignIn, - ))!; - expect(oobCode, isNotNull); - expect(oobCode.email, email); - expect(oobCode.type, EmulatorOobCodeType.emailSignIn); - - // Confirm the continue url was passed through to backend correctly. - final url = Uri.parse(oobCode.oobLink!); - expect(url.queryParameters['continueUrl'], Uri.encodeFull(continueUrl)); + test('fails if creating a user if providing a weak password', () async { + await ensureSignedIn(testEmail); + try { + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: generateRandomEmail(), + password: '1', + ); + fail('Should have thrown FirebaseAuthException'); + } on FirebaseAuthException catch (e) { + expect(e.code, equals('weak-password')); + } catch (e) { + fail(e.toString()); + } + }); }); - }); - group('languageCode', () { - test('should change the language code', () async { - await FirebaseAuth.instance.setLanguageCode('en'); + group('fetchSignInMethodsForEmail()', () { + test('should return password provider for an email address', () async { + var providers = + await FirebaseAuth.instance.fetchSignInMethodsForEmail(testEmail); + expect(providers, isList); + expect(providers.contains('password'), isTrue); + }); + + test('should return empty array for a not found email', () async { + var providers = await FirebaseAuth.instance + .fetchSignInMethodsForEmail(generateRandomEmail()); + + expect(providers, isList); + expect(providers, isEmpty); + }); - expect(FirebaseAuth.instance.languageCode, equals('en')); + test('throws for a bad email address', () async { + try { + await FirebaseAuth.instance.fetchSignInMethodsForEmail('foobar'); + fail('Should have thrown'); + } on FirebaseAuthException catch (e) { + expect(e.code, equals('invalid-email')); + } catch (e) { + fail(e.toString()); + } + }); }); - test( - 'should allow null value and default the device language code', - () async { - await FirebaseAuth.instance.setLanguageCode(null); + group('isSignInWithEmailLink()', () { + test('should return true or false', () { + const emailLink1 = + 'https://www.example.com/action?mode=signIn&oobCode=oobCode'; + const emailLink2 = + 'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode'; + const emailLink3 = 'https://www.example.com/action?mode=signIn'; + const emailLink4 = + 'https://x59dg.app.goo.gl/?link=https://rnfirebase-b9ad4.firebaseapp.com/__/auth/action?apiKey%3Dfoo%26mode%3DsignIn%26oobCode%3Dbar'; expect( - FirebaseAuth.instance.languageCode, - isNotNull, - ); // default to the device language or the Firebase projects default language - }, - skip: kIsWeb, - ); - - test( - 'should allow null value and set to null', - () async { - await FirebaseAuth.instance.setLanguageCode(null); + FirebaseAuth.instance.isSignInWithEmailLink(emailLink1), + equals(true), + ); + expect( + FirebaseAuth.instance.isSignInWithEmailLink(emailLink2), + equals(false), + ); + expect( + FirebaseAuth.instance.isSignInWithEmailLink(emailLink3), + equals(false), + ); + expect( + FirebaseAuth.instance.isSignInWithEmailLink(emailLink4), + equals(true), + ); + }); + }); - expect(FirebaseAuth.instance.languageCode, null); - }, - skip: !kIsWeb, - ); - }); + group('sendPasswordResetEmail()', () { + test('should not error', () async { + var email = generateRandomEmail(); - group('setPersistence()', () { - test( - 'throw an unimplemented error', - () async { try { - await FirebaseAuth.instance.setPersistence(Persistence.LOCAL); - fail('Should have thrown'); + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: email, + password: testPassword, + ); + + await FirebaseAuth.instance.sendPasswordResetEmail(email: email); + await FirebaseAuth.instance.currentUser!.delete(); } catch (e) { - expect(e, isInstanceOf()); + await FirebaseAuth.instance.currentUser!.delete(); + fail(e.toString()); } - }, - skip: kIsWeb, - ); + }); - test( - 'should set persistence', - () async { + test('fails if the user could not be found', () async { try { - await FirebaseAuth.instance.setPersistence(Persistence.LOCAL); + await FirebaseAuth.instance + .sendPasswordResetEmail(email: 'does-not-exist@bar.com'); + fail('Should have thrown'); + } on FirebaseAuthException catch (e) { + expect(e.code, equals('user-not-found')); } catch (e) { - fail('unexpected error thrown'); + fail(e.toString()); } - }, - skip: !kIsWeb, - ); - }); + }); + }); - group('signInAnonymously()', () { - test('should sign in anonymously', () async { - Future successCallback(UserCredential currentUserCredential) async { - var currentUser = currentUserCredential.user!; + group('sendSignInLinkToEmail()', () { + test('should send email successfully', () async { + const email = 'email-signin-test@example.com'; + const continueUrl = 'http://action-code-test.com'; - expect(currentUser, isA()); - expect(currentUser.uid, isA()); - expect(currentUser.email, isNull); - expect(currentUser.isAnonymous, isTrue); - expect( - currentUser.uid, - equals(FirebaseAuth.instance.currentUser!.uid), + await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: email, + password: testPassword, ); - var additionalUserInfo = currentUserCredential.additionalUserInfo; - expect(additionalUserInfo, isInstanceOf()); + final actionCodeSettings = ActionCodeSettings( + url: continueUrl, + handleCodeInApp: true, + ); - await FirebaseAuth.instance.signOut(); - } + await FirebaseAuth.instance.sendSignInLinkToEmail( + email: email, + actionCodeSettings: actionCodeSettings, + ); - final userCred = await FirebaseAuth.instance.signInAnonymously(); - await successCallback(userCred); + // Confirm with the emulator that it triggered an email sending code. + final oobCode = (await emulatorOutOfBandCode( + email, + EmulatorOobCodeType.emailSignIn, + ))!; + expect(oobCode, isNotNull); + expect(oobCode.email, email); + expect(oobCode.type, EmulatorOobCodeType.emailSignIn); + + // Confirm the continue url was passed through to backend correctly. + final url = Uri.parse(oobCode.oobLink!); + expect( + url.queryParameters['continueUrl'], Uri.encodeFull(continueUrl)); + }); }); - }); - group('signInWithCredential()', () { - test('should login with email and password', () async { - var credential = EmailAuthProvider.credential( - email: testEmail, - password: testPassword, - ); - await FirebaseAuth.instance - .signInWithCredential(credential) - .then(commonSuccessCallback); - }); + group('languageCode', () { + test('should change the language code', () async { + await FirebaseAuth.instance.setLanguageCode('en'); - test('throws if login user is disabled', () async { - var credential = EmailAuthProvider.credential( - email: testDisabledEmail, - password: testPassword, - ); + expect(FirebaseAuth.instance.languageCode, equals('en')); + }); - try { - await FirebaseAuth.instance.signInWithCredential(credential); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('user-disabled')); - expect( - e.message, - equals( - 'The user account has been disabled by an administrator.', - ), - ); - } catch (e) { - fail(e.toString()); - } - }); + test( + 'should allow null value and default the device language code', + () async { + await FirebaseAuth.instance.setLanguageCode(null); - test('throws if login password is incorrect', () async { - var credential = - EmailAuthProvider.credential(email: testEmail, password: 'sowrong'); - try { - await FirebaseAuth.instance.signInWithCredential(credential); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('wrong-password')); - expect( - e.message, - equals( - 'The password is invalid or the user does not have a password.', - ), - ); - } catch (e) { - fail(e.toString()); - } - }); + expect( + FirebaseAuth.instance.languageCode, + isNotNull, + ); // default to the device language or the Firebase projects default language + }, + skip: kIsWeb || defaultTargetPlatform == TargetPlatform.macOS, + ); + + test( + 'should allow null value and set to null', + () async { + await FirebaseAuth.instance.setLanguageCode(null); - test('throws if login user is not found', () async { - var credential = EmailAuthProvider.credential( - email: generateRandomEmail(), - password: testPassword, + expect(FirebaseAuth.instance.languageCode, null); + }, + skip: !kIsWeb, ); - try { - await FirebaseAuth.instance.signInWithCredential(credential); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('user-not-found')); - expect( - e.message, - equals( - 'There is no user record corresponding to this identifier. The user may have been deleted.', - ), - ); - } catch (e) { - fail(e.toString()); - } }); - }); - - group('signInWithCustomToken()', () { - test('signs in with custom auth token', () async { - final userCredential = await FirebaseAuth.instance.signInAnonymously(); - final uid = userCredential.user!.uid; - final claims = { - 'roles': [ - {'role': 'member'}, - {'role': 'admin'} - ] - }; - await ensureSignedOut(); + group('setPersistence()', () { + test( + 'throw an unimplemented error', + () async { + try { + await FirebaseAuth.instance.setPersistence(Persistence.LOCAL); + fail('Should have thrown'); + } catch (e) { + expect(e, isInstanceOf()); + } + }, + skip: kIsWeb || defaultTargetPlatform == TargetPlatform.macOS, + ); - expect(FirebaseAuth.instance.currentUser, null); + test( + 'should set persistence', + () async { + try { + await FirebaseAuth.instance.setPersistence(Persistence.LOCAL); + } catch (e) { + fail('unexpected error thrown'); + } + }, + skip: !kIsWeb, + ); + }); - final customToken = emulatorCreateCustomToken(uid, claims: claims); + group('signInAnonymously()', () { + test('should sign in anonymously', () async { + Future successCallback(UserCredential currentUserCredential) async { + var currentUser = currentUserCredential.user!; - final customTokenUserCredential = - await FirebaseAuth.instance.signInWithCustomToken(customToken); + expect(currentUser, isA()); + expect(currentUser.uid, isA()); + expect(currentUser.email, isNull); + expect(currentUser.isAnonymous, isTrue); + expect( + currentUser.uid, + equals(FirebaseAuth.instance.currentUser!.uid), + ); - expect(customTokenUserCredential.user!.uid, equals(uid)); - expect(FirebaseAuth.instance.currentUser!.uid, equals(uid)); + var additionalUserInfo = currentUserCredential.additionalUserInfo; + expect(additionalUserInfo, isInstanceOf()); - final idTokenResult = - await FirebaseAuth.instance.currentUser!.getIdTokenResult(); + await FirebaseAuth.instance.signOut(); + } - expect(idTokenResult.claims!['roles'], isA()); - expect(idTokenResult.claims!['roles'][0], isA()); - expect(idTokenResult.claims!['roles'][0]['role'], 'member'); + final userCred = await FirebaseAuth.instance.signInAnonymously(); + await successCallback(userCred); + }); }); - }); - group('signInWithEmailAndPassword()', () { - test('should login with email and password', () async { - await FirebaseAuth.instance - .signInWithEmailAndPassword( - email: testEmail, - password: testPassword, - ) - .then(commonSuccessCallback); - }); + group('signInWithCredential()', () { + test('should login with email and password', () async { + var credential = EmailAuthProvider.credential( + email: testEmail, + password: testPassword, + ); + await FirebaseAuth.instance + .signInWithCredential(credential) + .then(commonSuccessCallback); + }); - test('throws if login user is disabled', () async { - try { - await FirebaseAuth.instance.signInWithEmailAndPassword( + test('throws if login user is disabled', () async { + var credential = EmailAuthProvider.credential( email: testDisabledEmail, password: testPassword, ); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('user-disabled')); - expect( - e.message, - equals( - 'The user account has been disabled by an administrator.', - ), - ); - } catch (e) { - fail(e.toString()); - } - }); - test('throws if login password is incorrect', () async { - try { - await FirebaseAuth.instance.signInWithEmailAndPassword( - email: testEmail, - password: 'sowrong', - ); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('wrong-password')); - expect( - e.message, - equals( - 'The password is invalid or the user does not have a password.', - ), - ); - } catch (e) { - fail(e.toString()); - } - }); + try { + await FirebaseAuth.instance.signInWithCredential(credential); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('user-disabled')); + expect( + e.message, + equals( + 'The user account has been disabled by an administrator.', + ), + ); + } catch (e) { + fail(e.toString()); + } + }); + + test('throws if login password is incorrect', () async { + var credential = EmailAuthProvider.credential( + email: testEmail, password: 'sowrong'); + try { + await FirebaseAuth.instance.signInWithCredential(credential); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('wrong-password')); + expect( + e.message, + equals( + 'The password is invalid or the user does not have a password.', + ), + ); + } catch (e) { + fail(e.toString()); + } + }); - test('throws if login user is not found', () async { - try { - await FirebaseAuth.instance.signInWithEmailAndPassword( + test('throws if login user is not found', () async { + var credential = EmailAuthProvider.credential( email: generateRandomEmail(), password: testPassword, ); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('user-not-found')); - expect( - e.message, - equals( - 'There is no user record corresponding to this identifier. The user may have been deleted.', - ), - ); - } catch (e) { - fail(e.toString()); - } + try { + await FirebaseAuth.instance.signInWithCredential(credential); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('user-not-found')); + expect( + e.message, + equals( + 'There is no user record corresponding to this identifier. The user may have been deleted.', + ), + ); + } catch (e) { + fail(e.toString()); + } + }); }); - }); - group('signOut()', () { - test('should sign out', () async { - await ensureSignedIn(testEmail); - expect(FirebaseAuth.instance.currentUser, isA()); - await FirebaseAuth.instance.signOut(); - expect(FirebaseAuth.instance.currentUser, isNull); - }); - }); - - group('verifyPasswordResetCode()', () { - test('throws on invalid code', () async { - try { - await FirebaseAuth.instance.verifyPasswordResetCode('!!!!!!'); - fail('Should have thrown'); - } on FirebaseException catch (e) { - expect(e.code, equals('invalid-action-code')); - } catch (e) { - fail(e.toString()); - } + group('signInWithCustomToken()', () { + test('signs in with custom auth token', () async { + final userCredential = + await FirebaseAuth.instance.signInAnonymously(); + final uid = userCredential.user!.uid; + final claims = { + 'roles': [ + {'role': 'member'}, + {'role': 'admin'} + ] + }; + + await ensureSignedOut(); + + expect(FirebaseAuth.instance.currentUser, null); + + final customToken = emulatorCreateCustomToken(uid, claims: claims); + + final customTokenUserCredential = + await FirebaseAuth.instance.signInWithCustomToken(customToken); + + expect(customTokenUserCredential.user!.uid, equals(uid)); + expect(FirebaseAuth.instance.currentUser!.uid, equals(uid)); + + final idTokenResult = + await FirebaseAuth.instance.currentUser!.getIdTokenResult(); + + expect(idTokenResult.claims!['roles'], isA()); + expect(idTokenResult.claims!['roles'][0], isA()); + expect(idTokenResult.claims!['roles'][0]['role'], 'member'); + }); }); - }); - - group( - 'verifyPhoneNumber()', - () { - test('should fail with an invalid phone number', () async { - Future getError() async { - Completer completer = Completer(); - - unawaited( - FirebaseAuth.instance.verifyPhoneNumber( - phoneNumber: 'foo', - verificationCompleted: (PhoneAuthCredential credential) { - return completer - .completeError(Exception('Should not have been called')); - }, - verificationFailed: (FirebaseAuthException e) { - completer.complete(e); - }, - codeSent: (String verificationId, int? resetToken) { - return completer - .completeError(Exception('Should not have been called')); - }, - codeAutoRetrievalTimeout: (String foo) { - return completer - .completeError(Exception('Should not have been called')); - }, + + group('signInWithEmailAndPassword()', () { + test('should login with email and password', () async { + await FirebaseAuth.instance + .signInWithEmailAndPassword( + email: testEmail, + password: testPassword, + ) + .then(commonSuccessCallback); + }); + + test('throws if login user is disabled', () async { + try { + await FirebaseAuth.instance.signInWithEmailAndPassword( + email: testDisabledEmail, + password: testPassword, + ); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('user-disabled')); + expect( + e.message, + equals( + 'The user account has been disabled by an administrator.', ), ); + } catch (e) { + fail(e.toString()); + } + }); - return completer.future as FutureOr; + test('throws if login password is incorrect', () async { + try { + await FirebaseAuth.instance.signInWithEmailAndPassword( + email: testEmail, + password: 'sowrong', + ); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('wrong-password')); + expect( + e.message, + equals( + 'The password is invalid or the user does not have a password.', + ), + ); + } catch (e) { + fail(e.toString()); } + }); - Exception e = await getError(); - expect(e, isA()); + test('throws if login user is not found', () async { + try { + await FirebaseAuth.instance.signInWithEmailAndPassword( + email: generateRandomEmail(), + password: testPassword, + ); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('user-not-found')); + expect( + e.message, + equals( + 'There is no user record corresponding to this identifier. The user may have been deleted.', + ), + ); + } catch (e) { + fail(e.toString()); + } + }); + }); - FirebaseAuthException exception = e as FirebaseAuthException; - expect(exception.code, equals('invalid-phone-number')); + group('signOut()', () { + test('should sign out', () async { + await ensureSignedIn(testEmail); + expect(FirebaseAuth.instance.currentUser, isA()); + await FirebaseAuth.instance.signOut(); + expect(FirebaseAuth.instance.currentUser, isNull); }); + }); - test( - 'should auto verify phone number', - () async { - String testPhoneNumber = '+447444555666'; - String testSmsCode = '123456'; - await FirebaseAuth.instance.signInAnonymously(); + group('verifyPasswordResetCode()', () { + test('throws on invalid code', () async { + try { + await FirebaseAuth.instance.verifyPasswordResetCode('!!!!!!'); + fail('Should have thrown'); + } on FirebaseException catch (e) { + expect(e.code, equals('invalid-action-code')); + } catch (e) { + fail(e.toString()); + } + }); + }); - Future getCredential() async { - Completer completer = Completer(); + group( + 'verifyPhoneNumber()', + () { + test('should fail with an invalid phone number', () async { + Future getError() async { + Completer completer = Completer(); unawaited( FirebaseAuth.instance.verifyPhoneNumber( - phoneNumber: testPhoneNumber, - // ignore: invalid_use_of_visible_for_testing_member - autoRetrievedSmsCodeForTesting: testSmsCode, + phoneNumber: 'foo', verificationCompleted: (PhoneAuthCredential credential) { - if (credential.smsCode != testSmsCode) { - return completer - .completeError(Exception('SMS code did not match')); - } - - completer.complete(credential); - }, - verificationFailed: (FirebaseException e) { return completer.completeError( - Exception('Should not have been called'), - ); + Exception('Should not have been called')); + }, + verificationFailed: (FirebaseAuthException e) { + completer.complete(e); }, codeSent: (String verificationId, int? resetToken) { return completer.completeError( - Exception('Should not have been called'), - ); + Exception('Should not have been called')); }, codeAutoRetrievalTimeout: (String foo) { return completer.completeError( - Exception('Should not have been called'), - ); + Exception('Should not have been called')); }, ), ); - return completer.future as FutureOr; + return completer.future as FutureOr; } - PhoneAuthCredential credential = await getCredential(); - expect(credential, isA()); + Exception e = await getError(); + expect(e, isA()); + + FirebaseAuthException exception = e as FirebaseAuthException; + expect(exception.code, equals('invalid-phone-number')); + }); + + test( + 'should auto verify phone number', + () async { + String testPhoneNumber = '+447444555666'; + String testSmsCode = '123456'; + await FirebaseAuth.instance.signInAnonymously(); + + Future getCredential() async { + Completer completer = Completer(); + + unawaited( + FirebaseAuth.instance.verifyPhoneNumber( + phoneNumber: testPhoneNumber, + // ignore: invalid_use_of_visible_for_testing_member + autoRetrievedSmsCodeForTesting: testSmsCode, + verificationCompleted: (PhoneAuthCredential credential) { + if (credential.smsCode != testSmsCode) { + return completer + .completeError(Exception('SMS code did not match')); + } + + completer.complete(credential); + }, + verificationFailed: (FirebaseException e) { + return completer.completeError( + Exception('Should not have been called'), + ); + }, + codeSent: (String verificationId, int? resetToken) { + return completer.completeError( + Exception('Should not have been called'), + ); + }, + codeAutoRetrievalTimeout: (String foo) { + return completer.completeError( + Exception('Should not have been called'), + ); + }, + ), + ); + + return completer.future as FutureOr; + } + + PhoneAuthCredential credential = await getCredential(); + expect(credential, isA()); + }, + skip: kIsWeb || defaultTargetPlatform != TargetPlatform.android, + ); + }, + skip: defaultTargetPlatform == TargetPlatform.macOS || kIsWeb, + ); + + group('setSettings()', () { + test( + 'throws argument error if phoneNumber & smsCode have not been set simultaneously', + () async { + String message = + "The [smsCode] and the [phoneNumber] must both be either 'null' or a 'String''."; + await expectLater( + FirebaseAuth.instance.setSettings(phoneNumber: '123456'), + throwsA( + isA() + .having((e) => e.message, 'message', contains(message)), + ), + ); + + await expectLater( + FirebaseAuth.instance.setSettings(smsCode: '123456'), + throwsA( + isA() + .having((e) => e.message, 'message', contains(message)), + ), + ); }, skip: kIsWeb || defaultTargetPlatform != TargetPlatform.android, ); - }, - skip: defaultTargetPlatform == TargetPlatform.macOS || kIsWeb, - ); - - group('setSettings()', () { - test( - 'throws argument error if phoneNumber & smsCode have not been set simultaneously', - () async { - String message = - "The [smsCode] and the [phoneNumber] must both be either 'null' or a 'String''."; - await expectLater( - FirebaseAuth.instance.setSettings(phoneNumber: '123456'), - throwsA( - isA() - .having((e) => e.message, 'message', contains(message)), - ), - ); + }); - await expectLater( - FirebaseAuth.instance.setSettings(smsCode: '123456'), - throwsA( - isA() - .having((e) => e.message, 'message', contains(message)), - ), - ); + group( + 'tenantId', + () { + test('User associated with the tenantId correctly', () async { + // tenantId created in the GCP console + const String tenantId = 'auth-tenant-test-xukxg'; + // created User on GCP console associated with the above tenantId + final userCredential = + await FirebaseAuth.instance.signInWithEmailAndPassword( + email: 'test-tenant@email.com', + password: 'fake-password', + ); + + expect(userCredential.user!.tenantId, tenantId); + }); + // todo(russellwheatley85): get/set tenantId and authenticating user via auth emulator is not possible at the moment. }, - skip: kIsWeb || defaultTargetPlatform != TargetPlatform.android, + skip: true, ); - }); - - group( - 'tenantId', - () { - test('User associated with the tenantId correctly', () async { - // tenantId created in the GCP console - const String tenantId = 'auth-tenant-test-xukxg'; - // created User on GCP console associated with the above tenantId - final userCredential = - await FirebaseAuth.instance.signInWithEmailAndPassword( - email: 'test-tenant@email.com', - password: 'fake-password', - ); - - expect(userCredential.user!.tenantId, tenantId); - }); - // todo(russellwheatley85): get/set tenantId and authenticating user via auth emulator is not possible at the moment. - }, - skip: true, - ); - }); + }, + // macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538 + skip: defaultTargetPlatform == TargetPlatform.macOS, + ); } diff --git a/tests/integration_test/firebase_auth/firebase_auth_user_e2e_test.dart b/tests/integration_test/firebase_auth/firebase_auth_user_e2e_test.dart index 8f63772fad0e..f97277056d85 100644 --- a/tests/integration_test/firebase_auth/firebase_auth_user_e2e_test.dart +++ b/tests/integration_test/firebase_auth/firebase_auth_user_e2e_test.dart @@ -437,7 +437,8 @@ void main() { } expect(FirebaseAuth.instance.currentUser, isNotNull); }, - skip: kIsWeb, + // macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538 + skip: kIsWeb || defaultTargetPlatform == TargetPlatform.macOS, ); }); @@ -593,7 +594,8 @@ void main() { ); expect(FirebaseAuth.instance.currentUser!.refreshToken, equals('')); }, - skip: kIsWeb, + // macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538 + skip: kIsWeb || defaultTargetPlatform == TargetPlatform.macOS, ); test( @@ -780,7 +782,8 @@ void main() { ); }, // setting `photoURL` on web throws an error - skip: kIsWeb, + // macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538 + skip: kIsWeb || defaultTargetPlatform == TargetPlatform.macOS, ); }); @@ -1000,5 +1003,8 @@ void main() { fail('Should have thrown an error'); }); }); - }); + }, + // macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538 + skip: defaultTargetPlatform == TargetPlatform.macOS, + ); } From 670d31840ab3ab444fd82011e086df0ed17d31eb Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 8 Mar 2023 10:04:10 +0000 Subject: [PATCH 31/33] fix analyze issues --- .../firebase_auth_instance_e2e_test.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart index 2bb5311974fb..52fb6534a86d 100644 --- a/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart +++ b/tests/integration_test/firebase_auth/firebase_auth_instance_e2e_test.dart @@ -241,7 +241,8 @@ void main() { test('throws on invalid code', () async { try { await FirebaseAuth.instance.confirmPasswordReset( - code: '!!!!!!', newPassword: 'thingamajig'); + code: '!!!!!!', newPassword: 'thingamajig', + ); fail('Should have thrown'); } on FirebaseException catch (e) { expect(e.code, equals('invalid-action-code')); @@ -446,7 +447,8 @@ void main() { // Confirm the continue url was passed through to backend correctly. final url = Uri.parse(oobCode.oobLink!); expect( - url.queryParameters['continueUrl'], Uri.encodeFull(continueUrl)); + url.queryParameters['continueUrl'], Uri.encodeFull(continueUrl), + ); }); }); @@ -568,7 +570,8 @@ void main() { test('throws if login password is incorrect', () async { var credential = EmailAuthProvider.credential( - email: testEmail, password: 'sowrong'); + email: testEmail, password: 'sowrong', + ); try { await FirebaseAuth.instance.signInWithCredential(credential); fail('Should have thrown'); @@ -745,18 +748,21 @@ void main() { phoneNumber: 'foo', verificationCompleted: (PhoneAuthCredential credential) { return completer.completeError( - Exception('Should not have been called')); + Exception('Should not have been called'), + ); }, verificationFailed: (FirebaseAuthException e) { completer.complete(e); }, codeSent: (String verificationId, int? resetToken) { return completer.completeError( - Exception('Should not have been called')); + Exception('Should not have been called'), + ); }, codeAutoRetrievalTimeout: (String foo) { return completer.completeError( - Exception('Should not have been called')); + Exception('Should not have been called'), + ); }, ), ); From 7037ca627f3ebbe7bee65ba98a1c6ea8569840c1 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 8 Mar 2023 10:38:37 +0000 Subject: [PATCH 32/33] test: skip e2e test for android --- .../firebase_messaging/firebase_messaging_e2e_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart index 8dc7ccad2ef6..248fc244e4db 100644 --- a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart +++ b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart @@ -128,7 +128,7 @@ void main() { expect(await messaging.getAPNSToken(), isA()); }, skip: !(defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform != TargetPlatform.macOS), + defaultTargetPlatform == TargetPlatform.macOS), ); }); From 597d11698ce570bb1a3225bd00c3eb1e091cfd0e Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 8 Mar 2023 10:57:08 +0000 Subject: [PATCH 33/33] test: skip e2e test for macOS. iOS only. --- .../firebase_messaging/firebase_messaging_e2e_test.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart index 248fc244e4db..3b40eecf1b39 100644 --- a/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart +++ b/tests/integration_test/firebase_messaging/firebase_messaging_e2e_test.dart @@ -127,8 +127,7 @@ void main() { () async { expect(await messaging.getAPNSToken(), isA()); }, - skip: !(defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS), + skip: defaultTargetPlatform != TargetPlatform.iOS, ); });