49 lines
2.2 KiB
C#
49 lines
2.2 KiB
C#
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Host.IntegrationTests;
|
|
|
|
/// <summary>Verifies final-gate endpoint safety before any live probe can run.</summary>
|
|
[Trait("Category", "Unit")]
|
|
[Trait("Feature", "GrpcData"), Trait("Phase", "P12")]
|
|
public sealed class LocalFixtureEndpointGuardTests
|
|
{
|
|
/// <summary>Accepts the owned SQL, TCP and OPC UA endpoint shapes.</summary>
|
|
[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));
|
|
|
|
/// <summary>Preserves the address and application path advertised by the owned Host rig.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Only the owned OPC UA application endpoint may carry the application path.</summary>
|
|
[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<InvalidOperationException>(() => DriverProbeHandshakeE2eTests.ParseLocalHostOpcUaEndpoint(endpoint));
|
|
|
|
/// <summary>Refuses shared hosts, credentials and missing ports without resolving them.</summary>
|
|
[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<Exception>(() => DriverProbeHandshakeE2eTests.ParseLocalFixturePort(endpoint));
|
|
}
|