feat(historian-client): add TCP/TLS options fields

This commit is contained in:
Joseph Doherty
2026-06-12 11:14:36 -04:00
parent eb6a71abf2
commit 35ac0b8c4e
2 changed files with 54 additions and 0 deletions
@@ -40,4 +40,20 @@ public sealed record WonderwareHistorianClientOptions(
[Display(Name = "Probe timeout (seconds)", Description = "Connection test timeout. Default 15s.", GroupName = "Diagnostics")]
[Range(1, 60)]
public int ProbeTimeoutSeconds { get; init; } = 15;
/// <summary>Sidecar TCP host (DNS name or IP). Required for the TCP transport.</summary>
public string? Host { get; init; }
/// <summary>Sidecar TCP port (matches the sidecar's OTOPCUA_HISTORIAN_TCP_PORT).</summary>
public int Port { get; init; }
/// <summary>When true, the client wraps the TCP stream in TLS before the Hello handshake.</summary>
public bool UseTls { get; init; }
/// <summary>
/// Optional SHA-1 thumbprint (hex, no spaces) the client pins the sidecar's TLS server
/// cert against. When null/empty and <see cref="UseTls"/> is true, the client validates
/// the cert chain normally (CA-issued cert).
/// </summary>
public string? ServerCertThumbprint { get; init; }
}
@@ -0,0 +1,38 @@
using Shouldly;
using Xunit;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Client.Tests;
/// <summary>
/// Unit tests for <see cref="WonderwareHistorianClientOptions"/> TCP/TLS fields.
/// </summary>
public sealed class WonderwareHistorianClientOptionsTests
{
[Fact]
public void TcpTlsFields_AreStoredCorrectly_WhenExplicitlySet()
{
var opts = new WonderwareHistorianClientOptions("pipe", "secret")
{
Host = "h",
Port = 32569,
UseTls = true,
ServerCertThumbprint = "AB"
};
opts.Host.ShouldBe("h");
opts.Port.ShouldBe(32569);
opts.UseTls.ShouldBeTrue();
opts.ServerCertThumbprint.ShouldBe("AB");
}
[Fact]
public void TcpTlsFields_HaveCorrectDefaults_WhenNotSet()
{
var opts = new WonderwareHistorianClientOptions("pipe", "secret");
opts.Host.ShouldBeNull();
opts.Port.ShouldBe(0);
opts.UseTls.ShouldBeFalse();
opts.ServerCertThumbprint.ShouldBeNull();
}
}