refactor: relocate options classes to dedicated Options folders

Move configuration options from Core/DataAccess/DataSync/ExcelIO to
dedicated Options folders within each project for better organization.
Update all references and tests accordingly.
This commit is contained in:
Joseph Doherty
2026-01-03 08:55:08 -05:00
parent 3cb73eb09f
commit ec4c8fab87
52 changed files with 4628 additions and 202 deletions
@@ -1,5 +1,5 @@
using JdeScoping.Core.Options;
using JdeScoping.Infrastructure.Auth;
using JdeScoping.Infrastructure.Options;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NSubstitute;
@@ -10,20 +10,16 @@ namespace JdeScoping.Infrastructure.Tests.Unit;
public class LdapAuthServiceTests
{
private readonly IOptions<LdapOptions> _ldapOptions;
private readonly IOptions<AuthOptions> _authOptions;
private readonly ILogger<LdapAuthService> _logger;
public LdapAuthServiceTests()
{
_ldapOptions = Options.Create(new LdapOptions
_ldapOptions = Microsoft.Extensions.Options.Options.Create(new LdapOptions
{
ServerUrls = ["ldap.test.com"],
GroupDn = "CN=TestGroup,DC=test,DC=com",
SearchBase = "DC=test,DC=com",
ConnectionTimeoutSeconds = 5
});
_authOptions = Options.Create(new AuthOptions
{
ConnectionTimeoutSeconds = 5,
AdminBypassUsers = []
});
_logger = Substitute.For<ILogger<LdapAuthService>>();
@@ -33,7 +29,7 @@ public class LdapAuthServiceTests
public async Task AuthenticateAsync_EmptyUsername_ReturnsFailure()
{
// Arrange
var service = new LdapAuthService(_ldapOptions, _authOptions, _logger);
var service = new LdapAuthService(_ldapOptions, _logger);
// Act
var result = await service.AuthenticateAsync("", "password");
@@ -47,7 +43,7 @@ public class LdapAuthServiceTests
public async Task AuthenticateAsync_EmptyPassword_ReturnsFailure()
{
// Arrange
var service = new LdapAuthService(_ldapOptions, _authOptions, _logger);
var service = new LdapAuthService(_ldapOptions, _logger);
// Act
var result = await service.AuthenticateAsync("user", "");
@@ -61,13 +57,14 @@ public class LdapAuthServiceTests
public async Task AuthenticateAsync_NoServersConfigured_ReturnsConnectionError()
{
// Arrange
var emptyServerOptions = Options.Create(new LdapOptions
var emptyServerOptions = Microsoft.Extensions.Options.Options.Create(new LdapOptions
{
ServerUrls = [],
GroupDn = "CN=TestGroup,DC=test,DC=com",
SearchBase = "DC=test,DC=com"
SearchBase = "DC=test,DC=com",
AdminBypassUsers = []
});
var service = new LdapAuthService(emptyServerOptions, _authOptions, _logger);
var service = new LdapAuthService(emptyServerOptions, _logger);
// Act
var result = await service.AuthenticateAsync("user", "password");
@@ -81,7 +78,7 @@ public class LdapAuthServiceTests
public void GetUserInfoAsync_ThrowsNotSupportedException()
{
// Arrange
var service = new LdapAuthService(_ldapOptions, _authOptions, _logger);
var service = new LdapAuthService(_ldapOptions, _logger);
// Act & Assert
Should.Throw<NotSupportedException>(() => service.GetUserInfoAsync("user").GetAwaiter().GetResult());
@@ -93,11 +90,15 @@ public class LdapAuthServiceTests
// Arrange
// Note: We can't fully test admin bypass without a real LDAP server since bind still happens.
// This test verifies the configuration is recognized by checking that bypass users are configured.
var authOptionsWithBypass = Options.Create(new AuthOptions
var ldapOptionsWithBypass = Microsoft.Extensions.Options.Options.Create(new LdapOptions
{
ServerUrls = ["ldap.test.com"],
GroupDn = "CN=TestGroup,DC=test,DC=com",
SearchBase = "DC=test,DC=com",
ConnectionTimeoutSeconds = 5,
AdminBypassUsers = ["bypassuser", "adminuser"]
});
var service = new LdapAuthService(_ldapOptions, authOptionsWithBypass, _logger);
var service = new LdapAuthService(ldapOptionsWithBypass, _logger);
// Act - attempt to authenticate the bypass user (will fail LDAP connection, but config is exercised)
var result = await service.AuthenticateAsync("bypassuser", "anypassword");
@@ -113,14 +114,15 @@ public class LdapAuthServiceTests
public async Task AuthenticateAsync_MultipleServersConfigured_TriesEachUntilAllFail()
{
// Arrange
var multiServerOptions = Options.Create(new LdapOptions
var multiServerOptions = Microsoft.Extensions.Options.Options.Create(new LdapOptions
{
ServerUrls = ["ldap1.test.com", "ldap2.test.com", "ldap3.test.com"],
GroupDn = "CN=TestGroup,DC=test,DC=com",
SearchBase = "DC=test,DC=com",
ConnectionTimeoutSeconds = 1 // Fast timeout for test
ConnectionTimeoutSeconds = 1, // Fast timeout for test
AdminBypassUsers = []
});
var service = new LdapAuthService(multiServerOptions, _authOptions, _logger);
var service = new LdapAuthService(multiServerOptions, _logger);
// Act
var result = await service.AuthenticateAsync("testuser", "testpassword");