mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Adds metadata aggregation to the media library enrichment job
This commit is contained in:
1 parent
c82fadc7a2
commit
66871ccf62
168 files changed
+3503
-1062
No files matched your search
+8
-15
@@ -1,16 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
using Lumina.Infrastructure.Core.Security;
|
||||
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
@@ -31,6 +30,8 @@ public class GetUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly LoginRequestFixture _loginRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserSettingsEndpointTests"/> class.
|
||||
@@ -95,20 +96,12 @@ public class GetUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string username = $"testuser_{Guid.NewGuid()}";
|
||||
dbContext.Users.Add(new UserEntity
|
||||
{
|
||||
Id = userId,
|
||||
Username = username,
|
||||
Password = _hashService.HashString("TestPass123!"),
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
CreatedBy = userId,
|
||||
CreatedOnUtc = DateTime.UtcNow
|
||||
});
|
||||
UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
|
||||
user.TotpSecret = null;
|
||||
dbContext.Users.Add(user);
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
|
||||
HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
|
||||
string content = await loginResponse.Content.ReadAsStringAsync();
|
||||
LoginResponse? loginResult = JsonSerializer.Deserialize<LoginResponse>(content, _jsonOptions);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
|
||||
|
||||
+28
-30
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.UsersManagement.Settings;
|
||||
using Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
@@ -8,10 +10,8 @@ using Lumina.Infrastructure.Core.Security;
|
||||
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
@@ -32,6 +32,9 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
private readonly UserEntityFixture _userEntityFixture = new();
|
||||
private readonly LoginRequestFixture _loginRequestFixture = new();
|
||||
private readonly UpdateUserSettingsRequestFixture _updateUserSettingsRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateUserSettingsEndpointTests"/> class.
|
||||
@@ -47,11 +50,12 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
public async Task UpdateUserSettings_WhenUnauthorized_ShouldReturnUnauthorizedResult()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserSettingsRequest request = new(
|
||||
IsPaginationEnabled: true,
|
||||
ItemsPerPage: 48,
|
||||
IgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true
|
||||
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(
|
||||
isPaginationEnabled: true,
|
||||
itemsPerPage: 48,
|
||||
shouldIgnoreThePrefixForAlphaPicker: false,
|
||||
isThemeCachingEnabled: true,
|
||||
shouldAggregateMetadataWhenMissing: false
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -77,11 +81,12 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
// Arrange
|
||||
HttpClient client = _apiFactory.CreateClient();
|
||||
await CreateAndAuthenticateUserAsync(client);
|
||||
UpdateUserSettingsRequest request = new(
|
||||
IsPaginationEnabled: true,
|
||||
ItemsPerPage: int.MaxValue,
|
||||
IgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true
|
||||
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(
|
||||
isPaginationEnabled: true,
|
||||
itemsPerPage: int.MaxValue,
|
||||
shouldIgnoreThePrefixForAlphaPicker: false,
|
||||
isThemeCachingEnabled: true,
|
||||
shouldAggregateMetadataWhenMissing: false
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -100,11 +105,12 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
// Arrange
|
||||
HttpClient client = _apiFactory.CreateClient();
|
||||
await CreateAndAuthenticateUserAsync(client);
|
||||
UpdateUserSettingsRequest request = new(
|
||||
IsPaginationEnabled: true,
|
||||
ItemsPerPage: int.MinValue,
|
||||
IgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true
|
||||
UpdateUserSettingsRequest request = _updateUserSettingsRequestFixture.Create(
|
||||
isPaginationEnabled: true,
|
||||
itemsPerPage: int.MinValue,
|
||||
shouldIgnoreThePrefixForAlphaPicker: false,
|
||||
isThemeCachingEnabled: true,
|
||||
shouldAggregateMetadataWhenMissing: false
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -132,20 +138,12 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string username = $"testuser_{Guid.NewGuid()}";
|
||||
dbContext.Users.Add(new UserEntity
|
||||
{
|
||||
Id = userId,
|
||||
Username = username,
|
||||
Password = _hashService.HashString("TestPass123!"),
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
CreatedBy = userId,
|
||||
CreatedOnUtc = DateTime.UtcNow
|
||||
});
|
||||
UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
|
||||
user.TotpSecret = null;
|
||||
dbContext.Users.Add(user);
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
|
||||
HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
|
||||
string content = await loginResponse.Content.ReadAsStringAsync();
|
||||
LoginResponse? loginResult = JsonSerializer.Deserialize<LoginResponse>(content, _jsonOptions);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
|
||||
|
||||
Reference in new issue
Block a user