Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ public async Task MyAccountPageViewModel_Initialise_IsInitialised() {
this.ViewModel.IsDarkThemeEnabled.ShouldBeTrue();
}

[Fact]
public async Task MyAccountPageViewModel_Initialise_WhenMerchantDetailsAreCached_UsesCachedMerchantDetails() {
this.ApplicationCache.Setup(a => a.GetMerchantDetails()).Returns(TestData.MerchantDetailsModel);
this.ApplicationCache.Setup(a => a.GetLastLoginDate()).Returns(DateTime.Now);
this.ApplicationThemeService.Setup(s => s.GetDarkThemeEnabled()).ReturnsAsync(false);
this.Mediator.Setup(m => m.Send(It.IsAny<MerchantQueries.GetMerchantDetailsQuery>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Success(TestData.MerchantDetailsModel));

await this.ViewModel.Initialise(CancellationToken.None);

this.ViewModel.MerchantName.ShouldBe(TestData.MerchantDetailsModel.MerchantName);
this.Mediator.Verify(m => m.Send(It.IsAny<MerchantQueries.GetMerchantDetailsQuery>(), It.IsAny<CancellationToken>()), Times.Never);
}

[Fact]
public async Task MyAccountPageViewModel_SetDarkTheme_ThemeStoredAndPropertyUpdated() {
await this.ViewModel.SetDarkTheme(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using TransactionProcessor.Mobile.BusinessLogic.Models;

namespace TransactionProcessor.Mobile.BusinessLogic.Services
Expand All @@ -13,39 +14,43 @@
{
String GetConfigHostUrl();

void SetConfigHostUrl(String value, MemoryCacheEntryOptions options = default);

Check warning on line 17 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

Boolean GetUseTrainingMode();

void SetUseTrainingMode(Boolean value, MemoryCacheEntryOptions options = default);

Check warning on line 21 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 21 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

Boolean GetIsLoggedIn();

void SetIsLoggedIn(Boolean value, MemoryCacheEntryOptions options = default);

Check warning on line 25 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 25 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

Configuration GetConfiguration();

void SetConfiguration(Configuration value, MemoryCacheEntryOptions options = default);

Check warning on line 29 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 29 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

List<ContractProductModel> GetContractProducts();

void SetContractProducts(List<ContractProductModel> value, MemoryCacheEntryOptions options = default);

Check warning on line 33 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 33 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

TokenResponseModel GetAccessToken();

void SetAccessToken(TokenResponseModel value, MemoryCacheEntryOptions options = default);

Check warning on line 37 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Check warning on line 37 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

void ClearAccessToken();

MerchantDetailsModel GetMerchantDetails();

void ClearMerchantDetails();

void SetMerchantDetails(MerchantDetailsModel value, MemoryCacheEntryOptions options = default);

Check warning on line 45 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Decimal GetMerchantBalance();

void SetMerchantBalance(Decimal value, MemoryCacheEntryOptions options = default);

Check warning on line 49 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

DateTime GetLastLoginDate();

void SetLastLoginDate(DateTime value, MemoryCacheEntryOptions options = default);

Check warning on line 53 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
}

[ExcludeFromCodeCoverage]
Expand Down Expand Up @@ -98,7 +103,7 @@
}

public void SetConfigHostUrl(String value,
MemoryCacheEntryOptions options = default)

Check warning on line 106 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("ConfigHostUrl", value, options);
}
Expand All @@ -114,6 +119,10 @@
this.Set("AccessToken", value, options);
}

public void ClearAccessToken() {
this.MemoryCache.Remove("AccessToken");
}

public void SetConfiguration(Configuration value,
MemoryCacheEntryOptions options = default)
{
Expand All @@ -137,6 +146,10 @@
return this.TryGetValue<MerchantDetailsModel>("MerchantDetails");
}

public void ClearMerchantDetails() {
this.MemoryCache.Remove("MerchantDetails");
}

public void SetMerchantDetails(MerchantDetailsModel value,
MemoryCacheEntryOptions options = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private async Task ShowLoginPage() {
if (leave) {
Logger.LogInformation("LogoutCommand called");
this.ApplicationCache.SetIsLoggedIn(false);
this.ApplicationCache.SetAccessToken(null);
this.ApplicationCache.ClearAccessToken();
this.ApplicationCache.ClearMerchantDetails();

await this.NavigationService.GoToLoginPage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public async Task SetDarkTheme(Boolean isEnabled) {

private async Task LogoutCommandExecute() {
Logger.LogInformation("LogoutCommand called");
this.ApplicationCache.SetAccessToken(null);
this.ApplicationCache.ClearAccessToken();
this.ApplicationCache.SetIsLoggedIn(false);
this.ApplicationCache.ClearMerchantDetails();

await this.NavigationService.GoToLoginPage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
private const int AppiumPort = 4723;

public static MobileTestPlatform MobileTestPlatform;
public static AppiumDriver Driver;

Check warning on line 28 in TransactionProcessor.Mobile.UITests/Drivers/AppiumDriver.cs

View workflow job for this annotation

GitHub Actions / hardware_navigation_tests

Non-nullable field 'Driver' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 28 in TransactionProcessor.Mobile.UITests/Drivers/AppiumDriver.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Non-nullable field 'Driver' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
private AppiumLocalService? appiumService;
private Uri? appiumServerUri;
private readonly List<string> appiumStartupOutput = new();
Expand Down Expand Up @@ -499,6 +499,7 @@
driverOptions.AddAdditionalAppiumOption("appPackage", "com.transactionprocessor.mobile");
driverOptions.AddAdditionalAppiumOption("enforceAppInstall", true);
driverOptions.AddAdditionalAppiumOption("uiautomator2ServerInstallTimeout", "40000");
driverOptions.AddAdditionalAppiumOption("uiautomator2ServerLaunchTimeout", "120000");
driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 6000);

driverOptions.App = testAppConfig.AndroidAppPath;
Expand Down Expand Up @@ -562,7 +563,7 @@
}
finally
{
AppiumDriverWrapper.Driver = null;

Check warning on line 566 in TransactionProcessor.Mobile.UITests/Drivers/AppiumDriver.cs

View workflow job for this annotation

GitHub Actions / hardware_navigation_tests

Cannot convert null literal to non-nullable reference type.

Check warning on line 566 in TransactionProcessor.Mobile.UITests/Drivers/AppiumDriver.cs

View workflow job for this annotation

GitHub Actions / software_navigation_tests

Cannot convert null literal to non-nullable reference type.

if (this.ownsAppiumService && this.appiumService != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
@background @login @toolbar @profile @base @sharedapp @shared
Feature: LogoutLoginMerchantDetails

Background:

Given the following security roles exist
| Role Name |
| Merchant |

Given I create the following api scopes
| Name | DisplayName | Description |
| transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST |
| transactionProcessorACL | Transaction Processor ACL REST Scope | A scope for Transaction Processor ACL REST |

Given the following api resources exist
| Name | DisplayName | Secret | Scopes | UserClaims |
| transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | merchantId, estateId, role |
| transactionProcessorACL | Transaction Processor ACL REST | Secret1 | transactionProcessorACL | merchantId, estateId, role |

Given the following clients exist
| ClientId | ClientName | Secret | Scopes | GrantTypes |
| serviceClient | Service Client | Secret1 | transactionProcessor,transactionProcessorACL | client_credentials |
| mobileAppClient | Mobile App Client | Secret1 | transactionProcessorACL,transactionProcessor | password |

Given I have a token to access the estate management and transaction processor acl resources
| ClientId |
| serviceClient |

Given I have created the following estates
| EstateName |
| Test Estate 1 |

Given I have created the following operators
| EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber |
| Test Estate 1 | Safaricom | True | True |
| Test Estate 1 | Voucher | True | True |
| Test Estate 1 | PataPawa PostPay | True | True |
| Test Estate 1 | PataPawa PrePay | True | True |

And I have assigned the following operators to the estates
| EstateName | OperatorName |
| Test Estate 1 | Safaricom |
| Test Estate 1 | Voucher |
| Test Estate 1 | PataPawa PostPay |
| Test Estate 1 | PataPawa PrePay |

Given I create a contract with the following values
| EstateName | OperatorName | ContractDescription |
| Test Estate 1 | Safaricom | Safaricom Contract |
| Test Estate 1 | Voucher | Hospital 1 Contract |
| Test Estate 1 | PataPawa PostPay | PataPawa PostPay Contract |
| Test Estate 1 | PataPawa PrePay | PataPawa PrePay Contract |

When I create the following Products
| EstateName | OperatorName | ContractDescription | ProductName | DisplayText | Value | ProductType |
| Test Estate 1 | Safaricom | Safaricom Contract | Variable Topup | Custom | | MobileTopup |
| Test Estate 1 | Voucher | Hospital 1 Contract | 10 KES | 10 KES | 10.00 | Voucher |
| Test Estate 1 | PataPawa PostPay | PataPawa PostPay Contract | Post Pay Bill Pay | Bill Pay (Post) | | BillPayment |
| Test Estate 1 | PataPawa PrePay | PataPawa PrePay Contract | Pre Pay Bill Pay | Bill Pay (Pre) | | BillPayment |

Given I create the following merchants
| MerchantName | AddressLine1 | AddressLine2 | AddressLine3 | AddressLine4 | Town | Region | PostalCode | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 1 | test address line 1 | test address line 2 | test address line 3 | test address line 4 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 |
| Test Merchant 2 | test address line 1 | test address line 2 | test address line 3 | test address line 4 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 2 | testcontact2@merchant2.co.uk | Test Estate 1 |

Given I have assigned the following operator to the merchants
| OperatorName | MerchantName | MerchantNumber | TerminalNumber | EstateName |
| Safaricom | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
| Voucher | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
| PataPawa PostPay | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
| PataPawa PrePay | Test Merchant 1 | 00000001 | 10000001 | Test Estate 1 |
| Safaricom | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |
| Voucher | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |
| PataPawa PostPay | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |
| PataPawa PrePay | Test Merchant 2 | 00000002 | 10000002 | Test Estate 1 |

Given I have assigned the following devices to the merchants
| MerchantName | EstateName |
| Test Merchant 1 | Test Estate 1 |
| Test Merchant 2 | Test Estate 1 |

When I add the following contracts to the following merchants
| EstateName | MerchantName | ContractDescription |
| Test Estate 1 | Test Merchant 1 | Safaricom Contract |
| Test Estate 1 | Test Merchant 1 | Hospital 1 Contract |
| Test Estate 1 | Test Merchant 1 | PataPawa PostPay Contract |
| Test Estate 1 | Test Merchant 1 | PataPawa PrePay Contract |
| Test Estate 1 | Test Merchant 2 | Safaricom Contract |
| Test Estate 1 | Test Merchant 2 | Hospital 1 Contract |
| Test Estate 1 | Test Merchant 2 | PataPawa PostPay Contract |
| Test Estate 1 | Test Merchant 2 | PataPawa PrePay Contract |

Given I have created the following security users
| EmailAddress | Password | GivenName | FamilyName | EstateName | MerchantName |
| user1 | 123456 | TestMerchant | User1 | Test Estate 1 | Test Merchant 1 |
| user2 | 123456 | TestMerchant | User2 | Test Estate 1 | Test Merchant 2 |

Given I have created a config for my device

@PRTest
Scenario: Logout and relogin with a different merchant
Given I am on the Login Screen
And my device is registered
When I enter 'user1' as the Email Address
And I enter '123456' as the Password
And I tap on Login
Then the Merchant Home Page is displayed
When I tap on Profile
Then the My Profile Page is displayed
When I tap on the Account Info button
Then the Account Info Page is displayed
And the Account Info is displayed
| Name | Balance | AvailableBalance |
| Test Merchant 1 | 0 | 0 |
When I click on the back button
Then the My Profile Page is displayed
When I click on the back button
Then the Merchant Home Page is displayed
When I tap on Logout
Then A message is displayed confirming I want to log out
When I click yes
Then the Login Page is displayed
And I replace the merchants with the following merchants
| MerchantName | AddressLine1 | AddressLine2 | AddressLine3 | AddressLine4 | Town | Region | PostalCode | Country | ContactName | EmailAddress | EstateName |
| Test Merchant 2 | test address line 1 | test address line 2 | test address line 3 | test address line 4 | TestTown | Test Region | TE57 1NG | United Kingdom | Test Contact 2 | testcontact2@merchant2.co.uk | Test Estate 1 |
When I enter 'user2' as the Email Address
And I enter '123456' as the Password
And I tap on Login
Then the Merchant Home Page is displayed
When I tap on Profile
Then the My Profile Page is displayed
When I tap on the Account Info button
Then the Account Info Page is displayed
And the Account Info is displayed
| Name | Balance | AvailableBalance |
| Test Merchant 2 | 0 | 0 |
Loading
Loading