mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Implements file hashing media library scan job
This commit is contained in:
1 parent
66998055f0
commit
03a000e1e4
63 files changed
+2009
-287
No files matched your search
+2
-2
@@ -25,7 +25,7 @@ namespace Lumina.Presentation.Api.IntegrationTests.Common.Setup;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AuthenticatedLuminaApiFactory : LuminaApiFactory, IDisposable
|
||||
{
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
@@ -41,7 +41,7 @@ public class AuthenticatedLuminaApiFactory : LuminaApiFactory, IDisposable
|
||||
/// </summary>
|
||||
public AuthenticatedLuminaApiFactory()
|
||||
{
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class CheckInitializationEndpointTests : IClassFixture<AuthenticatedLumin
|
||||
UserEntity user = new()
|
||||
{
|
||||
Username = _testUsername,
|
||||
Password = new HashService().HashString("TestPass123!"),
|
||||
Password = new PasswordHashService().HashString("TestPass123!"),
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ public class SetupApplicationEndpointTests : IClassFixture<AuthenticatedLuminaAp
|
||||
UserEntity user = new()
|
||||
{
|
||||
Username = _testUsername,
|
||||
Password = new HashService().HashString("TestPass123!"),
|
||||
Password = new PasswordHashService().HashString("TestPass123!"),
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null, // TODO: test default role and permissions?
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ public class LoginEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>,
|
||||
{
|
||||
private HttpClient _client;
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly ICryptographyService _cryptographyService;
|
||||
private readonly TotpTokenGenerator _totpTokenGenerator;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
@@ -50,7 +50,7 @@ public class LoginEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>,
|
||||
{
|
||||
_client = apiFactory.CreateClient();
|
||||
_apiFactory = apiFactory;
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
_totpTokenGenerator = new TotpTokenGenerator();
|
||||
_testUsername = $"testuser_{Guid.NewGuid()}";
|
||||
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class RecoverPasswordEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
{
|
||||
private HttpClient _client;
|
||||
private readonly AuthenticatedLuminaApiFactory _apiFactory;
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly ICryptographyService _cryptographyService;
|
||||
private readonly TotpTokenGenerator _totpTokenGenerator;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
@@ -52,7 +52,7 @@ public class RecoverPasswordEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
{
|
||||
_client = apiFactory.CreateClient();
|
||||
_apiFactory = apiFactory;
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
_totpTokenGenerator = new TotpTokenGenerator();
|
||||
_testUsername = $"testuser_{Guid.NewGuid()}";
|
||||
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ public class RegisterEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
|
||||
UserEntity user = new()
|
||||
{
|
||||
Username = _testUsername,
|
||||
Password = new HashService().HashString("TestPass123!"),
|
||||
Password = new PasswordHashService().HashString("TestPass123!"),
|
||||
Libraries = [],
|
||||
UserPermissions = [],
|
||||
UserRole = null,
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ public class ChangePasswordEndpointTests : IClassFixture<LuminaApiFactory>, IDis
|
||||
{
|
||||
private readonly LuminaApiFactory _apiFactory;
|
||||
private readonly HttpClient _client;
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly string _testUsername;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
@@ -42,7 +42,7 @@ public class ChangePasswordEndpointTests : IClassFixture<LuminaApiFactory>, IDis
|
||||
_client = apiFactory.CreateClient();
|
||||
_client.DefaultRequestHeaders.Clear();
|
||||
_client.DefaultRequestHeaders.Add("X-Forwarded-For", $"192.168.1.12");
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
_testUsername = $"testuser_{Guid.NewGuid()}";
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.UsersManagement.A
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
|
||||
{
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly ICryptographyService _cryptographyService;
|
||||
private readonly TotpTokenGenerator _totpTokenGenerator;
|
||||
private readonly LuminaApiFactory _apiFactory;
|
||||
@@ -49,7 +49,7 @@ public class LoginEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
|
||||
// set a fake IP for this test instance
|
||||
_client.DefaultRequestHeaders.Clear();
|
||||
_client.DefaultRequestHeaders.Add("X-Forwarded-For", $"192.168.1.1");
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
_totpTokenGenerator = new TotpTokenGenerator();
|
||||
_testUsername = $"testuser_{Guid.NewGuid()}";
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.UsersManagement.A
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
|
||||
{
|
||||
private readonly HashService _hashService;
|
||||
private readonly PasswordHashService _hashService;
|
||||
private readonly LuminaApiFactory _apiFactory;
|
||||
private readonly HttpClient _client;
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
@@ -38,7 +38,7 @@ public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposabl
|
||||
_client = apiFactory.CreateClient();
|
||||
_client.DefaultRequestHeaders.Clear();
|
||||
_client.DefaultRequestHeaders.Add("X-Forwarded-For", $"192.168.1.5");
|
||||
_hashService = new HashService();
|
||||
_hashService = new PasswordHashService();
|
||||
_testUsername = $"testuser_{Guid.NewGuid()}";
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Command
|
||||
public class SetupApplicationCommandHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly IHashService _mockHashService;
|
||||
private readonly IPasswordHashService _mockHashService;
|
||||
private readonly ICryptographyService _mockCryptographyService;
|
||||
private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
|
||||
private readonly IQRCodeGenerator _mockQRCodeGenerator;
|
||||
@@ -45,7 +45,7 @@ public class SetupApplicationCommandHandlerTests
|
||||
public SetupApplicationCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockHashService = Substitute.For<IHashService>();
|
||||
_mockHashService = Substitute.For<IPasswordHashService>();
|
||||
_mockCryptographyService = Substitute.For<ICryptographyService>();
|
||||
_mockTotpTokenGenerator = Substitute.For<ITotpTokenGenerator>();
|
||||
_mockQRCodeGenerator = Substitute.For<IQRCodeGenerator>();
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Comma
|
||||
public class ChangePasswordCommandHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly IHashService _mockHashService;
|
||||
private readonly IPasswordHashService _mockHashService;
|
||||
private readonly IUserRepository _mockUserRepository;
|
||||
private readonly ChangePasswordCommandHandler _sut;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ChangePasswordCommandHandlerTests
|
||||
public ChangePasswordCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockHashService = Substitute.For<IHashService>();
|
||||
_mockHashService = Substitute.For<IPasswordHashService>();
|
||||
_mockUserRepository = Substitute.For<IUserRepository>();
|
||||
|
||||
_mockUnitOfWork.GetRepository<IUserRepository>().Returns(_mockUserRepository);
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Comma
|
||||
public class RecoverPasswordCommandHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly IHashService _mockHashService;
|
||||
private readonly IPasswordHashService _mockHashService;
|
||||
private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
|
||||
private readonly ICryptographyService _mockCryptographyService;
|
||||
private readonly IUserRepository _mockUserRepository;
|
||||
@@ -37,7 +37,7 @@ public class RecoverPasswordCommandHandlerTests
|
||||
public RecoverPasswordCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockHashService = Substitute.For<IHashService>();
|
||||
_mockHashService = Substitute.For<IPasswordHashService>();
|
||||
_mockTotpTokenGenerator = Substitute.For<ITotpTokenGenerator>();
|
||||
_mockCryptographyService = Substitute.For<ICryptographyService>();
|
||||
_mockUserRepository = Substitute.For<IUserRepository>();
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Comma
|
||||
public class RegisterUserCommandHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly IHashService _mockHashService;
|
||||
private readonly IPasswordHashService _mockHashService;
|
||||
private readonly ICryptographyService _mockCryptographyService;
|
||||
private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
|
||||
private readonly IQRCodeGenerator _mockQRCodeGenerator;
|
||||
@@ -41,7 +41,7 @@ public class RegisterUserCommandHandlerTests
|
||||
public RegisterUserCommandHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockHashService = Substitute.For<IHashService>();
|
||||
_mockHashService = Substitute.For<IPasswordHashService>();
|
||||
_mockCryptographyService = Substitute.For<ICryptographyService>();
|
||||
_mockTotpTokenGenerator = Substitute.For<ITotpTokenGenerator>();
|
||||
_mockQRCodeGenerator = Substitute.For<IQRCodeGenerator>();
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Queri
|
||||
public class LoginUserQueryHandlerTests
|
||||
{
|
||||
private readonly IUnitOfWork _mockUnitOfWork;
|
||||
private readonly IHashService _mockHashService;
|
||||
private readonly IPasswordHashService _mockHashService;
|
||||
private readonly IJwtTokenGenerator _mockJwtTokenGenerator;
|
||||
private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
|
||||
private readonly ICryptographyService _mockCryptographyService;
|
||||
@@ -40,7 +40,7 @@ public class LoginUserQueryHandlerTests
|
||||
public LoginUserQueryHandlerTests()
|
||||
{
|
||||
_mockUnitOfWork = Substitute.For<IUnitOfWork>();
|
||||
_mockHashService = Substitute.For<IHashService>();
|
||||
_mockHashService = Substitute.For<IPasswordHashService>();
|
||||
_mockJwtTokenGenerator = Substitute.For<IJwtTokenGenerator>();
|
||||
_mockTotpTokenGenerator = Substitute.For<ITotpTokenGenerator>();
|
||||
_mockCryptographyService = Substitute.For<ICryptographyService>();
|
||||
|
||||
@@ -7,19 +7,19 @@ using System.Diagnostics.CodeAnalysis;
|
||||
namespace Lumina.Infrastructure.UnitTests.Core.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="HashService"/> class.
|
||||
/// Contains unit tests for the <see cref="PasswordHashService"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HashServiceTests
|
||||
{
|
||||
private readonly HashService _sut;
|
||||
private readonly PasswordHashService _sut;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HashServiceTests"/> class.
|
||||
/// </summary>
|
||||
public HashServiceTests()
|
||||
{
|
||||
_sut = new HashService();
|
||||
_sut = new PasswordHashService();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in new issue
Block a user