mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
Merge branch 'feature/api_tests' into 'main'
Feature/api tests See merge request fabinfra/fabaccess/borepin!48
This commit is contained in:
commit
f347801cc8
@ -27,46 +27,52 @@ namespace Borepin.Model
|
||||
Name = _Machine.Name;
|
||||
Description = _Machine.Description;
|
||||
State = _Machine.State;
|
||||
Manager = new UserVisualize(_Machine.Manager);
|
||||
Manager.LoadData();
|
||||
|
||||
CanUse = !((UseInterface_Proxy)_Machine.Use).IsNull;
|
||||
CanInUse = !((InUseInterface_Proxy) _Machine.Inuse).IsNull;
|
||||
CanTakeOver = !((TakeoverInterface_Proxy) _Machine.Takeover).IsNull;
|
||||
CanCheck = !((CheckInterface_Proxy) _Machine.Check).IsNull;
|
||||
CanManage = !((ManageInterface_Proxy) _Machine.Manage).IsNull;
|
||||
CanAdmin = !((AdminInterface_Proxy) _Machine.Admin).IsNull;
|
||||
if(_Machine.Manager.Just != null)
|
||||
{
|
||||
Manager = new UserVisualize(_Machine.Manager.Just);
|
||||
Manager.LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager = null;
|
||||
}
|
||||
|
||||
CurrentUser = null;
|
||||
LastUser = null;
|
||||
|
||||
if (CanManage)
|
||||
if(!((ManageInterface_Proxy)_Machine.Manage).IsNull)
|
||||
{
|
||||
MachineInfoExtended machineInfoExtended = await _Machine.Manage.GetMachineInfoExtended().ConfigureAwait(false);
|
||||
if (machineInfoExtended != null)
|
||||
if (machineInfoExtended.CurrentUser.Just == null)
|
||||
{
|
||||
CurrentUser = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUser = new UserVisualize(machineInfoExtended.CurrentUser.Just);
|
||||
CurrentUser.LoadData();
|
||||
}
|
||||
|
||||
if (machineInfoExtended.CurrentUser == null || machineInfoExtended.CurrentUser.Username == null)
|
||||
{
|
||||
CurrentUser = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUser = new UserVisualize(machineInfoExtended.CurrentUser);
|
||||
CurrentUser.LoadData();
|
||||
}
|
||||
|
||||
if (machineInfoExtended.LastUser == null || machineInfoExtended.LastUser.Username == null)
|
||||
{
|
||||
LastUser = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastUser = new UserVisualize(machineInfoExtended.LastUser);
|
||||
LastUser.LoadData();
|
||||
}
|
||||
if (machineInfoExtended.LastUser .Just== null)
|
||||
{
|
||||
LastUser = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastUser = new UserVisualize(machineInfoExtended.LastUser.Just);
|
||||
LastUser.LoadData();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUser = null;
|
||||
LastUser = null;
|
||||
}
|
||||
|
||||
CanUse = !((UseInterface_Proxy)_Machine.Use).IsNull;
|
||||
CanInUse = !((InUseInterface_Proxy)_Machine.Inuse).IsNull;
|
||||
CanTakeOver = !((TakeoverInterface_Proxy)_Machine.Takeover).IsNull;
|
||||
CanCheck = !((CheckInterface_Proxy)_Machine.Check).IsNull;
|
||||
CanManage = !((ManageInterface_Proxy)_Machine.Manage).IsNull;
|
||||
CanAdmin = !((AdminInterface_Proxy)_Machine.Admin).IsNull;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
x:Class="Borepin.Page.ScanPage">
|
||||
<ContentPage.Content>
|
||||
<StackLayout IsVisible="{Binding IsVisible}">
|
||||
<zxing:ZXingScannerView Result="{Binding ScanResult, Mode=TwoWay}" ScanResultCommand="{Binding ScannedCommand}" IsScanning="{Binding IsScanning}" WidthRequest="300" HeightRequest="500" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
|
||||
<zxing:ZXingScannerView Result="{Binding ScanResult, Mode=TwoWay}" ScanResultCommand="{Binding ScannedCommand}" IsScanning="{Binding IsScanning}" WidthRequest="300" HeightRequest="500" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Options="{Binding ScanOptions}"/>
|
||||
<Button Text="Abort" Command="{Binding AbortCommand}"/>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
|
@ -7,7 +7,6 @@ using Prism.Navigation;
|
||||
using Borepin.Service.BFFH;
|
||||
using Borepin.Base;
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Services.Dialogs;
|
||||
using Prism.Services;
|
||||
using static FabAccessAPI.Schema.Machine;
|
||||
using System;
|
||||
@ -19,16 +18,12 @@ namespace Borepin.PageModel
|
||||
public class MachineListPageModel : ConnectionModelBase
|
||||
{
|
||||
#region Private Fields
|
||||
private readonly IDialogService _DialogService;
|
||||
|
||||
private Machine _NextMachine;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public MachineListPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IBFFHService bFFHService, IDialogService dialogService) : base(navigationService, pageDialogService, bFFHService)
|
||||
public MachineListPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IBFFHService bFFHService) : base(navigationService, pageDialogService, bFFHService)
|
||||
{
|
||||
_DialogService = dialogService;
|
||||
|
||||
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecute);
|
||||
ScanCodeCommand = new DelegateCommand(async () => await ScanCodeCommandExecute().ConfigureAwait(false));
|
||||
RefreshCommand = new DelegateCommand(async ()=> await RefreshCommandExecute().ConfigureAwait(true));
|
||||
@ -48,14 +43,11 @@ namespace Borepin.PageModel
|
||||
|
||||
IsConnected = true;
|
||||
|
||||
IMachineSystem machineSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
MachineSystem.IInfoInterface machine_infoInterface = await machineSystem.Info().ConfigureAwait(false);
|
||||
MachineSystem machineSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
UserSystem userSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).UserSystem;
|
||||
User user_self = await userSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
IUserSystem userSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).UserSystem;
|
||||
UserSystem.IInfoInterface user_infoInterface = await userSystem.Info().ConfigureAwait(false);
|
||||
User user_self = (await user_infoInterface.GetUserSelf().ConfigureAwait(false)).Item1;
|
||||
|
||||
IReadOnlyList<Machine> machine_list = await machine_infoInterface.GetMachineList().ConfigureAwait(false);
|
||||
IReadOnlyList<Machine> machine_list = await machineSystem.Info.GetMachineList().ConfigureAwait(false);
|
||||
|
||||
List<MachineListItemViewModel> viewmodel_list_user_assigned = new List<MachineListItemViewModel>();
|
||||
List<MachineListItemViewModel> viewmodel_list_not_user_assigned = new List<MachineListItemViewModel>();
|
||||
@ -141,7 +133,57 @@ namespace Borepin.PageModel
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
await _NavigationService.NavigateAsync("ScanURNPage").ConfigureAwait(false);
|
||||
NavigationParameters parameters = new NavigationParameters()
|
||||
{
|
||||
{"intance", null },
|
||||
};
|
||||
|
||||
await _NavigationService.NavigateAsync("ScanPage", parameters).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async void ScanCode_Result(string value)
|
||||
{
|
||||
if (! _BFFHService.IsConnected)
|
||||
{
|
||||
IsConnected = false;
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
MachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
|
||||
Machine machine = (await machineInterface.Info.GetMachineURN(value).ConfigureAwait(false)).Just;
|
||||
|
||||
if(machine == null)
|
||||
{
|
||||
IsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_NextMachine = machine;
|
||||
IsBusy = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPageLifecycleAware
|
||||
public async void OnAppearing()
|
||||
{
|
||||
if(_NextMachine != null)
|
||||
{
|
||||
NavigationParameters parameters = new NavigationParameters
|
||||
{
|
||||
{ "id", _NextMachine.Id},
|
||||
};
|
||||
|
||||
_NextMachine = null;
|
||||
|
||||
await _NavigationService.NavigateAsync("MachinePage", parameters).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDisappearing()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace Borepin.PageModel
|
||||
return;
|
||||
}
|
||||
|
||||
IMachineSystem machineSystem;
|
||||
MachineSystem machineSystem;
|
||||
try
|
||||
{
|
||||
machineSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
@ -52,9 +52,7 @@ namespace Borepin.PageModel
|
||||
return;
|
||||
}
|
||||
|
||||
IInfoInterface info = await machineSystem.Info().ConfigureAwait(false);
|
||||
|
||||
_Machine = await info.GetMachine(_ID).ConfigureAwait(false);
|
||||
_Machine = (await machineSystem.Info.GetMachine(_ID).ConfigureAwait(false)).Just;
|
||||
MachineItem = new MachineVisualize(_Machine);
|
||||
MachineItem.LoadData();
|
||||
|
||||
|
@ -13,14 +13,11 @@ namespace Borepin.PageModel
|
||||
{
|
||||
#region Private Fields
|
||||
private object _Instance;
|
||||
private readonly INavigationService _NavigationService;
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
public ScanPageModel(INavigationService navigationService) : base(navigationService)
|
||||
{
|
||||
_NavigationService = navigationService;
|
||||
|
||||
AbortCommand = new DelegateCommand(async () => await AbortCommandExecute().ConfigureAwait(true));
|
||||
ScannedCommand = new DelegateCommand(ScannedCommandExecute);
|
||||
|
||||
@ -32,7 +29,7 @@ namespace Borepin.PageModel
|
||||
#region Data
|
||||
public override async Task LoadData()
|
||||
{
|
||||
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -76,7 +73,7 @@ namespace Borepin.PageModel
|
||||
{
|
||||
{ "result", "scanned" },
|
||||
{ "value", ScanResult.Text },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
@ -99,7 +96,7 @@ namespace Borepin.PageModel
|
||||
INavigationParameters parameters = new NavigationParameters()
|
||||
{
|
||||
{ "result", "abort" },
|
||||
{ "instance", _Instance }
|
||||
{ "instance", _Instance },
|
||||
};
|
||||
await _NavigationService.GoBackAsync(parameters).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -4,21 +4,17 @@ using FabAccessAPI.Schema;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using Prism.Services;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
using ZXing;
|
||||
using ZXing.Mobile;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
class ScanURNPageModel : ConnectionModelBase
|
||||
{
|
||||
#region Private Fields
|
||||
private object _Instance;
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
public ScanURNPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IBFFHService bffhService) : base(navigationService, pageDialogService, bffhService)
|
||||
{
|
||||
@ -33,11 +29,28 @@ namespace Borepin.PageModel
|
||||
#region Data
|
||||
public override async Task LoadData()
|
||||
{
|
||||
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
public MobileBarcodeScanningOptions ScanOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return new MobileBarcodeScanningOptions()
|
||||
{
|
||||
PossibleFormats = new List<BarcodeFormat>()
|
||||
{
|
||||
BarcodeFormat.QR_CODE,
|
||||
BarcodeFormat.EAN_13
|
||||
// TODO add more Barcode Formats if needed
|
||||
}
|
||||
};
|
||||
}
|
||||
//set => SetProperty(ref _ScanOptions, value);
|
||||
}
|
||||
|
||||
private Result _ScanResult;
|
||||
public Result ScanResult
|
||||
{
|
||||
@ -73,6 +86,18 @@ namespace Borepin.PageModel
|
||||
{
|
||||
IsScanning = false;
|
||||
|
||||
// HACK
|
||||
if(string.Equals(ScanResult.Text, "4014472002512", System.StringComparison.Ordinal))
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await _PageDialogService.DisplayAlertAsync("YAY", "It's Bionade", "OK").ConfigureAwait(false);
|
||||
IsScanning = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
// END HACK
|
||||
|
||||
string id = await QRToID(ScanResult.Text).ConfigureAwait(false);
|
||||
|
||||
if (id != null)
|
||||
@ -87,10 +112,14 @@ namespace Borepin.PageModel
|
||||
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage/MachinePage", parameters).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
IsScanning = true;
|
||||
else
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await _PageDialogService.DisplayAlertAsync("Alert", "QR Code is invalid", "OK").ConfigureAwait(false);
|
||||
IsScanning = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> QRToID(string value)
|
||||
@ -101,17 +130,16 @@ namespace Borepin.PageModel
|
||||
return null;
|
||||
}
|
||||
|
||||
IMachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
MachineSystem.IInfoInterface infoInterface = await machineInterface.Info().ConfigureAwait(false);
|
||||
MachineSystem machineSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem;
|
||||
|
||||
Machine machine = await infoInterface.GetMachineURN(value).ConfigureAwait(false);
|
||||
Optional<Machine> optional = await machineSystem.Info.GetMachineURN(value).ConfigureAwait(false);
|
||||
|
||||
if (machine == null)
|
||||
if (optional.Just == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return machine.Id;
|
||||
return optional.Just.Id;
|
||||
}
|
||||
|
||||
private ICommand _AbortCommand;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c9283ebd696ed6dd428a7c3d24820889f7ab4bf3
|
||||
Subproject commit aea03aabe3d1322892c1896ba757ceeedb92ed73
|
@ -8,7 +8,7 @@ using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
using static FabAccessAPI.Schema.MachineSystem;
|
||||
using static FabAccessAPI.Schema.Machine;
|
||||
|
||||
namespace FabAccessAPI_Test
|
||||
{
|
||||
@ -57,7 +57,8 @@ namespace FabAccessAPI_Test
|
||||
}
|
||||
|
||||
[TestFixture, Parallelizable(ParallelScope.Children)]
|
||||
public class MachineSystem
|
||||
[Order(1)]
|
||||
public class MachineSystem_Test
|
||||
{
|
||||
[TestCase("Admin1", true)]
|
||||
[TestCase("Admin2", true)]
|
||||
@ -88,29 +89,15 @@ namespace FabAccessAPI_Test
|
||||
[TestCase("MakerQRA", true)]
|
||||
[TestCase("MakerQRB", true)]
|
||||
[TestCase("MakerQRC", true)]
|
||||
|
||||
[Order(1)]
|
||||
public async Task AccessMachineSystem(string username, bool expectAllow)
|
||||
[Order(2)]
|
||||
public async Task AccessMachineSystem_Info(string username, bool expectAllow)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
bool result = !((MachineSystem_Proxy)session.MachineSystem).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectAllow, result);
|
||||
Assert.AreEqual(expectAllow, !((MachineSystem.InfoInterface_Proxy)session.MachineSystem.Info).IsNull);
|
||||
}
|
||||
|
||||
//[TestCase("", true)]
|
||||
//[Order(2)]
|
||||
//public async Task AccessMachineSystem_Info(string username, bool expectAllow)
|
||||
//{
|
||||
// Session session = await API_TestEnv_Test.Connect(username);
|
||||
|
||||
// Assert.AreEqual(expectAllow, session.MachineSystem.Info);
|
||||
//}
|
||||
|
||||
[TestCase("Admin1", 15)]
|
||||
[TestCase("ManagerA1", 5)]
|
||||
[TestCase("ManagerB1", 5)]
|
||||
@ -133,8 +120,7 @@ namespace FabAccessAPI_Test
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
||||
IReadOnlyList<Machine> machine_list = await infoInterface.GetMachineList().ConfigureAwait(false);
|
||||
IReadOnlyList<Machine> machine_list = await session.MachineSystem.Info.GetMachineList().ConfigureAwait(false);
|
||||
|
||||
int result = machine_list.Count;
|
||||
|
||||
@ -167,16 +153,15 @@ namespace FabAccessAPI_Test
|
||||
[TestCase("MakerQRA", "MachineA1", true)]
|
||||
[TestCase("MakerQRB", "MachineB1", true)]
|
||||
[TestCase("MakerQRC", "MachineC1", true)]
|
||||
|
||||
[Order(4)]
|
||||
public async Task GetMachineByName(string username, string machineName, bool expectedAllow)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
||||
Machine machine = await infoInterface.GetMachine(machineName).ConfigureAwait(false);
|
||||
bool result = machine != null;
|
||||
Optional<Machine> optional = await session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false);
|
||||
|
||||
bool result = optional.Just != null;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
@ -191,12 +176,11 @@ namespace FabAccessAPI_Test
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
||||
Machine machine = await infoInterface.GetMachine(machineName).ConfigureAwait(false);
|
||||
Optional<Machine> optional = await session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.IsNull(machine);
|
||||
Assert.IsNull(optional.Just);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", "urn:fabaccess:resource:MachineA1", true)]
|
||||
@ -230,9 +214,8 @@ namespace FabAccessAPI_Test
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
||||
Machine machine = await infoInterface.GetMachine(urn).ConfigureAwait(false);
|
||||
bool result = machine != null;
|
||||
Optional<Machine> optional = await session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false);
|
||||
bool result = optional.Just != null;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
@ -248,12 +231,652 @@ namespace FabAccessAPI_Test
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
||||
Machine machine = await infoInterface.GetMachine(urn).ConfigureAwait(false);
|
||||
Optional<Machine> optional = await session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.IsNull(machine);
|
||||
Assert.IsNull(optional.Just);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Parallelizable(ParallelScope.Children)]
|
||||
[Order(2)]
|
||||
public class Machine_Test_Stateless
|
||||
{
|
||||
[TestCase("Admin1", "MachineA1", true)]
|
||||
[TestCase("Admin1", "MachineB1", true)]
|
||||
[TestCase("Admin1", "MachineC1", true)]
|
||||
[TestCase("ManagerA1", "MachineA1", true)]
|
||||
[TestCase("ManagerB1", "MachineB1", true)]
|
||||
[TestCase("ManagerC1", "MachineC1", true)]
|
||||
[TestCase("ManagerABC1", "MachineA1", true)]
|
||||
[TestCase("ManagerABC1", "MachineB1", true)]
|
||||
[TestCase("ManagerABC1", "MachineC1", true)]
|
||||
[TestCase("MakerA1", "MachineA1", true)]
|
||||
[TestCase("MakerB1", "MachineB1", true)]
|
||||
[TestCase("MakerC1", "MachineC1", true)]
|
||||
[TestCase("GuestA1", "MachineA1", true)]
|
||||
[TestCase("GuestB1", "MachineB1", true)]
|
||||
[TestCase("GuestC1", "MachineC1", true)]
|
||||
[TestCase("MakerQRA", "MachineA1", true)]
|
||||
[TestCase("MakerQRB", "MachineB1", true)]
|
||||
[TestCase("MakerQRC", "MachineC1", true)]
|
||||
[Order(1)]
|
||||
public async Task InfoInterface(string username, string machineID, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
bool result = !((Machine.InfoInterface_Proxy)machine.Info).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", "MachineA1", true)]
|
||||
[TestCase("Admin1", "MachineB1", true)]
|
||||
[TestCase("Admin1", "MachineC1", true)]
|
||||
[TestCase("ManagerA1", "MachineA1", true)]
|
||||
[TestCase("ManagerB1", "MachineB1", true)]
|
||||
[TestCase("ManagerC1", "MachineC1", true)]
|
||||
[TestCase("ManagerABC1", "MachineA1", true)]
|
||||
[TestCase("ManagerABC1", "MachineB1", true)]
|
||||
[TestCase("ManagerABC1", "MachineC1", true)]
|
||||
[TestCase("MakerA1", "MachineA1", false)]
|
||||
[TestCase("MakerB1", "MachineB1", false)]
|
||||
[TestCase("MakerC1", "MachineC1", false)]
|
||||
[TestCase("GuestA1", "MachineA1", false)]
|
||||
[TestCase("GuestB1", "MachineB1", false)]
|
||||
[TestCase("GuestC1", "MachineC1", false)]
|
||||
[TestCase("MakerQRA", "MachineA1", false)]
|
||||
[TestCase("MakerQRB", "MachineB1", false)]
|
||||
[TestCase("MakerQRC", "MachineC1", false)]
|
||||
[Order(2)]
|
||||
public async Task ManageInterface(string username, string machineID, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
bool result = !((ManageInterface_Proxy)machine.Manage).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", "MachineA1", true)]
|
||||
[TestCase("Admin1", "MachineB1", true)]
|
||||
[TestCase("Admin1", "MachineC1", true)]
|
||||
[TestCase("ManagerA1", "MachineA1", false)]
|
||||
[TestCase("ManagerB1", "MachineB1", false)]
|
||||
[TestCase("ManagerC1", "MachineC1", false)]
|
||||
[TestCase("ManagerABC1", "MachineA1", false)]
|
||||
[TestCase("ManagerABC1", "MachineB1", false)]
|
||||
[TestCase("ManagerABC1", "MachineC1", false)]
|
||||
[TestCase("MakerA1", "MachineA1", false)]
|
||||
[TestCase("MakerB1", "MachineB1", false)]
|
||||
[TestCase("MakerC1", "MachineC1", false)]
|
||||
[TestCase("GuestA1", "MachineA1", false)]
|
||||
[TestCase("GuestB1", "MachineB1", false)]
|
||||
[TestCase("GuestC1", "MachineC1", false)]
|
||||
[TestCase("MakerQRA", "MachineA1", false)]
|
||||
[TestCase("MakerQRB", "MachineB1", false)]
|
||||
[TestCase("MakerQRC", "MachineC1", false)]
|
||||
[Order(3), Ignore("Not Implemented")]
|
||||
public async Task AdminInterface(string username, string machineID, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
bool result = !((AdminInterface_Proxy)machine.Admin).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", "MachineA1", "Description of MachineA1", @"https://fab-access.readthedocs.io", "CategoryA")]
|
||||
[TestCase("Admin1", "MachineB2", "Description of MachineB2", @"https://fab-access.readthedocs.io", "CategoryB")]
|
||||
[TestCase("Admin1", "MachineC3", "Description of MachineC3", @"https://fab-access.readthedocs.io", "CategoryC")]
|
||||
[Order(4)]
|
||||
public async Task ReadMachineData(string username, string machineID, string description, string wiki, string category)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.AreEqual(machineID, machine.Id);
|
||||
Assert.AreEqual(description, machine.Description);
|
||||
Assert.AreEqual(wiki, machine.Wiki);
|
||||
Assert.AreEqual(category, machine.Category);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
[Order(3)]
|
||||
public class Machine_Test
|
||||
{
|
||||
#region SetUp
|
||||
[SetUp]
|
||||
public async Task SetUp()
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect("Admin1");
|
||||
Session session = connection.Session;
|
||||
|
||||
IReadOnlyList<Machine> machine_list = await session.MachineSystem.Info.GetMachineList().ConfigureAwait(false);
|
||||
|
||||
List<Task> tasks = new List<Task>();
|
||||
foreach(Machine m in machine_list)
|
||||
{
|
||||
tasks.Add(m.Manage.ForceFree());
|
||||
}
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
#endregion
|
||||
|
||||
[TestCase("Admin1", "MachineA1")]
|
||||
[TestCase("ManagerA1", "MachineA1")]
|
||||
[TestCase("MakerA1", "MachineA1")]
|
||||
[Order(1)]
|
||||
public async Task UseGiveBack(string username, string machineID)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine.Use.Use().ConfigureAwait(false);
|
||||
|
||||
machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(MachineState.free, machine.State);
|
||||
}
|
||||
|
||||
[TestCase("ManagerA1", "MakerA1", "MachineA1")]
|
||||
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||
[TestCase("ManagerA1", "GuestA1", "MachineA1")]
|
||||
[Order(2), Ignore("Not Implemented")]
|
||||
public async Task TransferMachine(string username1, string username2, string machineID)
|
||||
{
|
||||
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||
Session session1 = connection1.Session;
|
||||
|
||||
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||
Session session2 = connection1.Session;
|
||||
|
||||
Machine machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine1.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine1.Use.Use().ConfigureAwait(false);
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
|
||||
|
||||
Machine machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Takeover.Accept().ConfigureAwait(false);
|
||||
|
||||
machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
|
||||
Assert.AreEqual(MachineState.free, machine1.State);
|
||||
}
|
||||
|
||||
[TestCase("ManagerA1", "MakerA1", "MachineA1")]
|
||||
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||
[TestCase("ManagerA1", "GuestA1", "MachineA1")]
|
||||
[Order(3), Ignore("Not Implemented")]
|
||||
public async Task TransferMachine_Reject(string username1, string username2, string machineID)
|
||||
{
|
||||
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||
Session session1 = connection1.Session;
|
||||
|
||||
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||
Session session2 = connection1.Session;
|
||||
|
||||
Machine machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine1.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine1.Use.Use().ConfigureAwait(false);
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
|
||||
|
||||
Machine machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Takeover.Reject().ConfigureAwait(false);
|
||||
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
machine2 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
|
||||
Assert.AreEqual(MachineState.free, machine2.State);
|
||||
}
|
||||
|
||||
[TestCase("ManagerA1", "ManagerA1", "MachineA1")]
|
||||
[TestCase("ManagerA1", "Admin1", "MachineA1")]
|
||||
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||
[Order(4), Ignore("Not Implemented")]
|
||||
public async Task CheckMachine(string username1, string username2, string machineID)
|
||||
{
|
||||
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||
Session session1 = connection1.Session;
|
||||
|
||||
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||
Session session2 = connection1.Session;
|
||||
|
||||
Machine machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine1.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine1.Use.Use().ConfigureAwait(false);
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
Machine machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Check.Check().ConfigureAwait(false);
|
||||
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
|
||||
Assert.AreEqual(MachineState.free, machine1.State);
|
||||
}
|
||||
|
||||
[TestCase("ManagerA1", "ManagerA1", "MachineA1")]
|
||||
[TestCase("ManagerA1", "Admin1", "MachineA1")]
|
||||
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||
[Order(5), Ignore("Not Implemented")]
|
||||
public async Task CheckMachine_Reject(string username1, string username2, string machineID)
|
||||
{
|
||||
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||
Session session1 = connection1.Session;
|
||||
|
||||
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||
Session session2 = connection1.Session;
|
||||
|
||||
|
||||
Machine machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine1.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine1.Use.Use().ConfigureAwait(false);
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
Machine machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Check.Reject().ConfigureAwait(false);
|
||||
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine2.Check.Check().ConfigureAwait(false);
|
||||
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
|
||||
Assert.AreEqual(MachineState.free, machine1.State);
|
||||
}
|
||||
|
||||
[TestCase("MakerA1", "GuestA1", "ManagerA1", "MachineA1")]
|
||||
[Order(4), Ignore("Not Implemented")]
|
||||
public async Task CheckMachine_NoPermission(string username1, string username2, string username3, string machineID)
|
||||
{
|
||||
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||
Session session1 = connection1.Session;
|
||||
|
||||
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||
Session session2 = connection1.Session;
|
||||
|
||||
Connection connection3 = await API_TestEnv_Test.Connect(username3);
|
||||
Session session3 = connection3.Session;
|
||||
|
||||
Machine machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine1.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
await machine1.Use.Use().ConfigureAwait(false);
|
||||
machine1 = (await session1.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||
|
||||
Machine machine2 = (await session2.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
bool result = ((CheckInterface_Proxy)machine2.Check).IsNull;
|
||||
|
||||
Machine machine3 = (await session3.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
await machine3.Check.Check().ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection1);
|
||||
API_TestEnv_Test.Disconnect(connection2);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestCase("ManagerA1", "MachineA1")]
|
||||
[Order(5)]
|
||||
public async Task CurrentUser(string username, string machineID)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
Machine machine = (await session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
|
||||
|
||||
// Check State before run Test
|
||||
if (machine.State != MachineState.free)
|
||||
{
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
Assert.Inconclusive("State is not 'free'");
|
||||
}
|
||||
|
||||
MachineInfoExtended machineInfoExtended = await machine.Manage.GetMachineInfoExtended().ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.IsNull(machineInfoExtended.CurrentUser.Just);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Parallelizable(ParallelScope.Children)]
|
||||
[Order(4)]
|
||||
public class PermissionSystem_Test
|
||||
{
|
||||
[TestCase("Admin1", true)]
|
||||
[TestCase("ManagerA1", true)]
|
||||
[TestCase("MakerA1", true)]
|
||||
[TestCase("GuestA1", true)]
|
||||
[Order(1)]
|
||||
public async Task AccessPermissionSystem(string username, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
bool result = session.PermissionSystem != null;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
//[TestCase("Admin1", true)]
|
||||
//[TestCase("ManagerA1", true)]
|
||||
//[TestCase("MakerA1", true)]
|
||||
//[TestCase("GuestA1", true)]
|
||||
//[Order(2)]
|
||||
//public async Task InfoInterface(string username, bool expectInterface)
|
||||
//{
|
||||
// Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
// Session session = connection.Session;
|
||||
|
||||
// MachineSystem.IInfoInterface infoInterface = await session.PermissionSystem.Info().ConfigureAwait(false);
|
||||
|
||||
// bool result = !((Machine.InfoInterface_Proxy)machine.Info).IsNull;
|
||||
|
||||
// API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
// Assert.AreEqual(expectInterface, result);
|
||||
//}
|
||||
|
||||
[TestCase("Admin1", 13)]
|
||||
[TestCase("ManagerA1", 13)]
|
||||
[TestCase("MakerA1", 13)]
|
||||
[TestCase("GuestA1", 13)]
|
||||
[Order(3), Ignore("Not Implemented")]
|
||||
public async Task ListRoles(string username, int expectRolesCount)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
IReadOnlyList<Role> roles_list = await session.PermissionSystem.Info.GetRoleList().ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectRolesCount, roles_list.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Parallelizable(ParallelScope.Children)]
|
||||
[Order(5)]
|
||||
public class UserSystem_Test
|
||||
{
|
||||
//[TestCase("Admin1", true)]
|
||||
//[TestCase("ManagerA1", true)]
|
||||
//[TestCase("MakerA1", true)]
|
||||
//[TestCase("GuestA1", true)]
|
||||
//[Order(2)]
|
||||
//public async Task InfoInterface(string username, bool expectInterface)
|
||||
//{
|
||||
// Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
// Session session = connection.Session;
|
||||
|
||||
// UserSystem.IInfoInterface infoInterface = await session.UserSystem.Info().ConfigureAwait(false);
|
||||
|
||||
// bool result = !((UserSystem.InfoInterface_Proxy)infoInterface.Info).IsNull;
|
||||
|
||||
// API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
// Assert.AreEqual(expectInterface, result);
|
||||
//}
|
||||
|
||||
//[TestCase("Admin1", true)]
|
||||
//[TestCase("ManagerA1", false)]
|
||||
//[TestCase("MakerA1", false)]
|
||||
//[TestCase("GuestA1", false)]
|
||||
//[Order(3)]
|
||||
//public async Task ManageInterface(string username, bool expectInterface)
|
||||
//{
|
||||
// Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
// Session session = connection.Session;
|
||||
|
||||
// UserSystem.IInfoInterface infoInterface = await session.UserSystem.Info().ConfigureAwait(false);
|
||||
|
||||
// bool result = !((UserSystem.InfoInterface_Proxy)infoInterface.Info).IsNull;
|
||||
|
||||
// API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
// Assert.AreEqual(expectInterface, result);
|
||||
//}
|
||||
|
||||
[TestCase("Admin1")]
|
||||
[TestCase("ManagerA1")]
|
||||
[TestCase("MakerA1")]
|
||||
[TestCase("GuestA1")]
|
||||
[Order(4)]
|
||||
public async Task GetUserSelf(string username)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.IsNotNull(user);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Parallelizable(ParallelScope.Children)]
|
||||
[Order(6)]
|
||||
public class User_Test_Stateless
|
||||
{
|
||||
[TestCase("Admin1", true)]
|
||||
[TestCase("ManagerA1", true)]
|
||||
[TestCase("MakerA1", true)]
|
||||
[TestCase("GuestA1", true)]
|
||||
[Order(1)]
|
||||
public async Task InfoInterface(string username, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
bool result = !((User.InfoInterface_Proxy)user.Info).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", true)]
|
||||
[TestCase("ManagerA1", true)]
|
||||
[TestCase("MakerA1", true)]
|
||||
[TestCase("GuestA1", true)]
|
||||
[Order(2), Ignore("Not Implemented")]
|
||||
public async Task ManageInterface(string username, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
bool result = !((User.ManageInterface_Proxy)user.Manage).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1", true)]
|
||||
[TestCase("ManagerA1", false)]
|
||||
[TestCase("MakerA1", false)]
|
||||
[TestCase("GuestA1", false)]
|
||||
[Order(3), Ignore("Not Implemented")]
|
||||
public async Task AdminInterface(string username, bool expectInterface)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
bool result = !((User.AdminInterface_Proxy)user.Admin).IsNull;
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.AreEqual(expectInterface, result);
|
||||
}
|
||||
|
||||
[TestCase("Admin1")]
|
||||
[TestCase("ManagerA1")]
|
||||
[TestCase("MakerA1")]
|
||||
[TestCase("GuestA1")]
|
||||
[Order(4)]
|
||||
public async Task ReadUserData(string username)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.AreEqual(username, user.Username);
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase("Admin1", "somerole")]
|
||||
[TestCase("ManagerA1")]
|
||||
[TestCase("MakerA1")]
|
||||
[TestCase("GuestA1")]
|
||||
[Order(5), Ignore("Not Implemented")]
|
||||
public async Task ListUserRoles(string username, params string[] expect_roles)
|
||||
{
|
||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
||||
Session session = connection.Session;
|
||||
|
||||
User user = await session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
|
||||
List<Role> roles_user = new List<Role>(await user.Info.ListRoles().ConfigureAwait(false));
|
||||
List<string> expect_roles_list = new List<string>(expect_roles);
|
||||
|
||||
API_TestEnv_Test.Disconnect(connection);
|
||||
|
||||
if (roles_user.Count != expect_roles_list.Count)
|
||||
{
|
||||
Assert.Fail("Roles Count is different");
|
||||
}
|
||||
|
||||
foreach (Role role_user in roles_user)
|
||||
{
|
||||
if (!expect_roles_list.Exists(x => x == role_user.Name))
|
||||
{
|
||||
Assert.Fail("Roles are different");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
[Order(7)]
|
||||
public class User_Test
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FabAccessAPI_Test
|
||||
{
|
||||
|
||||
[TestFixture, Order(0)]
|
||||
public class Connection_Test
|
||||
{
|
||||
const string TESTSERVER = "bffh.lab.bln.kjknet.de";
|
||||
|
Loading…
x
Reference in New Issue
Block a user