started with tests

This commit is contained in:
TheJoKlLa 2024-03-28 14:30:22 +01:00
parent 296c0a29ee
commit 35b4e952f8
13 changed files with 1415 additions and 1013 deletions

@ -1 +1 @@
Subproject commit ec8352c6ae97a0c0b75ad8bcdd5b0cb156f753e7 Subproject commit 158d307d74a8e82d5b7c9f4de1afcb180cc6eceb

View File

@ -149,7 +149,7 @@ namespace FabAccessAPI_Test
try try
{ {
// Stop here and cut internet connection // Stop here and cut internet connection
await api.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false); await api.Session.Resources.List().ConfigureAwait(false);
} }
catch catch
{ {
@ -168,7 +168,5 @@ namespace FabAccessAPI_Test
ClassicAssert.AreEqual(1, event_Disconnected, "event_Disconnected"); ClassicAssert.AreEqual(1, event_Disconnected, "event_Disconnected");
}); });
} }
} }
} }

View File

@ -0,0 +1,137 @@
using FabAccessAPI;
using NUnit.Framework;
using System.Threading.Tasks;
using FabAccessAPI.Schema;
using NUnit.Framework.Legacy;
using System.Runtime.Serialization;
using Capnp.Rpc;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Xml.Serialization;
namespace FabAccessAPI_Test.API_SpecTests
{
[TestFixture, Parallelizable(ParallelScope.Children)]
public class Bootstrap
{
private bool _RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
private Stream _InjectSSL(Stream tcpstream)
{
SslStream sslStream = new SslStream(tcpstream, false, new RemoteCertificateValidationCallback(_RemoteCertificateValidationCallback));
sslStream.ReadTimeout = 5000;
sslStream.AuthenticateAsClient("bffhd");
sslStream.ReadTimeout = -1;
return sslStream;
}
[TestCase(1, 0)]
public async Task getAPIVersion(int major, int minor)
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.InjectMidlayer(_InjectSSL);
tcpRpcClient.Connect(TestEnv.TESTSERVER, TestEnv.TESTSERVER_PORT);
await tcpRpcClient.WhenConnected;
IBootstrap _Bootstrap = tcpRpcClient.GetMain<IBootstrap>();
FabAccessAPI.Schema.Version data = await _Bootstrap.GetAPIVersion().ConfigureAwait(false);
FabAccessAPI.Schema.Version expected = new FabAccessAPI.Schema.Version()
{
Major = major,
Minor = minor
};
tcpRpcClient.Dispose();
Assert.That(data, Is.EqualTo(expected));
}
[TestCase("bffhd", "TODO")]
public async Task getServerRelease(string name, string release)
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.InjectMidlayer(_InjectSSL);
tcpRpcClient.Connect(TestEnv.TESTSERVER, TestEnv.TESTSERVER_PORT);
await tcpRpcClient.WhenConnected;
IBootstrap _Bootstrap = tcpRpcClient.GetMain<IBootstrap>();
(string data_name, string data_release) = await _Bootstrap.GetServerRelease().ConfigureAwait(false);
tcpRpcClient.Dispose();
Assert.That(data_name, Is.EqualTo(name));
Assert.That(data_release, Is.EqualTo(release));
}
[TestCase("FabAccessTest", "test.fab-access.space")]
public async Task getServerInfo(string spacename, string instanceurl)
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.InjectMidlayer(_InjectSSL);
tcpRpcClient.Connect(TestEnv.TESTSERVER, TestEnv.TESTSERVER_PORT);
await tcpRpcClient.WhenConnected;
IBootstrap _Bootstrap = tcpRpcClient.GetMain<IBootstrap>();
(string data_spacename, string data_instanceurl) = await _Bootstrap.GetServerInfo().ConfigureAwait(false);
tcpRpcClient.Dispose();
Assert.That(data_spacename, Is.EqualTo(spacename));
Assert.That(data_instanceurl, Is.EqualTo(instanceurl));
}
[TestCase("FabAccessTest", "test.fab-access.space")]
public async Task mechanisms()
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.InjectMidlayer(_InjectSSL);
tcpRpcClient.Connect(TestEnv.TESTSERVER, TestEnv.TESTSERVER_PORT);
await tcpRpcClient.WhenConnected;
IBootstrap _Bootstrap = tcpRpcClient.GetMain<IBootstrap>();
Assert.Fail("Not Defined");
}
[TestCase("User0")]
public async Task APIConnect(string username)
{
API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData);
ServerData data = api.ServerData;
await api.Disconnect();
ServerData expected = new ServerData
{
APIVersion = new FabAccessAPI.Schema.Version()
{
Major = 1,
Minor = 0
},
ServerName = "bffhd",
ServerRelease = "TODO",
SpaceName = "FabAccessTest",
InstanceURL = "test.fab-access.space"
};
Assert.That(data, Is.EqualTo(expected));
}
}
}

View File

@ -1,199 +1,199 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture, Parallelizable(ParallelScope.Children)] // [TestFixture, Parallelizable(ParallelScope.Children)]
[Order(1)] // [Order(1)]
public class MachineSystem_Test_Stateless // public class MachineSystem_Test_Stateless
{ // {
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("Admin2", true)] // [TestCase("Admin2", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("ManagerA2", true)] // [TestCase("ManagerA2", true)]
[TestCase("ManagerB1", true)] // [TestCase("ManagerB1", true)]
[TestCase("ManagerB2", true)] // [TestCase("ManagerB2", true)]
[TestCase("ManagerC1", true)] // [TestCase("ManagerC1", true)]
[TestCase("ManagerC2", true)] // [TestCase("ManagerC2", true)]
[TestCase("ManagerABC1", true)] // [TestCase("ManagerABC1", true)]
[TestCase("ManagerABC2", true)] // [TestCase("ManagerABC2", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("MakerA2", true)] // [TestCase("MakerA2", true)]
[TestCase("MakerB1", true)] // [TestCase("MakerB1", true)]
[TestCase("MakerB2", true)] // [TestCase("MakerB2", true)]
[TestCase("MakerC1", true)] // [TestCase("MakerC1", true)]
[TestCase("MakerC2", true)] // [TestCase("MakerC2", true)]
[TestCase("MakerABC1", true)] // [TestCase("MakerABC1", true)]
[TestCase("MakerABC2", true)] // [TestCase("MakerABC2", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[TestCase("GuestA2", true)] // [TestCase("GuestA2", true)]
[TestCase("GuestB1", true)] // [TestCase("GuestB1", true)]
[TestCase("GuestB2", true)] // [TestCase("GuestB2", true)]
[TestCase("GuestC1", true)] // [TestCase("GuestC1", true)]
[TestCase("GuestC2", true)] // [TestCase("GuestC2", true)]
[TestCase("GuestABC1", true)] // [TestCase("GuestABC1", true)]
[TestCase("GuestABC2", true)] // [TestCase("GuestABC2", true)]
[TestCase("MakerQRA", true)] // [TestCase("MakerQRA", true)]
[TestCase("MakerQRB", true)] // [TestCase("MakerQRB", true)]
[TestCase("MakerQRC", true)] // [TestCase("MakerQRC", true)]
[Order(2)] // [Order(2)]
public async Task AccessMachineSystem_Info(string username, bool expectAllow) // public async Task AccessMachineSystem_Info(string username, bool expectAllow)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
ClassicAssert.AreEqual(expectAllow, !((MachineSystem.InfoInterface_Proxy)api.Session.MachineSystem.Info).IsNull); // ClassicAssert.AreEqual(expectAllow, !((MachineSystem.InfoInterface_Proxy)api.Session.MachineSystem.Info).IsNull);
} // }
[TestCase("Admin1", 15)] // [TestCase("Admin1", 15)]
[TestCase("ManagerA1", 5)] // [TestCase("ManagerA1", 5)]
[TestCase("ManagerB1", 5)] // [TestCase("ManagerB1", 5)]
[TestCase("ManagerC1", 5)] // [TestCase("ManagerC1", 5)]
[TestCase("ManagerABC1", 15)] // [TestCase("ManagerABC1", 15)]
[TestCase("MakerA1", 5)] // [TestCase("MakerA1", 5)]
[TestCase("MakerB1", 5)] // [TestCase("MakerB1", 5)]
[TestCase("MakerC1", 5)] // [TestCase("MakerC1", 5)]
[TestCase("MakerABC1", 15)] // [TestCase("MakerABC1", 15)]
[TestCase("GuestA1", 5)] // [TestCase("GuestA1", 5)]
[TestCase("GuestB1", 5)] // [TestCase("GuestB1", 5)]
[TestCase("GuestC1", 5)] // [TestCase("GuestC1", 5)]
[TestCase("GuestABC1", 15)] // [TestCase("GuestABC1", 15)]
[TestCase("MakerQRA", 0)] // [TestCase("MakerQRA", 0)]
[TestCase("MakerQRB", 0)] // [TestCase("MakerQRB", 0)]
[TestCase("MakerQRC", 0)] // [TestCase("MakerQRC", 0)]
[Order(3)] // [Order(3)]
public async Task ListMachines(string username, int expectedMachineCount) // public async Task ListMachines(string username, int expectedMachineCount)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
IReadOnlyList<Machine> machine_list = await api.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false); // IReadOnlyList<Machine> machine_list = await api.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false);
int result = machine_list.Count; // int result = machine_list.Count;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectedMachineCount, result); // ClassicAssert.AreEqual(expectedMachineCount, result);
} // }
[TestCase("Admin1", "MachineA1", true)] // [TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)] // [TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)] // [TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)] // [TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerA1", "MachineB1", false)] // [TestCase("ManagerA1", "MachineB1", false)]
[TestCase("ManagerA1", "MachineC1", false)] // [TestCase("ManagerA1", "MachineC1", false)]
[TestCase("ManagerB1", "MachineA1", false)] // [TestCase("ManagerB1", "MachineA1", false)]
[TestCase("ManagerB1", "MachineB1", true)] // [TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerB1", "MachineC1", false)] // [TestCase("ManagerB1", "MachineC1", false)]
[TestCase("ManagerC1", "MachineA1", false)] // [TestCase("ManagerC1", "MachineA1", false)]
[TestCase("ManagerC1", "MachineB1", false)] // [TestCase("ManagerC1", "MachineB1", false)]
[TestCase("ManagerC1", "MachineC1", true)] // [TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)] // [TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)] // [TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)] // [TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", true)] // [TestCase("MakerA1", "MachineA1", true)]
[TestCase("MakerB1", "MachineB1", true)] // [TestCase("MakerB1", "MachineB1", true)]
[TestCase("MakerC1", "MachineC1", true)] // [TestCase("MakerC1", "MachineC1", true)]
[TestCase("GuestA1", "MachineA1", true)] // [TestCase("GuestA1", "MachineA1", true)]
[TestCase("GuestB1", "MachineB1", true)] // [TestCase("GuestB1", "MachineB1", true)]
[TestCase("GuestC1", "MachineC1", true)] // [TestCase("GuestC1", "MachineC1", true)]
[TestCase("MakerQRA", "MachineA1", true)] // [TestCase("MakerQRA", "MachineA1", true)]
[TestCase("MakerQRB", "MachineB1", true)] // [TestCase("MakerQRB", "MachineB1", true)]
[TestCase("MakerQRC", "MachineC1", true)] // [TestCase("MakerQRC", "MachineC1", true)]
[Order(4)] // [Order(4)]
public async Task GetMachineByName(string username, string machineName, bool expectedAllow) // public async Task GetMachineByName(string username, string machineName, bool expectedAllow)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false); // Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false);
bool result = optional.Just != null; // bool result = optional.Just != null;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectedAllow, result); // ClassicAssert.AreEqual(expectedAllow, result);
} // }
[TestCase("Admin1", "MachineX")] // [TestCase("Admin1", "MachineX")]
[TestCase("Admin1", "urn:fabaccess:resource:MachineA1")] // [TestCase("Admin1", "urn:fabaccess:resource:MachineA1")]
[Order(5)] // [Order(5)]
public async Task GetMachineByName_WrongName(string username, string machineName) // public async Task GetMachineByName_WrongName(string username, string machineName)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false); // Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachine(machineName).ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNull(optional.Just); // ClassicAssert.IsNull(optional.Just);
} // }
[TestCase("Admin1", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("Admin1", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("Admin1", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("Admin1", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("Admin1", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("Admin1", "urn:fabaccess:resource:MachineC1", true)]
[TestCase("ManagerA1", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("ManagerA1", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("ManagerA1", "urn:fabaccess:resource:MachineB1", false)] // [TestCase("ManagerA1", "urn:fabaccess:resource:MachineB1", false)]
[TestCase("ManagerA1", "urn:fabaccess:resource:MachineC1", false)] // [TestCase("ManagerA1", "urn:fabaccess:resource:MachineC1", false)]
[TestCase("ManagerB1", "urn:fabaccess:resource:MachineA1", false)] // [TestCase("ManagerB1", "urn:fabaccess:resource:MachineA1", false)]
[TestCase("ManagerB1", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("ManagerB1", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("ManagerB1", "urn:fabaccess:resource:MachineC1", false)] // [TestCase("ManagerB1", "urn:fabaccess:resource:MachineC1", false)]
[TestCase("ManagerC1", "urn:fabaccess:resource:MachineA1", false)] // [TestCase("ManagerC1", "urn:fabaccess:resource:MachineA1", false)]
[TestCase("ManagerC1", "urn:fabaccess:resource:MachineB1", false)] // [TestCase("ManagerC1", "urn:fabaccess:resource:MachineB1", false)]
[TestCase("ManagerC1", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("ManagerC1", "urn:fabaccess:resource:MachineC1", true)]
[TestCase("ManagerABC1", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("ManagerABC1", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("ManagerABC1", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("ManagerABC1", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("ManagerABC1", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("ManagerABC1", "urn:fabaccess:resource:MachineC1", true)]
[TestCase("MakerA1", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("MakerA1", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("MakerB1", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("MakerB1", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("MakerC1", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("MakerC1", "urn:fabaccess:resource:MachineC1", true)]
[TestCase("GuestA1", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("GuestA1", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("GuestB1", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("GuestB1", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("GuestC1", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("GuestC1", "urn:fabaccess:resource:MachineC1", true)]
[TestCase("MakerQRA", "urn:fabaccess:resource:MachineA1", true)] // [TestCase("MakerQRA", "urn:fabaccess:resource:MachineA1", true)]
[TestCase("MakerQRB", "urn:fabaccess:resource:MachineB1", true)] // [TestCase("MakerQRB", "urn:fabaccess:resource:MachineB1", true)]
[TestCase("MakerQRC", "urn:fabaccess:resource:MachineC1", true)] // [TestCase("MakerQRC", "urn:fabaccess:resource:MachineC1", true)]
[Order(6)] // [Order(6)]
public async Task GetMachineByURN(string username, string urn, bool expectedAllow) // public async Task GetMachineByURN(string username, string urn, bool expectedAllow)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false); // Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false);
bool result = optional.Just != null; // bool result = optional.Just != null;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectedAllow, result); // ClassicAssert.AreEqual(expectedAllow, result);
} // }
[TestCase("Admin1", "urn:fabaccess:resource:MachineX")] // [TestCase("Admin1", "urn:fabaccess:resource:MachineX")]
[TestCase("Admin1", "MachineA1")] // [TestCase("Admin1", "MachineA1")]
[TestCase("Admin1", "something")] // [TestCase("Admin1", "something")]
[Order(7)] // [Order(7)]
public async Task GetMachineByURN_WrongURN(string username, string urn) // public async Task GetMachineByURN_WrongURN(string username, string urn)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false); // Optional<Machine> optional = await api.Session.MachineSystem.Info.GetMachineURN(urn).ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNull(optional.Just); // ClassicAssert.IsNull(optional.Just);
} // }
} // }
} // }

View File

@ -1,301 +1,301 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture] // [TestFixture]
public class Machine_Test // public class Machine_Test
{ // {
#region SetUp // #region SetUp
[SetUp] // [SetUp]
public async Task SetUp() // public async Task SetUp()
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1"); // ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1");
await api.Connect(connectionData); // await api.Connect(connectionData);
IReadOnlyList<Machine> machine_list = await api.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false); // IReadOnlyList<Machine> machine_list = await api.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false);
List<Task> tasks = new List<Task>(); // List<Task> tasks = new List<Task>();
foreach (Machine m in machine_list) // foreach (Machine m in machine_list)
{ // {
tasks.Add(m.Manage.ForceFree()); // tasks.Add(m.Manage.ForceFree());
} // }
await Task.WhenAll(tasks); // await Task.WhenAll(tasks);
} // }
#endregion // #endregion
[TestCase("Admin1", "MachineA1")] // [TestCase("Admin1", "MachineA1")]
[TestCase("ManagerA1", "MachineA1")] // [TestCase("ManagerA1", "MachineA1")]
[TestCase("MakerA1", "MachineA1")] // [TestCase("MakerA1", "MachineA1")]
[Order(1)] // [Order(1)]
public async Task UseGiveBack(string username, string machineID) // public async Task UseGiveBack(string username, string machineID)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine.State != Machine.MachineState.free) // if (machine.State != Machine.MachineState.free)
{ // {
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine.Use.Use().ConfigureAwait(false); // await machine.Use.Use().ConfigureAwait(false);
machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine.Inuse.GiveBack().ConfigureAwait(false); // await machine.Inuse.GiveBack().ConfigureAwait(false);
machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(Machine.MachineState.free, machine.State); // ClassicAssert.AreEqual(Machine.MachineState.free, machine.State);
} // }
[TestCase("ManagerA1", "MakerA1", "MachineA1")] // [TestCase("ManagerA1", "MakerA1", "MachineA1")]
[TestCase("MakerA1", "Admin1", "MachineA1")] // [TestCase("MakerA1", "Admin1", "MachineA1")]
[TestCase("ManagerA1", "GuestA1", "MachineA1")] // [TestCase("ManagerA1", "GuestA1", "MachineA1")]
[Order(2), Ignore("Not Implemented")] // [Order(2), Ignore("Not Implemented")]
public async Task TransferMachine(string username1, string username2, string machineID) // public async Task TransferMachine(string username1, string username2, string machineID)
{ // {
API api1 = new API(); // API api1 = new API();
ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1); // ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1);
await api1.Connect(connectionData1); // await api1.Connect(connectionData1);
API api2 = new API(); // API api2 = new API();
ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2); // ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2);
await api2.Connect(connectionData2); // await api2.Connect(connectionData2);
Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine1.State != Machine.MachineState.free) // if (machine1.State != Machine.MachineState.free)
{ // {
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine1.Use.Use().ConfigureAwait(false); // await machine1.Use.Use().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false); // await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Takeover.Accept().ConfigureAwait(false); // await machine2.Takeover.Accept().ConfigureAwait(false);
machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Inuse.GiveBack().ConfigureAwait(false); // await machine2.Inuse.GiveBack().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State); // ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State);
} // }
[TestCase("ManagerA1", "MakerA1", "MachineA1")] // [TestCase("ManagerA1", "MakerA1", "MachineA1")]
[TestCase("MakerA1", "Admin1", "MachineA1")] // [TestCase("MakerA1", "Admin1", "MachineA1")]
[TestCase("ManagerA1", "GuestA1", "MachineA1")] // [TestCase("ManagerA1", "GuestA1", "MachineA1")]
[Order(3), Ignore("Not Implemented")] // [Order(3), Ignore("Not Implemented")]
public async Task TransferMachine_Reject(string username1, string username2, string machineID) // public async Task TransferMachine_Reject(string username1, string username2, string machineID)
{ // {
API api1 = new API(); // API api1 = new API();
ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1); // ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1);
await api1.Connect(connectionData1); // await api1.Connect(connectionData1);
API api2 = new API(); // API api2 = new API();
ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2); // ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2);
await api2.Connect(connectionData2); // await api2.Connect(connectionData2);
Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine1.State != Machine.MachineState.free) // if (machine1.State != Machine.MachineState.free)
{ // {
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine1.Use.Use().ConfigureAwait(false); // await machine1.Use.Use().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false); // await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Takeover.Reject().ConfigureAwait(false); // await machine2.Takeover.Reject().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.GiveBack().ConfigureAwait(false); // await machine1.Inuse.GiveBack().ConfigureAwait(false);
machine2 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine2 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.AreEqual(Machine.MachineState.free, machine2.State); // ClassicAssert.AreEqual(Machine.MachineState.free, machine2.State);
} // }
[TestCase("ManagerA1", "ManagerA1", "MachineA1")] // [TestCase("ManagerA1", "ManagerA1", "MachineA1")]
[TestCase("ManagerA1", "Admin1", "MachineA1")] // [TestCase("ManagerA1", "Admin1", "MachineA1")]
[TestCase("MakerA1", "Admin1", "MachineA1")] // [TestCase("MakerA1", "Admin1", "MachineA1")]
[Order(4), Ignore("Not Implemented")] // [Order(4), Ignore("Not Implemented")]
public async Task CheckMachine(string username1, string username2, string machineID) // public async Task CheckMachine(string username1, string username2, string machineID)
{ // {
API api1 = new API(); // API api1 = new API();
ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1); // ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1);
await api1.Connect(connectionData1); // await api1.Connect(connectionData1);
API api2 = new API(); // API api2 = new API();
ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2); // ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2);
await api2.Connect(connectionData2); // await api2.Connect(connectionData2);
Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine1.State != Machine.MachineState.free) // if (machine1.State != Machine.MachineState.free)
{ // {
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine1.Use.Use().ConfigureAwait(false); // await machine1.Use.Use().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.GiveBack().ConfigureAwait(false); // await machine1.Inuse.GiveBack().ConfigureAwait(false);
Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Check.Check().ConfigureAwait(false); // await machine2.Check.Check().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State); // ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State);
} // }
[TestCase("ManagerA1", "ManagerA1", "MachineA1")] // [TestCase("ManagerA1", "ManagerA1", "MachineA1")]
[TestCase("ManagerA1", "Admin1", "MachineA1")] // [TestCase("ManagerA1", "Admin1", "MachineA1")]
[TestCase("MakerA1", "Admin1", "MachineA1")] // [TestCase("MakerA1", "Admin1", "MachineA1")]
[Order(5), Ignore("Not Implemented")] // [Order(5), Ignore("Not Implemented")]
public async Task CheckMachine_Reject(string username1, string username2, string machineID) // public async Task CheckMachine_Reject(string username1, string username2, string machineID)
{ // {
API api1 = new API(); // API api1 = new API();
ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1); // ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1);
await api1.Connect(connectionData1); // await api1.Connect(connectionData1);
API api2 = new API(); // API api2 = new API();
ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2); // ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2);
await api2.Connect(connectionData2); // await api2.Connect(connectionData2);
Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine1.State != Machine.MachineState.free) // if (machine1.State != Machine.MachineState.free)
{ // {
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine1.Use.Use().ConfigureAwait(false); // await machine1.Use.Use().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.GiveBack().ConfigureAwait(false); // await machine1.Inuse.GiveBack().ConfigureAwait(false);
Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Check.Reject().ConfigureAwait(false); // await machine2.Check.Reject().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.GiveBack().ConfigureAwait(false); // await machine1.Inuse.GiveBack().ConfigureAwait(false);
machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine2.Check.Check().ConfigureAwait(false); // await machine2.Check.Check().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State); // ClassicAssert.AreEqual(Machine.MachineState.free, machine1.State);
} // }
[TestCase("MakerA1", "GuestA1", "ManagerA1", "MachineA1")] // [TestCase("MakerA1", "GuestA1", "ManagerA1", "MachineA1")]
[Order(4), Ignore("Not Implemented")] // [Order(4), Ignore("Not Implemented")]
public async Task CheckMachine_NoPermission(string username1, string username2, string username3, string machineID) // public async Task CheckMachine_NoPermission(string username1, string username2, string username3, string machineID)
{ // {
API api1 = new API(); // API api1 = new API();
ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1); // ConnectionData connectionData1 = TestEnv.CreateConnetionData(username1);
await api1.Connect(connectionData1); // await api1.Connect(connectionData1);
API api2 = new API(); // API api2 = new API();
ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2); // ConnectionData connectionData2 = TestEnv.CreateConnetionData(username2);
await api2.Connect(connectionData2); // await api2.Connect(connectionData2);
API api3 = new API(); // API api3 = new API();
ConnectionData connectionData3 = TestEnv.CreateConnetionData(username3); // ConnectionData connectionData3 = TestEnv.CreateConnetionData(username3);
await api3.Connect(connectionData3); // await api3.Connect(connectionData3);
Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine1.State != Machine.MachineState.free) // if (machine1.State != Machine.MachineState.free)
{ // {
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
await api3.Disconnect(); // await api3.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
await machine1.Use.Use().ConfigureAwait(false); // await machine1.Use.Use().ConfigureAwait(false);
machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // machine1 = (await api1.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine1.Inuse.GiveBack().ConfigureAwait(false); // await machine1.Inuse.GiveBack().ConfigureAwait(false);
Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine2 = (await api2.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
bool result = ((Machine.CheckInterface_Proxy)machine2.Check).IsNull; // bool result = ((Machine.CheckInterface_Proxy)machine2.Check).IsNull;
Machine machine3 = (await api3.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine3 = (await api3.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await machine3.Check.Check().ConfigureAwait(false); // await machine3.Check.Check().ConfigureAwait(false);
await api1.Disconnect(); // await api1.Disconnect();
await api2.Disconnect(); // await api2.Disconnect();
await api3.Disconnect(); // await api3.Disconnect();
ClassicAssert.IsTrue(result); // ClassicAssert.IsTrue(result);
} // }
[TestCase("ManagerA1", "MachineA1")] // [TestCase("ManagerA1", "MachineA1")]
[Order(5)] // [Order(5)]
public async Task CurrentUser(string username, string machineID) // public async Task CurrentUser(string username, string machineID)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
// Check State before run Test // // Check State before run Test
if (machine.State != Machine.MachineState.free) // if (machine.State != Machine.MachineState.free)
{ // {
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.Inconclusive("State is not 'free'"); // ClassicAssert.Inconclusive("State is not 'free'");
} // }
Machine.MachineInfoExtended machineInfoExtended = await machine.Manage.GetMachineInfoExtended().ConfigureAwait(false); // Machine.MachineInfoExtended machineInfoExtended = await machine.Manage.GetMachineInfoExtended().ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNull(machineInfoExtended.CurrentUser.Just); // ClassicAssert.IsNull(machineInfoExtended.CurrentUser.Just);
} // }
} // }
} // }

View File

@ -1,139 +1,139 @@
using FabAccessAPI; // using FabAccessAPI;
using NUnit.Framework; // using NUnit.Framework;
using System.Threading.Tasks; // using System.Threading.Tasks;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture, Parallelizable(ParallelScope.Children)] // [TestFixture, Parallelizable(ParallelScope.Children)]
[Order(2)] // [Order(2)]
public class Machine_Test_Stateless // public class Machine_Test_Stateless
{ // {
[TestCase("Admin1", "MachineA1", true)] // [TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)] // [TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)] // [TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)] // [TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerB1", "MachineB1", true)] // [TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerC1", "MachineC1", true)] // [TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)] // [TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)] // [TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)] // [TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", true)] // [TestCase("MakerA1", "MachineA1", true)]
[TestCase("MakerB1", "MachineB1", true)] // [TestCase("MakerB1", "MachineB1", true)]
[TestCase("MakerC1", "MachineC1", true)] // [TestCase("MakerC1", "MachineC1", true)]
[TestCase("GuestA1", "MachineA1", true)] // [TestCase("GuestA1", "MachineA1", true)]
[TestCase("GuestB1", "MachineB1", true)] // [TestCase("GuestB1", "MachineB1", true)]
[TestCase("GuestC1", "MachineC1", true)] // [TestCase("GuestC1", "MachineC1", true)]
[TestCase("MakerQRA", "MachineA1", true)] // [TestCase("MakerQRA", "MachineA1", true)]
[TestCase("MakerQRB", "MachineB1", true)] // [TestCase("MakerQRB", "MachineB1", true)]
[TestCase("MakerQRC", "MachineC1", true)] // [TestCase("MakerQRC", "MachineC1", true)]
[Order(1)] // [Order(1)]
public async Task InfoInterface(string username, string machineID, bool expectInterface) // public async Task InfoInterface(string username, string machineID, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
bool result = !((Machine.InfoInterface_Proxy)machine.Info).IsNull; // bool result = !((Machine.InfoInterface_Proxy)machine.Info).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", "MachineA1", true)] // [TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)] // [TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)] // [TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)] // [TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerB1", "MachineB1", true)] // [TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerC1", "MachineC1", true)] // [TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)] // [TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)] // [TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)] // [TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", false)] // [TestCase("MakerA1", "MachineA1", false)]
[TestCase("MakerB1", "MachineB1", false)] // [TestCase("MakerB1", "MachineB1", false)]
[TestCase("MakerC1", "MachineC1", false)] // [TestCase("MakerC1", "MachineC1", false)]
[TestCase("GuestA1", "MachineA1", false)] // [TestCase("GuestA1", "MachineA1", false)]
[TestCase("GuestB1", "MachineB1", false)] // [TestCase("GuestB1", "MachineB1", false)]
[TestCase("GuestC1", "MachineC1", false)] // [TestCase("GuestC1", "MachineC1", false)]
[TestCase("MakerQRA", "MachineA1", false)] // [TestCase("MakerQRA", "MachineA1", false)]
[TestCase("MakerQRB", "MachineB1", false)] // [TestCase("MakerQRB", "MachineB1", false)]
[TestCase("MakerQRC", "MachineC1", false)] // [TestCase("MakerQRC", "MachineC1", false)]
[Order(2)] // [Order(2)]
public async Task ManageInterface(string username, string machineID, bool expectInterface) // public async Task ManageInterface(string username, string machineID, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
bool result = !((Machine.ManageInterface_Proxy)machine.Manage).IsNull; // bool result = !((Machine.ManageInterface_Proxy)machine.Manage).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", "MachineA1", true)] // [TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)] // [TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)] // [TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", false)] // [TestCase("ManagerA1", "MachineA1", false)]
[TestCase("ManagerB1", "MachineB1", false)] // [TestCase("ManagerB1", "MachineB1", false)]
[TestCase("ManagerC1", "MachineC1", false)] // [TestCase("ManagerC1", "MachineC1", false)]
[TestCase("ManagerABC1", "MachineA1", false)] // [TestCase("ManagerABC1", "MachineA1", false)]
[TestCase("ManagerABC1", "MachineB1", false)] // [TestCase("ManagerABC1", "MachineB1", false)]
[TestCase("ManagerABC1", "MachineC1", false)] // [TestCase("ManagerABC1", "MachineC1", false)]
[TestCase("MakerA1", "MachineA1", false)] // [TestCase("MakerA1", "MachineA1", false)]
[TestCase("MakerB1", "MachineB1", false)] // [TestCase("MakerB1", "MachineB1", false)]
[TestCase("MakerC1", "MachineC1", false)] // [TestCase("MakerC1", "MachineC1", false)]
[TestCase("GuestA1", "MachineA1", false)] // [TestCase("GuestA1", "MachineA1", false)]
[TestCase("GuestB1", "MachineB1", false)] // [TestCase("GuestB1", "MachineB1", false)]
[TestCase("GuestC1", "MachineC1", false)] // [TestCase("GuestC1", "MachineC1", false)]
[TestCase("MakerQRA", "MachineA1", false)] // [TestCase("MakerQRA", "MachineA1", false)]
[TestCase("MakerQRB", "MachineB1", false)] // [TestCase("MakerQRB", "MachineB1", false)]
[TestCase("MakerQRC", "MachineC1", false)] // [TestCase("MakerQRC", "MachineC1", false)]
[Order(3), Ignore("Not Implemented")] // [Order(3), Ignore("Not Implemented")]
public async Task AdminInterface(string username, string machineID, bool expectInterface) // public async Task AdminInterface(string username, string machineID, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
bool result = !((Machine.AdminInterface_Proxy)machine.Admin).IsNull; // bool result = !((Machine.AdminInterface_Proxy)machine.Admin).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", "MachineA1", "Description of MachineA1", @"https://fab-access.readthedocs.io", "CategoryA")] // [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", "MachineB2", "Description of MachineB2", @"https://fab-access.readthedocs.io", "CategoryB")]
[TestCase("Admin1", "MachineC3", "Description of MachineC3", @"https://fab-access.readthedocs.io", "CategoryC")] // [TestCase("Admin1", "MachineC3", "Description of MachineC3", @"https://fab-access.readthedocs.io", "CategoryC")]
[Order(4)] // [Order(4)]
public async Task ReadMachineData(string username, string machineID, string description, string wiki, string category) // public async Task ReadMachineData(string username, string machineID, string description, string wiki, string category)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just; // Machine machine = (await api.Session.MachineSystem.Info.GetMachine(machineID).ConfigureAwait(false)).Just;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.Multiple(() => // ClassicAssert.Multiple(() =>
{ // {
ClassicAssert.AreEqual(machineID, machine.Id); // ClassicAssert.AreEqual(machineID, machine.Id);
ClassicAssert.AreEqual(description, machine.Description); // ClassicAssert.AreEqual(description, machine.Description);
ClassicAssert.AreEqual(wiki, machine.Wiki); // ClassicAssert.AreEqual(wiki, machine.Wiki);
ClassicAssert.AreEqual(category, machine.Category); // ClassicAssert.AreEqual(category, machine.Category);
}); // });
} // }
} // }
} // }

View File

@ -1,70 +1,70 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture, Parallelizable(ParallelScope.Children)] // [TestFixture, Parallelizable(ParallelScope.Children)]
[Order(1)] // [Order(1)]
public class PermissionSystem_Test_Stateless // public class PermissionSystem_Test_Stateless
{ // {
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[Order(1)] // [Order(1)]
public async Task AccessPermissionSystem(string username, bool expectInterface) // public async Task AccessPermissionSystem(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
bool result = api.Session.PermissionSystem != null; // bool result = api.Session.PermissionSystem != null;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[Order(2)] // [Order(2)]
public async Task InfoInterface(string username, bool expectInterface) // public async Task InfoInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
PermissionSystem.InfoInterface_Proxy infoInterface = (PermissionSystem.InfoInterface_Proxy)api.Session.PermissionSystem.Info; // PermissionSystem.InfoInterface_Proxy infoInterface = (PermissionSystem.InfoInterface_Proxy)api.Session.PermissionSystem.Info;
bool result = !infoInterface.IsNull; // bool result = !infoInterface.IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", 13)] // [TestCase("Admin1", 13)]
[TestCase("ManagerA1", 13)] // [TestCase("ManagerA1", 13)]
[TestCase("MakerA1", 13)] // [TestCase("MakerA1", 13)]
[TestCase("GuestA1", 13)] // [TestCase("GuestA1", 13)]
[Order(3), Ignore("Not implemented")] // [Order(3), Ignore("Not implemented")]
public async Task ListRoles(string username, int expectRolesCount) // public async Task ListRoles(string username, int expectRolesCount)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
IReadOnlyList<Role> roles_list = await api.Session.PermissionSystem.Info.GetRoleList().ConfigureAwait(false); // IReadOnlyList<Role> roles_list = await api.Session.PermissionSystem.Info.GetRoleList().ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectRolesCount, roles_list.Count); // ClassicAssert.AreEqual(expectRolesCount, roles_list.Count);
} // }
} // }
} // }

View File

@ -1,143 +1,143 @@
using Capnp.Rpc; // using Capnp.Rpc;
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture] // [TestFixture]
public class UserSystem_Test // public class UserSystem_Test
{ // {
#region SetUp // #region SetUp
[SetUp] // [SetUp]
public async Task SetUp() // public async Task SetUp()
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1"); // ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1");
await api.Connect(connectionData); // await api.Connect(connectionData);
IReadOnlyList<User> user_list = await api.Session.UserSystem.Manage.GetUserList().ConfigureAwait(false); // IReadOnlyList<User> user_list = await api.Session.UserSystem.Manage.GetUserList().ConfigureAwait(false);
List<Task> tasks = new List<Task>(); // List<Task> tasks = new List<Task>();
foreach (User u in user_list) // foreach (User u in user_list)
{ // {
if(u.Username.StartsWith("New")) // if(u.Username.StartsWith("New"))
{ // {
tasks.Add(api.Session.UserSystem.Manage.RemoveUser(u)); // tasks.Add(api.Session.UserSystem.Manage.RemoveUser(u));
} // }
} // }
await Task.WhenAll(tasks); // await Task.WhenAll(tasks);
} // }
#endregion // #endregion
[TestCase("Admin1", "NewUserA1")] // [TestCase("Admin1", "NewUserA1")]
[Order(1)] // [Order(1)]
public async Task AddUser_DEPRECATED(string username, string username2) // public async Task AddUser_DEPRECATED(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
bool methodNotImplemented = false; // bool methodNotImplemented = false;
try // try
{ // {
User user = (await api.Session.UserSystem.Manage.AddUser(username2, TestEnv.PASSWORD).ConfigureAwait(false)); // User user = (await api.Session.UserSystem.Manage.AddUser(username2, TestEnv.PASSWORD).ConfigureAwait(false));
} // }
catch (RpcException exception) when (string.Equals(exception.Message, "method not implemented", StringComparison.Ordinal)) // catch (RpcException exception) when (string.Equals(exception.Message, "method not implemented", StringComparison.Ordinal))
{ // {
methodNotImplemented = true; // methodNotImplemented = true;
} // }
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsTrue(methodNotImplemented); // ClassicAssert.IsTrue(methodNotImplemented);
} // }
[TestCase("Admin1", "NewUserA1")] // [TestCase("Admin1", "NewUserA1")]
[TestCase("Admin1", "NewUserB1")] // [TestCase("Admin1", "NewUserB1")]
[TestCase("Admin1", "NewUserC1")] // [TestCase("Admin1", "NewUserC1")]
[Order(1)] // [Order(1)]
public async Task AddUser(string username, string username2) // public async Task AddUser(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Successful; // User user = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Successful;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNotNull(user); // ClassicAssert.IsNotNull(user);
} // }
[TestCase("Admin1", "Admin1")] // [TestCase("Admin1", "Admin1")]
[TestCase("Admin1", "ManagerA1")] // [TestCase("Admin1", "ManagerA1")]
[TestCase("Admin1", "MakerA1")] // [TestCase("Admin1", "MakerA1")]
[TestCase("Admin1", "GuestA1")] // [TestCase("Admin1", "GuestA1")]
[Order(2)] // [Order(2)]
public async Task AddUser_AllreadyExists(string username, string username2) // public async Task AddUser_AllreadyExists(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Failed.Error; // UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Failed.Error;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.alreadyExists, error); // ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.alreadyExists, error);
} // }
[TestCase("Admin1", "")] // [TestCase("Admin1", "")]
[Order(2)] // [Order(2)]
public async Task AddUser_InvalidUsername(string username, string username2) // public async Task AddUser_InvalidUsername(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Failed.Error; // UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Failed.Error;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.usernameInvalid, error); // ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.usernameInvalid, error);
} // }
[TestCase("Admin1", "NewUserC1", "")] // [TestCase("Admin1", "NewUserC1", "")]
[Order(2)] // [Order(2)]
public async Task AddUser_InvalidPassword(string username, string username2, string password) // public async Task AddUser_InvalidPassword(string username, string username2, string password)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, password).ConfigureAwait(false)).Failed.Error; // UserSystem.ManageInterface.AddUserError.AddUserErrorEnum error = (await api.Session.UserSystem.Manage.AddUserFallible(username2, password).ConfigureAwait(false)).Failed.Error;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.passwordInvalid, error); // ClassicAssert.AreEqual(UserSystem.ManageInterface.AddUserError.AddUserErrorEnum.passwordInvalid, error);
} // }
[TestCase("Admin1", "NewUserA1")] // [TestCase("Admin1", "NewUserA1")]
[TestCase("Admin1", "NewUserB1")] // [TestCase("Admin1", "NewUserB1")]
[TestCase("Admin1", "NewUserC1")] // [TestCase("Admin1", "NewUserC1")]
[Order(3)] // [Order(3)]
public async Task AddRemoveUser(string username, string username2) // public async Task AddRemoveUser(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Successful; // User user = (await api.Session.UserSystem.Manage.AddUserFallible(username2, TestEnv.PASSWORD).ConfigureAwait(false)).Successful;
await api.Session.UserSystem.Manage.RemoveUser(user); // await api.Session.UserSystem.Manage.RemoveUser(user);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNotNull(user); // ClassicAssert.IsNotNull(user);
} // }
} // }
} // }

View File

@ -1,123 +1,123 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture, Parallelizable(ParallelScope.Children)] // [TestFixture, Parallelizable(ParallelScope.Children)]
[Order(1)] // [Order(1)]
public class UserSystem_Test_Stateless // public class UserSystem_Test_Stateless
{ // {
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[Order(2)] // [Order(2)]
public async Task InfoInterface(string username, bool expectInterface) // public async Task InfoInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.InfoInterface_Proxy infoInterface = (UserSystem.InfoInterface_Proxy)api.Session.UserSystem.Info; // UserSystem.InfoInterface_Proxy infoInterface = (UserSystem.InfoInterface_Proxy)api.Session.UserSystem.Info;
bool result = !infoInterface.IsNull; // bool result = !infoInterface.IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", false)] // [TestCase("MakerA1", false)]
[TestCase("GuestA1", false)] // [TestCase("GuestA1", false)]
[Order(3)] // [Order(3)]
public async Task ManageInterface(string username, bool expectInterface) // public async Task ManageInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.ManageInterface_Proxy manageInterface = (UserSystem.ManageInterface_Proxy)api.Session.UserSystem.Manage; // UserSystem.ManageInterface_Proxy manageInterface = (UserSystem.ManageInterface_Proxy)api.Session.UserSystem.Manage;
bool result = !manageInterface.IsNull; // bool result = !manageInterface.IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", false)] // [TestCase("MakerA1", false)]
[TestCase("GuestA1", false)] // [TestCase("GuestA1", false)]
[Order(3)] // [Order(3)]
public async Task SearchInterface(string username, bool expectInterface) // public async Task SearchInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
UserSystem.SearchInterface_Proxy searchInterface = (UserSystem.SearchInterface_Proxy)api.Session.UserSystem.Search; // UserSystem.SearchInterface_Proxy searchInterface = (UserSystem.SearchInterface_Proxy)api.Session.UserSystem.Search;
bool result = !searchInterface.IsNull; // bool result = !searchInterface.IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1")] // [TestCase("Admin1")]
[TestCase("ManagerA1")] // [TestCase("ManagerA1")]
[TestCase("MakerA1")] // [TestCase("MakerA1")]
[TestCase("GuestA1")] // [TestCase("GuestA1")]
[Order(4)] // [Order(4)]
public async Task GetUserSelf(string username) // public async Task GetUserSelf(string username)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNotNull(user); // ClassicAssert.IsNotNull(user);
} // }
[TestCase("Admin1", "Admin1")] // [TestCase("Admin1", "Admin1")]
[TestCase("Admin1", "MakerA1")] // [TestCase("Admin1", "MakerA1")]
[TestCase("Admin1", "GuestA1")] // [TestCase("Admin1", "GuestA1")]
[Order(4)] // [Order(4)]
public async Task GetUserByUsername(string username, string username2) // public async Task GetUserByUsername(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just; // User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNotNull(user); // ClassicAssert.IsNotNull(user);
} // }
[TestCase("Admin1", "UnknownUser")] // [TestCase("Admin1", "UnknownUser")]
[Order(5)] // [Order(5)]
public async Task GetUserByUsername_NotExist(string username, string username2) // public async Task GetUserByUsername_NotExist(string username, string username2)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just; // User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.IsNull(user); // ClassicAssert.IsNull(user);
} // }
} // }
} // }

View File

@ -1,69 +1,69 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture] // [TestFixture]
public class User_Test // public class User_Test
{ // {
#region SetUp // #region SetUp
[SetUp] // [SetUp]
public async Task SetUp() // public async Task SetUp()
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1"); // ConnectionData connectionData = TestEnv.CreateConnetionData("Admin1");
await api.Connect(connectionData); // await api.Connect(connectionData);
IReadOnlyList<User> user_list = await api.Session.UserSystem.Manage.GetUserList().ConfigureAwait(false); // IReadOnlyList<User> user_list = await api.Session.UserSystem.Manage.GetUserList().ConfigureAwait(false);
List<Task> tasks = new List<Task>(); // List<Task> tasks = new List<Task>();
foreach (User u in user_list) // foreach (User u in user_list)
{ // {
if (u.Username.StartsWith("New")) // if (u.Username.StartsWith("New"))
{ // {
tasks.Add(api.Session.UserSystem.Manage.RemoveUser(u)); // tasks.Add(api.Session.UserSystem.Manage.RemoveUser(u));
} // }
} // }
await Task.WhenAll(tasks); // await Task.WhenAll(tasks);
} // }
#endregion // #endregion
[TestCase("Admin1", "NewMakerA1", "UseA", "ReadA", "DiscloseA")] // [TestCase("Admin1", "NewMakerA1", "UseA", "ReadA", "DiscloseA")]
[Order(1)] // [Order(1)]
[Ignore("Deprecated")] // [Ignore("Deprecated")]
public async Task AddRoles(string username, string username2, params string[] roles) // public async Task AddRoles(string username, string username2, params string[] roles)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
await api.Session.UserSystem.Manage.AddUser(username2, TestEnv.PASSWORD); // await api.Session.UserSystem.Manage.AddUser(username2, TestEnv.PASSWORD);
User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just; // User user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just;
foreach(string s in roles) // foreach(string s in roles)
{ // {
await user.Admin.AddRole(new Role() { Name = s }).ConfigureAwait(false); // await user.Admin.AddRole(new Role() { Name = s }).ConfigureAwait(false);
} // }
user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just; // user = (await api.Session.UserSystem.Search.GetUserByName(username2).ConfigureAwait(false)).Just;
List<Role> user_roles = new List<Role>(await user.Info.ListRoles().ConfigureAwait(false)); // List<Role> user_roles = new List<Role>(await user.Info.ListRoles().ConfigureAwait(false));
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.Multiple(() => // ClassicAssert.Multiple(() =>
{ // {
ClassicAssert.AreEqual(3, user_roles.Count); // ClassicAssert.AreEqual(3, user_roles.Count);
foreach (string s in roles) // foreach (string s in roles)
{ // {
ClassicAssert.IsTrue(user_roles.Exists(x => x.Name == s)); // ClassicAssert.IsTrue(user_roles.Exists(x => x.Name == s));
} // }
}); // });
} // }
} // }
} // }

View File

@ -1,127 +1,127 @@
using FabAccessAPI; // using FabAccessAPI;
using FabAccessAPI.Schema; // using FabAccessAPI.Schema;
using NUnit.Framework; // using NUnit.Framework;
using NUnit.Framework.Legacy; // using NUnit.Framework.Legacy;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Threading.Tasks; // using System.Threading.Tasks;
namespace FabAccessAPI_Test.API_TestEnv // namespace FabAccessAPI_Test.API_TestEnv
{ // {
[TestFixture, Parallelizable(ParallelScope.Children)] // [TestFixture, Parallelizable(ParallelScope.Children)]
[Order(2)] // [Order(2)]
public class User_Test_Stateless // public class User_Test_Stateless
{ // {
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[Order(1)] // [Order(1)]
public async Task InfoInterface(string username, bool expectInterface) // public async Task InfoInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
bool result = !((User.InfoInterface_Proxy)user.Info).IsNull; // bool result = !((User.InfoInterface_Proxy)user.Info).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", true)] // [TestCase("MakerA1", true)]
[TestCase("GuestA1", true)] // [TestCase("GuestA1", true)]
[Order(2)] // [Order(2)]
public async Task ManageInterface(string username, bool expectInterface) // public async Task ManageInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
bool result = !((User.ManageInterface_Proxy)user.Manage).IsNull; // bool result = !((User.ManageInterface_Proxy)user.Manage).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1", true)] // [TestCase("Admin1", true)]
[TestCase("ManagerA1", true)] // [TestCase("ManagerA1", true)]
[TestCase("MakerA1", false)] // [TestCase("MakerA1", false)]
[TestCase("GuestA1", false)] // [TestCase("GuestA1", false)]
[Order(3)] // [Order(3)]
public async Task AdminInterface(string username, bool expectInterface) // public async Task AdminInterface(string username, bool expectInterface)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
bool result = !((User.AdminInterface_Proxy)user.Admin).IsNull; // bool result = !((User.AdminInterface_Proxy)user.Admin).IsNull;
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.AreEqual(expectInterface, result); // ClassicAssert.AreEqual(expectInterface, result);
} // }
[TestCase("Admin1")] // [TestCase("Admin1")]
[TestCase("ManagerA1")] // [TestCase("ManagerA1")]
[TestCase("MakerA1")] // [TestCase("MakerA1")]
[TestCase("GuestA1")] // [TestCase("GuestA1")]
[Order(4)] // [Order(4)]
public async Task ReadUserData(string username) // public async Task ReadUserData(string username)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
await api.Disconnect(); // await api.Disconnect();
ClassicAssert.Multiple(() => // ClassicAssert.Multiple(() =>
{ // {
ClassicAssert.AreEqual(username, user.Username); // ClassicAssert.AreEqual(username, user.Username);
}); // });
} // }
[TestCase("Admin1", "Admin", "ManageUsers")] // [TestCase("Admin1", "Admin", "ManageUsers")]
[TestCase("ManagerA1", "ManageA", "UseA", "ReadA", "DiscloseA", "ManageUsers")] // [TestCase("ManagerA1", "ManageA", "UseA", "ReadA", "DiscloseA", "ManageUsers")]
[TestCase("MakerA1", "UseA", "ReadA", "DiscloseA")] // [TestCase("MakerA1", "UseA", "ReadA", "DiscloseA")]
[TestCase("GuestA1", "ReadA", "DiscloseA")] // [TestCase("GuestA1", "ReadA", "DiscloseA")]
[Order(5)] // [Order(5)]
public async Task ListUserRoles(string username, params string[] expect_roles) // public async Task ListUserRoles(string username, params string[] expect_roles)
{ // {
API api = new API(); // API api = new API();
ConnectionData connectionData = TestEnv.CreateConnetionData(username); // ConnectionData connectionData = TestEnv.CreateConnetionData(username);
await api.Connect(connectionData); // await api.Connect(connectionData);
User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); // User user = await api.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
List<Role> roles_user = new List<Role>(await user.Info.ListRoles().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); // List<string> expect_roles_list = new List<string>(expect_roles);
await api.Disconnect(); // await api.Disconnect();
if (roles_user.Count != expect_roles_list.Count) // if (roles_user.Count != expect_roles_list.Count)
{ // {
ClassicAssert.Fail("Roles Count is different"); // ClassicAssert.Fail("Roles Count is different");
} // }
foreach (Role role_user in roles_user) // foreach (Role role_user in roles_user)
{ // {
if (!expect_roles_list.Exists(x => x == role_user.Name)) // if (!expect_roles_list.Exists(x => x == role_user.Name))
{ // {
ClassicAssert.Fail("Roles are different"); // ClassicAssert.Fail("Roles are different");
} // }
} // }
} // }
} // }
} // }

View File

@ -12,7 +12,7 @@ namespace FabAccessAPI_Test
public const int TESTSERVER_PORT = 59661; public const int TESTSERVER_PORT = 59661;
public const string PASSWORD = "secret"; public const string PASSWORD = "secret";
[TestCase("Testuser")] [TestCase("UserA")]
public static ConnectionData CreateConnetionData(string username) public static ConnectionData CreateConnetionData(string username)
{ {
ConnectionData connectionData = new ConnectionData() ConnectionData connectionData = new ConnectionData()

267
usecase.md Normal file
View File

@ -0,0 +1,267 @@
Use Cases
===
# Requierements
+ User0 - User ohne Account
+ UserA - generischer User
+ UserB - generischer User mit gleichen Rollen wir UserA
+ UserC - generischer User ohne Rollen
+ MaschineA - frei zugängliche Resource mit festem Ort und Stromanschluss
+ TerminalA - NFC Reader bei MaschineA, welche nur MaschinA nutzen kann
+ RolleB - Rolle mit Berechtigungen MaschineB zu nutzen
+ MaschineB - beschränkt zugängliche Resource mit festem Ort und Stromanschluss
+ TerminalB - NFC Reader bei MaschineA, welche nur MaschineB mit PIN nutzen kann
+ TerminalB - NFC Reader bei MaschineA, welche nur MaschinB mit PIN nutzen kann
+ MaschineC - frei zugängliche Resource mit festem Ort und Stromanschluss, benötigt MaschineD zum funktionieren
+ MaschineD - Maschine mit welche von MaschineC gebraucht wird
+ MaschineE - Maschine, welche von meheren Nutzer gleichzeitig verwendet werden kann
+ ManagerA - User mit Berechtigung zum Verwalten von Usern und Vergeben von Berechtigungen
+ UserB
+ CardA - FabFireCard von UserA
+ CardB - FabFireCard von UserB
+ Borepin - Client zum Interagieren von BFFH über FabAccess API
+ BFFH - Server mit FabAccess API
# Assumptions
+ die Pin für alle FabFireCards eine User ist die gleiche
+ Terminals wissen für welche Maschine sie eine PIN benötigen
+ Terminals sind immer an einen Satz von Maschinen gebunden und könnten nur diese Ausleihen
+ Maschinen fallen in einen definierten State zurück, wenn der Claim disowned wird oder disown failed, wenn sich einen Maschine in einem bestimmten State befindet
+ User können entweder einen Claim oder einen Interset an der selben Resource haben
# Tests
## Serverdaten
User0 kann von BFFH im Bootstrape sich Informationen zu dem Serverrelease und namen holen und über die InstanceURL, sowie den Spacenamen.
## Accounterzeugung
*User0 geht zu ManagerA und bittet um einen Account*
ManagerA öffnet Borepin, wird automatisch angemeldet
+ öffnet die Nutzerverwaltung
+ beginnt mit dem Anlegen eines neuen Nutzers
+ trägt den Nutzernamen ein
+ fügt zusätzliche Informationen hinzu
+ gerneriert ein Initialpasswort für User0
+ sagt User0 das Passwort / druckt User0 das Passwort aus / erstellt einen QR-Code mit Anmeldedaten / emuliert einen NTAG mit Anmeldedaten
User0 installiert Borepin, öffnet Borepin und
+ trägt die Serveradresse ein
+ verbindet sich mit dem Server
+ logt sich mit Username und Passwort ein
oder
+ scannt die Anmeldedaten per QR-Code / scannt die Anmeldedaten per NFC
+ verbindet sich mit dem Server und logt sich direkt ein
-> BFFH zwingt User0 ein neues Passwort zu setzen
User0 setzt ein neues Passwort
Borepin holt ein Token für die zukünftige Anmeldung des Gerätes
*User0 kann nun Resourcen ausleihen*
## Rollenvergabe
*UserA möchte MaschineB verwenden können*
UserA geht zu ManagerA und erhält eine Einweisung für MaschineB
ManagerA öffnet Borepin, wird automatisch angemeldet und
+ öffnet die Nutzerverwaltung
+ wählt UserA aus
+ fügt UserA RolleB zu
*UserA kann nun Borepin öffnen, wird automatisch angemeldet und kann MaschineB nutzten*
## Claim
*UserA steht vor MaschineA und möchte diese verwenden*
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA in einer Liste aus / scannt den QR-Code von MaschineA / scannt den NTAG von MaschineA
+ leiht MaschineA aus
+ schaltet den Strom von MaschineA frei
+ verwendet MaschineA
+ gibt MaschineA zurück, Strom wird gesperrt vom BFFH
*UserA hat MaschineA verwendet*
## Transfer
*UserA möchte UserB die MaschineB übergeben*
UserA hatte MaschineB ausgeliehen, öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA in einer Liste aus / scannt den QR-Code von MaschineA / scannt den NTAG von MaschineA
+ generiet ein Transfer QR-Code / emuliert eine Transfer NTAG
UserB öffnet Borepin, wird automatisch angemeldet und
+ scannt Transfer QR-Code / scannt Transfer NTAG
*UserB kann nun MaschineB verwenden, ohne das der Zustand der Maschine sich verändet hat*
## Lend/Instruct
*UserA möchte UserC an MaschineB ausbilden*
UserA hatte MaschineB ausgeliehen, öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA in einer Liste aus / scannt den QR-Code von MaschineA / scannt den NTAG von MaschineA
+ generiet ein Lend QR-Code / emuliert eine Lend NTAG
UserC öffnet Borepin, wird automatisch angemeldet und
+ scannt Lend QR-Code / scannt Lend NTAG
+ verwendet MaschineB
+ gibt MaschineB zurück
UserA erhält MaschineB zurück, prüft MaschineB, gibt MaschineB zurück
*UserC hat MaschineB verwendet, unter Verantwortung von UserA*
## FabFireCard Erzeugung
*UserA geht zu ManagerA und möchte ein FabFireCard erhalten*
ManagerA öffnet Borepin, wird automatisch angemeldet und
+ öffnet die Nutzerverwaltung
+ wählt UserA aus
+ hält eine leere DESFire Karte auf den NFC Scanner
+ legt eine FabFireCard für UserA an und beschreibt diese
+ gibt UserA die FabFireCard - Card A
UserA öffnet Borepin, wird automatisch angemeldet und
+ geht auf seinem Profil
+ setzt eine Pin für die FabFireCard
*UserA hat eine FabFireCard erhalten und eine zusätzliche Pin festgelegt*
## Passwortänderungen
*UserA möchte sein Passwort ändern*
UserA öffnet Borepin, wird automatisch angemeldet und
+ geht auf seinem Profil
+ beginnt mit dem Ändern des Passwort
+ gibt sein altes Passwort ein
+ gibt ein neues Passwort ein
*UserA hat sein Passwort geändert*
## FabFireCard Pin ändern
*UserA möchte seine PIN zur FabFireCard ändern*
UserA öffnet Borepin, wird automatisch angemeldet und
+ geht auf seinem Profil
+ beginnt mit dem Ändern der Pin
+ gibt sein Passwort ein
+ gibt eine neue PIN ein
*UserA hat seine PIN geändert*
## Passwort vergessen
*UserA geht zu ManagerA und bittet darum ein neues Passwort zu erhalten*
ManagerA öffnet Borepin, wird automatisch angemeldet und
+ öffnet die Nutzerverwaltung
+ wählt UserA aus
+ sagt User0 das Passwort / druckt User0 das Passwort aus / erstellt einen QR-Code mit Anmeldedaten / emuliert einen NTAG mit Anmeldedaten
__Gleiches Verhalten wie bei Accounterzeugung__
*UserA hat sein Passwort zurückgesetzt*
## Terminalnutzung
*UserA möchte MaschineA mit CardA ausleihen*
UserA steht vor TerminalA und
+ hält CardA auf den NFC Reader
TerminalA meldet sich bei BFFH und
+ leiht MaschineA für UserA aus
+ schaltet den Strom frei
UserA steht vor TerminalA und
+ gibt auf TerminalA ein, MaschineA zurückgeben
oder UserA öffnet Borepin, wird automatisch angemeldet und
+ gibt MaschinA zurück
*UserA hat MaschineA mit CardA ausgeliehen und verwendet*
## Terminalnutzung mit PIN
*UserA möchte MaschineB mit CardA ausleihen*
UserA steht vor TerminalB und
+ hält CardA auf den NFC Reader
-> TerminalB fordert eine PIN
+ tippt PIN ein
TerminalB meldet sich bei BFFH und
+ leiht MaschineB für UserA aus
+ schaltet den Strom frei
__Gleiches Verhalten wie bei Accounterzeugung__
*UserA hat MaschineA mit CardA ausgeliehen und verwendet*
## Reservieren
*UserA möchte für morgen MaschineA reservieren*
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ geht auf reservieren und trägt ein Zeitraum ein
-> UserA erhält zum Begin der Reservierung automatisch den Claim für die MaschineA, wenn dieser verfügbar ist
oder
-> UserA erhält zum Begin der Reservierung eine Benachrichtigung, dass die Maschine gerade verwendet wird
UserA geht zu ManagerA und bittet ihn die Maschine freizugeben
ManagerA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ entfernt den Claim
-> UserA erhält automatisch den Claim für MaschineA
*UserA kann MaschineA im Reservierungszeitraum nutzen*
## Queuing
*UserB verwendet gerade MaschineA und UserA möchte als nächster an MaschineA*
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ geht auf queuing
UserB gibt MaschineA zurück
-> UserA erhält automatisch ein Claim auf MaschineA
*UserA kann direkt nach UserB MaschineA nutzen*
## Intereset/Reservierung/Queuing aufhebn
*UserA hat einen Interest auf MaschineA*
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ beendet Interest
*UserA hat jetzt keinen Interest auf MaschineA*
## Benachrichten
*UserA möchte wissen wann die MaschineA frei ist*
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ aktiviert Benachrichtigungen für MaschineA (mit Optionen, um welchen State es geht)
-> BFFH benachrichtigt UserA, dass die MaschineA frei ist
-> Noftiy wird wieder gelöscht
oder
-> BFFH benachrichtigt UserA, dass die MaschineA frei ist
UserA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ deaktiviert Benachrichtigungen für MaschineA
*UserA wurde über Änderungen von MaschineA benachrichtigt*
## Abhängige Maschinen
*UserA möchte MaschineC ausleihen*
serA öffnet Borepin, wird automatisch angemeldet und
+ wählt MaschineA aus Liste aus
+ claimed MaschineA
-> MaschineD wird von BFFH geclaimed
## Kaputte Maschine melden
## Multi Claim
## Claim überschreiben
## Register