summary refs log tree commit diff
path: root/testFrontend/SafeNSound.FakeUser/UserStore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'testFrontend/SafeNSound.FakeUser/UserStore.cs')
-rw-r--r--testFrontend/SafeNSound.FakeUser/UserStore.cs18
1 files changed, 15 insertions, 3 deletions
diff --git a/testFrontend/SafeNSound.FakeUser/UserStore.cs b/testFrontend/SafeNSound.FakeUser/UserStore.cs

index 9b04efb..f643a68 100644 --- a/testFrontend/SafeNSound.FakeUser/UserStore.cs +++ b/testFrontend/SafeNSound.FakeUser/UserStore.cs
@@ -5,7 +5,7 @@ namespace SafeNSound.FakeUser; public class UserStore(SafeNSoundAuthentication authService, SafeNSoundConfiguration config) : IHostedService { public List<ClientContainer> Admins { get; } = Enumerable.Range(0, 1).Select(_ => new ClientContainer()).ToList(); public List<ClientContainer> Monitors { get; } = Enumerable.Range(0, 5).Select(_ => new ClientContainer()).ToList(); - public List<ClientContainer> Users { get; } = Enumerable.Range(0, 150000).Select(_ => new ClientContainer()).ToList(); + public List<ClientContainer> Users { get; } = Enumerable.Range(0, 15).Select(_ => new ClientContainer()).ToList(); public List<ClientContainer> AllUsers => [.. Users, .. Monitors, .. Admins]; public ClientContainer GetRandomUser() { @@ -51,8 +51,16 @@ public class UserStore(SafeNSoundAuthentication authService, SafeNSoundConfigura var tasks = ((ClientContainer[]) [..Users, ..Monitors, ..Admins]).Select(async container => { await ss.WaitAsync(); await authService.Register(container.Auth); - // container.Client = new SafeNSoundClient(config, (await authService.Login(container.Auth)).AccessToken); - // container.WhoAmI = await container.Client.WhoAmI(); + container.Client = new SafeNSoundClient(config, (await authService.Login(container.Auth)).AccessToken); + container.WhoAmI = await container.Client.WhoAmI(); + await container.Client.UpdateDevice(container.WhoAmI.DeviceId, new() { + Name = "FakeUser-" + container.Auth.Username, + }); + + if (container.Auth.UserType == "admin") { + await container.Client.MonitorAllUsers(); + } + ss.Release(); }).ToList(); await Task.WhenAll(tasks); @@ -76,6 +84,10 @@ public class UserStore(SafeNSoundAuthentication authService, SafeNSoundConfigura private async Task Cleanup(ClientContainer container) { if (container.Client == null) return; try { + _ = await container.Client.GetDevices(); + if(Random.Shared.Next(100)>50) + await container.Client.DeleteDevice(container.WhoAmI!.DeviceId); + else await container.Client.LogOut(); await container.Client.DeleteAccount(container.Auth); } catch {