/
softailor
/
gridient
Обзор
Документация
Войти
/
softailor
/
gridient
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/Gridient.Infrastructure.Authentication.Local.Tests/Extensions/ServiceCollectionExtensionsTests.cs
66 строк
3 KB
Jenkins
Auto add
18 фев 2026, 10:19
18 фев 2026, 10:19
1e6c4f8
Код
Авторство
О чём код?
using FluentAssertions; using Gridient.Core.Features; using Gridient.Core.Options; using Gridient.Core.Services.Interfaces; using Gridient.Infrastructure.Authentication.Local.Extensions; using Gridient.Infrastructure.Authentication.Local.Repositories; using Gridient.Infrastructure.Authentication.Local.Services; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Moq; using Xunit; namespace Gridient.Infrastructure.Authentication.Local.Tests.Extensions { public class ServiceCollectionExtensionsTests { #region AddGridientLocalAuth /// <summary> /// Проверяет, что AddGridientLocalAuth регистрирует ключевые сервисы Auth.Local в DI и они резолвятся. /// </summary> [Fact] public void AddGridientLocalAuth_ShouldRegisterExpectedServices() { var services = new ServiceCollection(); // External dependencies (repositories, core services) services.AddSingleton<IAuthUserRepository>(Mock.Of<IAuthUserRepository>()); services.AddSingleton<IRefreshTokenRepository>(Mock.Of<IRefreshTokenRepository>()); services.AddSingleton<IPasswordResetTokenRepository>(Mock.Of<IPasswordResetTokenRepository>()); services.AddSingleton<IUserService>(Mock.Of<IUserService>()); var config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary<string, string?> { ["Jwt:Secret"] = "0123456789abcdef0123456789abcdef", ["Jwt:Issuer"] = "Gridient", ["Jwt:Audience"] = "GridientUsers", ["Jwt:AccessTokenLifetimeMinutes"] = "15", ["Jwt:RefreshTokenLifetimeHours"] = "48", ["Registration:EnablePublicSignup"] = "true", ["Registration:EnableAdminCreation"] = "true" }) .Build(); services.AddGridientLocalAuth(config); var sp = services.BuildServiceProvider(); sp.GetService<IPasswordHasher>().Should().NotBeNull(); sp.GetService<ITokenService>().Should().NotBeNull(); sp.GetService<ILocalAuthService>().Should().NotBeNull(); sp.GetService<IRegistrationService>().Should().NotBeNull(); sp.GetService<IPasswordResetService>().Should().NotBeNull(); sp.GetServices<IClientFeatureProvider>().Should().NotBeEmpty(); sp.GetServices<Gridient.Core.Authorization.IResourceOperationProvider>().Should().NotBeEmpty(); // Ensure options binding is present sp.GetService<IOptions<RegistrationOptions>>().Should().NotBeNull(); } #endregion } }