Group all 69 projects into category subfolders under src/ and tests/ so the Rider Solution Explorer mirrors the module structure. Folders: Core, Server, Drivers (with a nested Driver CLIs subfolder), Client, Tooling. - Move every project folder on disk with git mv (history preserved as renames). - Recompute relative paths in 57 .csproj files: cross-category ProjectReferences, the lib/ HintPath+None refs in Driver.Historian.Wonderware, and the external mxaccessgw refs in Driver.Galaxy and its test project. - Rebuild ZB.MOM.WW.OtOpcUa.slnx with nested solution folders. - Re-prefix project paths in functional scripts (e2e, compliance, smoke SQL, integration, install). Build green (0 errors); unit tests pass. Docs left for a separate pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Admin.Security;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Admin.Tests;
|
|
|
|
[Trait("Category", "Unit")]
|
|
public sealed class RoleMapperTests
|
|
{
|
|
[Fact]
|
|
public void Maps_single_group_to_single_role()
|
|
{
|
|
var mapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["ReadOnly"] = "ConfigViewer",
|
|
};
|
|
RoleMapper.Map(["ReadOnly"], mapping).ShouldBe(["ConfigViewer"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void Group_match_is_case_insensitive()
|
|
{
|
|
var mapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["ReadOnly"] = "ConfigViewer",
|
|
};
|
|
RoleMapper.Map(["readonly"], mapping).ShouldContain("ConfigViewer");
|
|
}
|
|
|
|
[Fact]
|
|
public void User_with_multiple_matching_groups_gets_all_distinct_roles()
|
|
{
|
|
var mapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["ReadOnly"] = "ConfigViewer",
|
|
["ReadWrite"] = "ConfigEditor",
|
|
["AlarmAck"] = "FleetAdmin",
|
|
};
|
|
var roles = RoleMapper.Map(["ReadOnly", "ReadWrite", "AlarmAck"], mapping);
|
|
roles.ShouldContain("ConfigViewer");
|
|
roles.ShouldContain("ConfigEditor");
|
|
roles.ShouldContain("FleetAdmin");
|
|
roles.Count.ShouldBe(3);
|
|
}
|
|
|
|
[Fact]
|
|
public void Unknown_group_is_ignored()
|
|
{
|
|
var mapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["ReadOnly"] = "ConfigViewer",
|
|
};
|
|
RoleMapper.Map(["UnrelatedGroup"], mapping).ShouldBeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void Empty_mapping_returns_empty_roles()
|
|
{
|
|
RoleMapper.Map(["ReadOnly"], new Dictionary<string, string>()).ShouldBeEmpty();
|
|
}
|
|
}
|