From 70c8a264d2211fdd8eaa09c6f4d41367f4f59421 Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Mon, 15 Jan 2024 17:35:37 -0300 Subject: [PATCH 1/6] PM-3350 PM-3349 Enable running Core tests --- .github/workflows/build.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee1088cd37..26d34e22a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,17 +153,17 @@ jobs: # - name: Verify Format # run: dotnet tool run dotnet-format --check - # - name: Run Core tests - # run: dotnet test test/Core.Test/Core.Test.csproj --logger "trx;LogFileName=test-results.trx" + - name: Run Core tests + run: dotnet test test/Core.Test/Core.Test.csproj --logger "trx;LogFileName=test-results.trx" /p:CustomConstants=UT - #- name: Report test results - # uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 - # if: always() - # with: - # name: Test Results - # path: "**/test-results.trx" - # reporter: dotnet-trx - # fail-on-error: true + - name: Report test results + uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 + if: always() + with: + name: Test Results + path: "**/test-results.trx" + reporter: dotnet-trx + fail-on-error: true - name: Build Play Store publisher if: ${{ matrix.variant == 'prod' }} From 6b7c6eac71f950cf6b8237040042f63d6df23363 Mon Sep 17 00:00:00 2001 From: Daniel James Smith <2670567+djsmith85@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:49:40 +0100 Subject: [PATCH 2/6] Import-link routes to import page after login (#2937) Co-authored-by: Daniel James Smith --- src/App/Pages/Settings/VaultSettingsPageViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/Pages/Settings/VaultSettingsPageViewModel.cs b/src/App/Pages/Settings/VaultSettingsPageViewModel.cs index 6969a8133c..3afdba9298 100644 --- a/src/App/Pages/Settings/VaultSettingsPageViewModel.cs +++ b/src/App/Pages/Settings/VaultSettingsPageViewModel.cs @@ -40,7 +40,7 @@ namespace Bit.App.Pages private async Task GoToImportItemsAsync() { - var webVaultUrl = _environmentService.GetWebVaultUrl(); + var webVaultUrl = _environmentService.GetWebVaultUrl() + "/#/tools/import"; var body = string.Format(AppResources.YouCanImportDataToYourVaultOnX, webVaultUrl); if (await _platformUtilsService.ShowDialogAsync(body, AppResources.ContinueToWebApp, AppResources.Continue, AppResources.Cancel)) { From 0a5d77288686eba1245edb276de320b75af3789f Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Tue, 16 Jan 2024 11:32:27 -0300 Subject: [PATCH 3/6] PM-3350 Fix build.yml format --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26d34e22a7..fe6f6a1768 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -157,13 +157,13 @@ jobs: run: dotnet test test/Core.Test/Core.Test.csproj --logger "trx;LogFileName=test-results.trx" /p:CustomConstants=UT - name: Report test results - uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 - if: always() - with: - name: Test Results - path: "**/test-results.trx" - reporter: dotnet-trx - fail-on-error: true + uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0 + if: always() + with: + name: Test Results + path: "**/test-results.trx" + reporter: dotnet-trx + fail-on-error: true - name: Build Play Store publisher if: ${{ matrix.variant == 'prod' }} From d6c139cb8a6bbabe79b805bcfd600ed048c727c8 Mon Sep 17 00:00:00 2001 From: Daniel James Smith <2670567+djsmith85@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:02:06 +0100 Subject: [PATCH 4/6] Import-link routes to import page after login (#2939) Co-authored-by: Daniel James Smith --- src/App/Pages/Settings/VaultSettingsPageViewModel.cs | 6 +++--- src/Core/ExternalLinksConstants.cs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/App/Pages/Settings/VaultSettingsPageViewModel.cs b/src/App/Pages/Settings/VaultSettingsPageViewModel.cs index 3afdba9298..e343111742 100644 --- a/src/App/Pages/Settings/VaultSettingsPageViewModel.cs +++ b/src/App/Pages/Settings/VaultSettingsPageViewModel.cs @@ -40,11 +40,11 @@ namespace Bit.App.Pages private async Task GoToImportItemsAsync() { - var webVaultUrl = _environmentService.GetWebVaultUrl() + "/#/tools/import"; - var body = string.Format(AppResources.YouCanImportDataToYourVaultOnX, webVaultUrl); + var toolsImportUrl = string.Format(ExternalLinksConstants.WEB_VAULT_TOOLS_IMPORT_FORMAT, _environmentService.GetWebVaultUrl()); + var body = string.Format(AppResources.YouCanImportDataToYourVaultOnX, toolsImportUrl); if (await _platformUtilsService.ShowDialogAsync(body, AppResources.ContinueToWebApp, AppResources.Continue, AppResources.Cancel)) { - _platformUtilsService.LaunchUri(webVaultUrl); + _platformUtilsService.LaunchUri(toolsImportUrl); } } } diff --git a/src/Core/ExternalLinksConstants.cs b/src/Core/ExternalLinksConstants.cs index fbb70030ab..6db6292a27 100644 --- a/src/Core/ExternalLinksConstants.cs +++ b/src/Core/ExternalLinksConstants.cs @@ -13,6 +13,11 @@ /// public const string WEB_VAULT_SETTINGS_FORMAT = "{0}/#/settings"; + /// + /// Link to go to individual vault import page. Requires to pass vault URL as parameter. + /// + public const string WEB_VAULT_TOOLS_IMPORT_FORMAT = "{0}/#/tools/import"; + /// /// General website, not in the full format of a URL given that this is used as parameter of string resources to be shown to the user. /// From 0a1fbfafb50395091d11a0ad73370cfa069055a9 Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Wed, 17 Jan 2024 09:34:31 -0300 Subject: [PATCH 5/6] PM-3349 Fix navigation when coming from autofill with Accessibility Services enabled. The user was getting into Home page instead of where they were, with this workaround the app navigates as if the account has been switched, leaving the user as closely as possible to where they were, basically on the first screen for the current state of the user. --- src/Core/App.xaml.cs | 26 +++++++++++++++++++++--- src/Core/Pages/Accounts/HomePage.xaml | 1 + src/Core/Pages/Accounts/HomePage.xaml.cs | 19 +++++++++++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/Core/App.xaml.cs b/src/Core/App.xaml.cs index 8124ac3ee8..7deed659dd 100644 --- a/src/Core/App.xaml.cs +++ b/src/Core/App.xaml.cs @@ -46,6 +46,7 @@ namespace Bit.App // This queue keeps those actions so that when the app has resumed they can still be executed. // Links: https://github.com/dotnet/maui/issues/11501 and https://bitwarden.atlassian.net/wiki/spaces/NMME/pages/664862722/MainPage+Assignments+not+working+on+Android+on+Background+or+App+resume private readonly Queue _onResumeActions = new Queue(); + private bool _hasNavigatedToAutofillWindow; #if ANDROID @@ -89,7 +90,7 @@ namespace Bit.App { Options = appOptions ?? new AppOptions(); } - + protected override Window CreateWindow(IActivationState activationState) { //When executing from AutofillExternalActivity we don't have "Options" so we need to filter "manually" @@ -106,18 +107,37 @@ namespace Bit.App if (Options != null && (Options.FromAutofillFramework || Options.Uri != null || Options.OtpData != null || Options.CreateSend != null)) { _isResumed = true; //Specifically for the Autofill scenario we need to manually set the _isResumed here + _hasNavigatedToAutofillWindow = true; return new AutoFillWindow(new NavigationPage(new AndroidNavigationRedirectPage())); } + var homePage = new HomePage(Options); + // WORKAROUND: If the user autofills with Accessibility Services enabled and goes back to the application then there is currently an issue + // where this method is called again + // thus it goes through here and the user goes to HomePage as we see here. + // So to solve this, the next flag check has been added which then turns on a flag on the home page + // that will trigger a navigation on the accounts manager when it loads; workarounding this behavior and navigating the user + // to the proper page depending on its state. + // WARNING: this doens't navigate the user to where they were but it acts as if the user had changed their account. + if(_hasNavigatedToAutofillWindow) + { + homePage.PerformNavigationOnAccountChangedOnLoad = true; + // this is needed because when coming back from AutofillWindow OnResume won't be called and we need this flag + // so that void Navigate(NavigationTarget navTarget, INavigationParams navParams) doesn't enqueue the navigation + // and it performs it directly. + _isResumed = true; + _hasNavigatedToAutofillWindow = false; + } + //If we have an existing MainAppWindow we can use that one var mainAppWindow = Windows.OfType().FirstOrDefault(); if (mainAppWindow != null) { - mainAppWindow.PendingPage = new NavigationPage(new HomePage(Options)); + mainAppWindow.PendingPage = new NavigationPage(homePage); } //Create new main window - return new MainAppWindow(new NavigationPage(new HomePage(Options))); + return new MainAppWindow(new NavigationPage(homePage)); } #else //iOS doesn't use the CreateWindow override used in Android so we just set the Application.Current.MainPage directly diff --git a/src/Core/Pages/Accounts/HomePage.xaml b/src/Core/Pages/Accounts/HomePage.xaml index 0061612485..fe69921554 100644 --- a/src/Core/Pages/Accounts/HomePage.xaml +++ b/src/Core/Pages/Accounts/HomePage.xaml @@ -9,6 +9,7 @@ x:DataType="pages:HomeViewModel" HideSoftInputOnTapped="True" x:Name="_page" + Loaded="HomePage_Loaded" Title="{Binding PageTitle}"> diff --git a/src/Core/Pages/Accounts/HomePage.xaml.cs b/src/Core/Pages/Accounts/HomePage.xaml.cs index 03f8c8da48..11c5b36bad 100644 --- a/src/Core/Pages/Accounts/HomePage.xaml.cs +++ b/src/Core/Pages/Accounts/HomePage.xaml.cs @@ -1,8 +1,8 @@ -using Bit.App.Models; +using Bit.App.Abstractions; +using Bit.App.Models; using Bit.App.Utilities; using Bit.Core.Abstractions; using Bit.Core.Utilities; -using Microsoft.Maui.Platform; namespace Bit.App.Pages { @@ -44,6 +44,21 @@ namespace Bit.App.Pages } } + public bool PerformNavigationOnAccountChangedOnLoad { get; internal set; } + + void HomePage_Loaded(System.Object sender, System.EventArgs e) + { +#if ANDROID + // WORKAROUND: This is needed to fix the navigation when coming back from autofill when Accessibility Services is enabled + // See App.xaml.cs -> CreateWindow(...) for more info. + if (PerformNavigationOnAccountChangedOnLoad && ServiceContainer.TryResolve(out var accountsManager)) + { + PerformNavigationOnAccountChangedOnLoad = false; + accountsManager.NavigateOnAccountChangeAsync().FireAndForget(); + } +#endif + } + public async Task DismissRegisterPageAndLogInAsync(string email) { await Navigation.PopModalAsync(); From 6b9eeba88d76b5b717571fd2eb043d61c757737f Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Wed, 17 Jan 2024 13:22:00 -0300 Subject: [PATCH 6/6] PM-3350 PM-3349 Added property to Directory.Build.props to enable Unit Testing globally so Test runners work --- Directory.Build.props | 2 ++ test/Core.Test/Core.Test.csproj | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bf789590a0..1be40c6008 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,7 @@ 8.0.4-nightly.* + + \ No newline at end of file diff --git a/test/Core.Test/Core.Test.csproj b/test/Core.Test/Core.Test.csproj index 79a3df6a7d..6062ea90c6 100644 --- a/test/Core.Test/Core.Test.csproj +++ b/test/Core.Test/Core.Test.csproj @@ -4,11 +4,6 @@ net8.0 false Bit.Core.Test - -