47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.LmxProxy.Host.Tests.Security
|
|
{
|
|
public class ApiKeyInterceptorTests
|
|
{
|
|
[Theory]
|
|
[InlineData("/scada.ScadaService/Write")]
|
|
[InlineData("/scada.ScadaService/WriteBatch")]
|
|
[InlineData("/scada.ScadaService/WriteBatchAndWait")]
|
|
public void WriteProtectedMethods_AreCorrectlyDefined(string method)
|
|
{
|
|
// This test verifies the set of write-protected methods is correct.
|
|
// The actual interceptor logic is tested via integration tests.
|
|
var writeProtected = new System.Collections.Generic.HashSet<string>(
|
|
System.StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
"/scada.ScadaService/Write",
|
|
"/scada.ScadaService/WriteBatch",
|
|
"/scada.ScadaService/WriteBatchAndWait"
|
|
};
|
|
writeProtected.Should().Contain(method);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("/scada.ScadaService/Connect")]
|
|
[InlineData("/scada.ScadaService/Disconnect")]
|
|
[InlineData("/scada.ScadaService/GetConnectionState")]
|
|
[InlineData("/scada.ScadaService/Read")]
|
|
[InlineData("/scada.ScadaService/ReadBatch")]
|
|
[InlineData("/scada.ScadaService/Subscribe")]
|
|
[InlineData("/scada.ScadaService/CheckApiKey")]
|
|
public void ReadMethods_AreNotWriteProtected(string method)
|
|
{
|
|
var writeProtected = new System.Collections.Generic.HashSet<string>(
|
|
System.StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
"/scada.ScadaService/Write",
|
|
"/scada.ScadaService/WriteBatch",
|
|
"/scada.ScadaService/WriteBatchAndWait"
|
|
};
|
|
writeProtected.Should().NotContain(method);
|
|
}
|
|
}
|
|
}
|