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