mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
test(BRIDGE-220): Add Bridge E2E UI login/logout tests for Windows
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
{
|
||||
@ -6,31 +7,60 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string MailboxPassword { get; set; }
|
||||
|
||||
public TestUserData(string username, string password)
|
||||
public TestUserData(string username, string password, string mailboxPassword ="")
|
||||
{
|
||||
Username = username;
|
||||
Password = password;
|
||||
MailboxPassword = mailboxPassword;
|
||||
}
|
||||
|
||||
public static TestUserData GetFreeUser()
|
||||
{
|
||||
(string username, string password) = GetusernameAndPassword("BRIDGE_FLAUI_FREE_USER");
|
||||
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_FREE_USER");
|
||||
return new TestUserData(username, password);
|
||||
}
|
||||
|
||||
public static TestUserData GetPaidUser()
|
||||
{
|
||||
(string username, string password) = GetusernameAndPassword("BRIDGE_FLAUI_PAID_USER");
|
||||
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_PAID_USER");
|
||||
return new TestUserData(username, password);
|
||||
}
|
||||
|
||||
public static TestUserData GetMailboxUser()
|
||||
{
|
||||
(string username, string password, string mailboxPassword) = GetUsernameAndPasswordAndMailbox("BRIDGE_FLAUI_MAILBOX_USER");
|
||||
return new TestUserData(username, password, mailboxPassword);
|
||||
}
|
||||
|
||||
public static TestUserData GetDisabledUser()
|
||||
{
|
||||
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_DISABLED_USER");
|
||||
return new TestUserData(username, password);
|
||||
}
|
||||
|
||||
public static TestUserData GetDeliquentUser()
|
||||
{
|
||||
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_DELIQUENT_USER");
|
||||
return new TestUserData(username, password);
|
||||
}
|
||||
public static TestUserData GetIncorrectCredentialsUser()
|
||||
{
|
||||
return new TestUserData("IncorrectUsername", "IncorrectPass");
|
||||
}
|
||||
|
||||
private static (string, string) GetusernameAndPassword(string userType)
|
||||
public static TestUserData GetEmptyCredentialsUser()
|
||||
{
|
||||
return new TestUserData("", "");
|
||||
}
|
||||
|
||||
public static TestUserData GetAliasUser()
|
||||
{
|
||||
(string username, string password) = GetUsernameAndPassword("BRIDGE_FLAUI_ALIAS_USER");
|
||||
return new TestUserData(username, password);
|
||||
}
|
||||
private static (string, string) GetUsernameAndPassword(string userType)
|
||||
{
|
||||
// Get the environment variable for the user and check if missing
|
||||
// When changing or adding an environment variable, you must restart Visual Studio
|
||||
@ -38,7 +68,7 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
string? str = Environment.GetEnvironmentVariable(userType);
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
throw new Exception($"Missing environment variable: {userType}");
|
||||
throw new Exception($"Environment variable {userType} must contain one ':' and it must be between username and password!");
|
||||
}
|
||||
|
||||
// Check if the environment variable contains only one ':'
|
||||
@ -54,5 +84,34 @@ namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
string[] split = str.Split(':');
|
||||
return (split[0], split[1]);
|
||||
}
|
||||
private static (string, string, string) GetUsernameAndPasswordAndMailbox(string userType)
|
||||
{
|
||||
// Get the environment variable for the user type and check if missing
|
||||
string? str = Environment.GetEnvironmentVariable(userType);
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
throw new Exception($"Missing environment variable: {userType}");
|
||||
}
|
||||
|
||||
// Check if the environment variable contains exactly two ':'
|
||||
// The first part is the username, second part is the password, third is the mailbox
|
||||
string separator = ":";
|
||||
string[] parts = str.Split(separator);
|
||||
|
||||
if (parts.Length != 3)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Environment variable {userType} must contain exactly two ':' characters, separating username, password, and mailbox!"
|
||||
);
|
||||
}
|
||||
|
||||
string username = parts[0];
|
||||
string password = parts[1];
|
||||
string mailbox = parts[2];
|
||||
|
||||
// Return the username, password, and mailbox as a tuple
|
||||
return (username, password, mailbox);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user