using Xunit; namespace ZB.MOM.WW.OtOpcUa.Host.IntegrationTests; /// Verifies final-gate endpoint safety before any live probe can run. [Trait("Category", "Unit")] [Trait("Feature", "GrpcData"), Trait("Phase", "P12")] public sealed class LocalFixtureEndpointGuardTests { /// Accepts the owned SQL, TCP and OPC UA endpoint shapes. [Theory] [InlineData("127.0.0.1:41234")] [InlineData("127.0.0.1,41234")] [InlineData("opc.tcp://127.0.0.1:41234")] public void Generated_loopback_endpoints_have_the_allocated_port(string endpoint) => Assert.Equal(41234, DriverProbeHandshakeE2eTests.ParseLocalFixturePort(endpoint)); /// Preserves the address and application path advertised by the owned Host rig. [Fact] public void Generated_host_opcua_endpoint_preserves_the_application_path() { const string endpoint = "opc.tcp://127.0.0.1:41234/OtOpcUa"; var parsed = DriverProbeHandshakeE2eTests.ParseLocalHostOpcUaEndpoint(endpoint); Assert.Equal(41234, parsed.Port); Assert.Equal(endpoint, parsed.OriginalString); } /// Only the owned OPC UA application endpoint may carry the application path. [Theory] [InlineData("opc.tcp://127.0.0.1:41234")] [InlineData("opc.tcp://127.0.0.1:41234/Other")] [InlineData("http://127.0.0.1:41234/OtOpcUa")] [InlineData("opc.tcp://127.0.0.1:41234/OtOpcUa?other=1")] public void Other_host_opcua_endpoint_shapes_are_rejected(string endpoint) => Assert.Throws(() => DriverProbeHandshakeE2eTests.ParseLocalHostOpcUaEndpoint(endpoint)); /// Refuses shared hosts, credentials and missing ports without resolving them. [Theory] [InlineData("10.100.0.35:5020")] [InlineData("localhost:5020")] [InlineData("opc.tcp://user:password@127.0.0.1:5020")] [InlineData("127.0.0.1")] [InlineData("127.0.0.1:0")] [InlineData("http://127.0.0.1:5020/path")] [InlineData("opc.tcp://127.0.0.1:41234/OtOpcUa")] public void Foreign_or_ambiguous_endpoints_are_rejected(string endpoint) => Assert.ThrowsAny(() => DriverProbeHandshakeE2eTests.ParseLocalFixturePort(endpoint)); }