backend: Enforce notification access and clear push devices

This commit is contained in:
GonnaHetzMe committed 2026-12-04 21:42:00 +01:00
1 parent ee5f1d3d10
commit 4f95c8a379
12 files changed
+145 -46

No files matched your search

@@ -36,6 +36,7 @@ public sealed class BackendFixture : IAsyncLifetime
.Build();
private readonly TestEmailSender email = new();
private ApiFactory? factory;
private int clientNumber;
internal TokenSaveGate TokenSaves { get; } = new();
internal IServiceProvider Services => factory!.Services;
@@ -62,7 +63,13 @@ public sealed class BackendFixture : IAsyncLifetime
internal HttpClient CreateClient(string? accessToken = null)
{
var client = factory!.CreateClient();
// Každý klient simuluje vlastní IP adresu a má vlastní limit požadavků na přihlášení.
var address = IPAddress.Parse($"2001:db8::{Interlocked.Increment(ref clientNumber):x}");
var server = factory!.Server;
var client = new HttpClient(server.CreateHandler(context => context.Connection.RemoteIpAddress = address))
{
BaseAddress = server.BaseAddress,
};
if (accessToken is not null)
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
return client;