34 lines
1 KiB
C#
34 lines
1 KiB
C#
|
|
using Surveillance.Client.Domain;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace Surveillance.Client.Domain.Tests;
|
||
|
|
|
||
|
|
public sealed class DeviceEndpointTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public void CredentialKeyIsStableAcrossHostCaseAndWhitespace()
|
||
|
|
{
|
||
|
|
var first = new DeviceEndpoint(" camera.local ", 34567);
|
||
|
|
var second = new DeviceEndpoint("CAMERA.local", 34567);
|
||
|
|
|
||
|
|
Assert.Equal(first.CredentialKey, second.CredentialKey);
|
||
|
|
Assert.Equal("camera.local:34567", first.ToString());
|
||
|
|
}
|
||
|
|
|
||
|
|
[Theory]
|
||
|
|
[InlineData(0)]
|
||
|
|
[InlineData(65536)]
|
||
|
|
public void RejectsPortsOutsideTcpRange(int port)
|
||
|
|
{
|
||
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => new DeviceEndpoint("127.0.0.1", port));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void CredentialsNeverExposeTheirValuesInToString()
|
||
|
|
{
|
||
|
|
var credentials = new DeviceCredentials("viewer", "a-secret-value");
|
||
|
|
|
||
|
|
Assert.DoesNotContain("viewer", credentials.ToString(), StringComparison.Ordinal);
|
||
|
|
Assert.DoesNotContain("a-secret-value", credentials.ToString(), StringComparison.Ordinal);
|
||
|
|
}
|
||
|
|
}
|