Close data leaks: remove anonymous user creation, hide private playlists, validate uploads and clamp gateway ranges
This commit is contained in:
@@ -44,6 +44,23 @@ public sealed class ApiTestFixture : WebApplicationFactory<Program>, IAsyncLifet
|
||||
|
||||
public HttpClient CreateAnonymousClient() => CreateClient();
|
||||
|
||||
public async Task<long> SeedUserAsync(long? userId = null, string? name = null)
|
||||
{
|
||||
var id = userId ?? Random.Shared.NextInt64(1, long.MaxValue);
|
||||
var userName = name ?? $"user-{id}";
|
||||
|
||||
using var scope = Services.CreateScope();
|
||||
var database = scope.ServiceProvider.GetRequiredService<Musify.Infrastructure.Persistence.Database>();
|
||||
database.Users.Add(new Musify.Domain.Entities.User
|
||||
{
|
||||
Id = id,
|
||||
Name = userName,
|
||||
NormalizedName = userName.ToUpperInvariant()
|
||||
});
|
||||
await database.SaveChangesAsync();
|
||||
return id;
|
||||
}
|
||||
|
||||
public HttpClient CreateAuthenticatedClient(long userId, string userName = "test-user")
|
||||
{
|
||||
var client = CreateClient();
|
||||
|
||||
Reference in New Issue
Block a user