604bfe919c
Apply comprehensive fixes from code reviews including: - Extract shared utilities (SqlFormatHelper, CellValueConverter, DbDestinationBase) - Add interface abstractions (IAuthenticationService, IDatabaseMigrator, IMisQueryBuilder) - Implement SecureStore for encrypted secrets storage - Fix error handling with proper HTTP status codes and logging - Optimize double enumeration in DevEtlRegistry - Add DataSync.Dev README for developer onboarding - Extract filter panel base classes to reduce duplication - Update code review docs to mark all issues as fixed
83 lines
2.6 KiB
C#
83 lines
2.6 KiB
C#
using JdeScoping.Core.Interfaces;
|
|
using JdeScoping.Infrastructure.Auth;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Shouldly;
|
|
|
|
namespace JdeScoping.Api.Tests.Configuration;
|
|
|
|
public class ServiceRegistrationTests
|
|
{
|
|
[Fact]
|
|
public void AddInfrastructure_WithUseFakeAuthTrue_RegistersFakeAuthService()
|
|
{
|
|
// Arrange
|
|
var services = new ServiceCollection();
|
|
services.AddLogging();
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
{
|
|
["Ldap:UseFakeAuth"] = "true"
|
|
})
|
|
.Build();
|
|
|
|
// Act
|
|
services.AddInfrastructure(configuration);
|
|
var provider = services.BuildServiceProvider();
|
|
var authService = provider.GetRequiredService<IAuthenticationService>();
|
|
|
|
// Assert
|
|
authService.ShouldBeOfType<FakeAuthService>();
|
|
}
|
|
|
|
[Fact]
|
|
public void AddInfrastructure_WithUseFakeAuthFalse_RegistersLdapAuthService()
|
|
{
|
|
// Arrange
|
|
var services = new ServiceCollection();
|
|
services.AddLogging();
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
{
|
|
["Ldap:UseFakeAuth"] = "false",
|
|
["Ldap:ServerUrls:0"] = "ldap://localhost:389",
|
|
["Ldap:SearchBase"] = "DC=example,DC=com"
|
|
})
|
|
.Build();
|
|
|
|
// Act
|
|
services.AddInfrastructure(configuration);
|
|
var provider = services.BuildServiceProvider();
|
|
var authService = provider.GetRequiredService<IAuthenticationService>();
|
|
|
|
// Assert
|
|
authService.ShouldBeOfType<LdapAuthService>();
|
|
}
|
|
|
|
[Fact]
|
|
public void AddInfrastructure_WithNoAuthConfig_RegistersLdapAuthServiceByDefault()
|
|
{
|
|
// Arrange
|
|
var services = new ServiceCollection();
|
|
services.AddLogging();
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
{
|
|
["Ldap:ServerUrls:0"] = "ldap://localhost:389",
|
|
["Ldap:SearchBase"] = "DC=example,DC=com"
|
|
})
|
|
.Build();
|
|
|
|
// Act
|
|
services.AddInfrastructure(configuration);
|
|
var provider = services.BuildServiceProvider();
|
|
var authService = provider.GetRequiredService<IAuthenticationService>();
|
|
|
|
// Assert
|
|
authService.ShouldBeOfType<LdapAuthService>();
|
|
}
|
|
}
|