feat(auth): cut ScadaBridge over to ZB.MOM.WW.Auth.Ldap; nest+rename Ldap config; roles+sitescope via IGroupRoleMapper (Task 1.2/1.4)
This commit is contained in:
@@ -14,6 +14,7 @@ using ZB.MOM.WW.ScadaBridge.Commons.Entities.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
using ZB.MOM.WW.Auth.Abstractions.Ldap;
|
||||
using ZB.MOM.WW.ScadaBridge.ManagementService;
|
||||
using ZB.MOM.WW.ScadaBridge.Security;
|
||||
|
||||
@@ -71,14 +72,12 @@ public class AuditEndpointsTests
|
||||
.Returns(Task.FromResult<IReadOnlyList<AuditEvent>>(Array.Empty<AuditEvent>()));
|
||||
}
|
||||
|
||||
// Substituted LDAP bind — AuthenticateAsync is virtual (test seam).
|
||||
var ldap = Substitute.For<LdapAuthService>(
|
||||
Options.Create(new SecurityOptions()),
|
||||
Substitute.For<ILogger<LdapAuthService>>());
|
||||
// Substituted LDAP bind — the shared ILdapAuthService is the seam now (Task 1.2).
|
||||
var ldap = Substitute.For<ILdapAuthService>();
|
||||
ldap.AuthenticateAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(ldapSucceeds
|
||||
? new LdapAuthResult(true, "Auditor", "auditor", new[] { "cn=audit" }, null)
|
||||
: new LdapAuthResult(false, null, null, null, "Bad credentials."));
|
||||
? LdapAuthResult.Success("auditor", "Auditor", new[] { "audit" })
|
||||
: LdapAuthResult.Fail(LdapAuthFailure.BadCredentials));
|
||||
|
||||
// Substituted role mapper — MapGroupsToRolesAsync is virtual (test seam).
|
||||
var roleMapper = Substitute.For<RoleMapper>(Substitute.For<ISecurityRepository>());
|
||||
|
||||
Reference in New Issue
Block a user