Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests/RoleMapperTests.cs
T
Joseph Doherty 64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
docs: backfill XML documentation across 756 files
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public
members surfaced by commentchecker — resolves 5,847 of 5,869 issues
(99.6%) across three /fixdocs passes.
2026-05-28 08:10:17 -04:00

63 lines
1.6 KiB
C#

using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Security.Ldap;
namespace ZB.MOM.WW.OtOpcUa.Security.Tests;
public sealed class RoleMapperTests
{
/// <summary>
/// Verifies that empty mapping returns no roles.
/// </summary>
[Fact]
public void Empty_mapping_returns_empty()
{
RoleMapper.Map(new[] { "Admins" }, new Dictionary<string, string>())
.ShouldBeEmpty();
}
/// <summary>
/// Verifies that RoleMapper maps a group to its corresponding role.
/// </summary>
[Fact]
public void Maps_group_to_role()
{
RoleMapper.Map(
new[] { "AdminGroup" },
new Dictionary<string, string> { ["AdminGroup"] = "FleetAdmin" })
.ShouldBe(new[] { "FleetAdmin" });
}
/// <summary>
/// Verifies that group matching is case-insensitive.
/// </summary>
[Fact]
public void Case_insensitive_group_match()
{
RoleMapper.Map(
new[] { "admingroup" },
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["AdminGroup"] = "FleetAdmin",
})
.ShouldBe(new[] { "FleetAdmin" });
}
/// <summary>
/// Verifies that multiple groups are deduplicated to unique roles.
/// </summary>
[Fact]
public void Multiple_groups_dedup_roles()
{
var roles = RoleMapper.Map(
new[] { "AdminGroup", "AlsoAdmin" },
new Dictionary<string, string>
{
["AdminGroup"] = "FleetAdmin",
["AlsoAdmin"] = "FleetAdmin",
});
roles.ShouldBe(new[] { "FleetAdmin" });
}
}