Add comprehensive smoke and feature tests for Gateway API
- Introduced LtdFeatureTests to validate BACnet and OPC UA point updates, trend logging, and alarm rule functionality. - Added OpcUaClientTests to ensure proper OPC UA client configuration, point value synchronization, and session management. - Created OpcUaFeatureTests to test OPC UA server capabilities, including browsing, reading, writing, and subscription notifications. - Implemented native_bacnet_test.py for isolated BACnet wire testing, covering discovery, read/write operations, and command processing. - Added ui-theme-tabs.test.cjs to verify theme switching, tab interactions, and protocol form accessibility in the UI.
This commit is contained in:
1 parent
d9165a60ff
commit
98c48d9d78
80 files changed
+11120
-315
No files matched your search
@@ -0,0 +1,11 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public enum NotificationChannel { Mail, WhatsApp, Ntfy }
|
||||
public enum AlarmCondition { Active, Inactive, Above, Below }
|
||||
public sealed record NotificationIntegration(NotificationChannel Channel, string Endpoint, bool HasApiKey);
|
||||
public sealed record UpdateNotificationKeyRequest(string? ApiKey, bool ClearApiKey = false);
|
||||
public sealed record AlarmDestination(NotificationChannel Channel, string Recipient, string Template = "stoerung", string PersonName = "SE-Inno", int Priority = 0, string Tags = "alarm");
|
||||
public sealed record AlarmRule(Guid Id, string Name, Guid PointId, AlarmCondition Condition, double Threshold,
|
||||
double Hysteresis, bool Enabled, bool NotifyRecovery, string Message, IReadOnlyList<AlarmDestination> Destinations);
|
||||
public sealed record NotificationDelivery(long Id, Guid RuleId, string Title, string Message,
|
||||
AlarmDestination Destination, string State, DateTimeOffset CreatedAtUtc, string? Result);
|
||||
@@ -0,0 +1,73 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
/// <summary>A reusable group of trend logs, equivalent to an LTD saved selection.</summary>
|
||||
public sealed record GatewayTrendSelection(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string? Description,
|
||||
Guid OwnerId,
|
||||
bool Shared,
|
||||
IReadOnlyList<Guid> TrendLogIds,
|
||||
DateTimeOffset CreatedAtUtc,
|
||||
DateTimeOffset UpdatedAtUtc);
|
||||
|
||||
public sealed record CreateTrendSelectionRequest(string Name, string? Description, bool Shared, IReadOnlyList<Guid> TrendLogIds);
|
||||
public sealed record UpdateTrendSelectionRequest(string? Name, string? Description, bool? Shared, IReadOnlyList<Guid>? TrendLogIds);
|
||||
|
||||
/// <summary>Scheduled CSV export and optional mail dispatch for one saved selection.</summary>
|
||||
public sealed record CsvRunnerJob(
|
||||
Guid Id,
|
||||
string Name,
|
||||
Guid SelectionId,
|
||||
string Time,
|
||||
int RangeHours,
|
||||
string Delimiter,
|
||||
bool Enabled,
|
||||
bool MailEnabled,
|
||||
string? MailTo,
|
||||
string MailSubject,
|
||||
string MailMessage,
|
||||
string? LastRunLocalDate,
|
||||
CsvRunnerJobResult? LastResult,
|
||||
DateTimeOffset CreatedAtUtc,
|
||||
DateTimeOffset UpdatedAtUtc);
|
||||
|
||||
public sealed record CsvRunnerJobResult(bool Success, string? FilePath, string? Error, DateTimeOffset RanAtUtc);
|
||||
public sealed record CsvRunnerExecution(Guid Id, Guid JobId, string Name, string State, DateTimeOffset EnqueuedAtUtc);
|
||||
|
||||
public sealed record CreateCsvRunnerJobRequest(
|
||||
string Name,
|
||||
Guid SelectionId,
|
||||
string Time,
|
||||
int RangeHours,
|
||||
string Delimiter,
|
||||
bool Enabled,
|
||||
bool MailEnabled,
|
||||
string? MailTo,
|
||||
string? MailSubject,
|
||||
string? MailMessage);
|
||||
|
||||
public sealed record UpdateCsvRunnerJobRequest(
|
||||
string? Name,
|
||||
Guid? SelectionId,
|
||||
string? Time,
|
||||
int? RangeHours,
|
||||
string? Delimiter,
|
||||
bool? Enabled,
|
||||
bool? MailEnabled,
|
||||
string? MailTo,
|
||||
string? MailSubject,
|
||||
string? MailMessage);
|
||||
|
||||
public sealed record MailIntegrationView(bool MailConfigured, string Endpoint);
|
||||
public sealed record UpdateMailIntegrationRequest(string? ApiKey, bool ClearApiKey = false);
|
||||
|
||||
public sealed record TrendExportRow(
|
||||
DateTimeOffset TimestampUtc,
|
||||
string TrendLogName,
|
||||
uint BacnetObjectInstance,
|
||||
string PointName,
|
||||
System.Text.Json.JsonElement Value,
|
||||
PointProtocol SourceProtocol,
|
||||
string? Status,
|
||||
string Unit = "");
|
||||
@@ -9,7 +9,9 @@ public sealed record GatewayConfiguration(
|
||||
IReadOnlyList<ModbusServerConfiguration> ModbusServers,
|
||||
KnxConfiguration Knx,
|
||||
MqttConfiguration? Mqtt = null,
|
||||
InstallationIdentity? Installation = null)
|
||||
InstallationIdentity? Installation = null,
|
||||
IReadOnlyList<SerialPortConfiguration>? SerialPorts = null,
|
||||
IReadOnlyList<ModbusRtuServerConfiguration>? ModbusRtuServers = null)
|
||||
{
|
||||
public static GatewayConfiguration CreateDefault(int deviceInstance, int bacnetPort, int opcUaPort, string interfaceName) => new(
|
||||
VendorId: 815,
|
||||
@@ -20,7 +22,9 @@ public sealed record GatewayConfiguration(
|
||||
ModbusServers: [],
|
||||
Knx: new KnxConfiguration(false, false),
|
||||
Mqtt: MqttConfiguration.CreateDefault(),
|
||||
Installation: null);
|
||||
Installation: null,
|
||||
SerialPorts: [],
|
||||
ModbusRtuServers: []);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +56,26 @@ public sealed record OpcUaConfiguration(
|
||||
int Port,
|
||||
bool ClientEnabled,
|
||||
bool ServerEnabled,
|
||||
bool AllowAnonymous);
|
||||
bool AllowAnonymous,
|
||||
IReadOnlyList<OpcUaClientConfiguration>? Clients = null);
|
||||
|
||||
public enum OpcUaAuthenticationMode
|
||||
{
|
||||
Anonymous,
|
||||
Username,
|
||||
Certificate
|
||||
}
|
||||
|
||||
public sealed record OpcUaClientConfiguration(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string EndpointUrl,
|
||||
OpcUaAuthenticationMode AuthenticationMode,
|
||||
string? Username,
|
||||
bool AcceptUntrustedServerCertificate = false,
|
||||
bool Enabled = true,
|
||||
bool UseSecurity = true,
|
||||
int PublishingIntervalMilliseconds = 1000);
|
||||
|
||||
public sealed record ModbusServerConfiguration(
|
||||
Guid Id,
|
||||
@@ -64,7 +87,37 @@ public sealed record ModbusServerConfiguration(
|
||||
int HoldingRegisterCount,
|
||||
IReadOnlyList<string> AllowedClientIps);
|
||||
|
||||
public sealed record KnxConfiguration(bool Enabled, bool Secure);
|
||||
/// <summary>Named serial interface. The device path remains a Linux path such as /dev/ttyUSB0.</summary>
|
||||
public sealed record SerialPortConfiguration(
|
||||
Guid Id,
|
||||
string Alias,
|
||||
string DevicePath,
|
||||
int BaudRate,
|
||||
string Parity,
|
||||
int DataBits,
|
||||
int StopBits);
|
||||
|
||||
/// <summary>Modbus RTU slave configuration addressed through a configured serial alias.</summary>
|
||||
public sealed record ModbusRtuServerConfiguration(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string SerialPortAlias,
|
||||
int UnitId,
|
||||
int FirstHoldingRegister,
|
||||
int HoldingRegisterCount);
|
||||
|
||||
public enum KnxTransport
|
||||
{
|
||||
Ip,
|
||||
Tp
|
||||
}
|
||||
|
||||
public sealed record KnxConfiguration(
|
||||
bool Enabled,
|
||||
bool Secure,
|
||||
KnxTransport Transport = KnxTransport.Ip,
|
||||
string? SerialPortAlias = null,
|
||||
string? LocalIpAddress = null);
|
||||
|
||||
public sealed record MqttConfiguration(
|
||||
bool Enabled,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
/// <summary>Locally managed account. Password material never leaves the store.</summary>
|
||||
public sealed record GatewayUser(
|
||||
Guid Id,
|
||||
string Username,
|
||||
string DisplayName,
|
||||
string? Email,
|
||||
string Role,
|
||||
bool Active,
|
||||
DateTimeOffset CreatedAtUtc,
|
||||
DateTimeOffset UpdatedAtUtc);
|
||||
|
||||
public sealed record GatewayRole(
|
||||
string Name,
|
||||
string Label,
|
||||
IReadOnlyList<string> Permissions,
|
||||
bool IsSystem,
|
||||
DateTimeOffset UpdatedAtUtc);
|
||||
|
||||
public sealed record AuthenticatedGatewayUser(
|
||||
GatewayUser User,
|
||||
IReadOnlyList<string> Permissions);
|
||||
|
||||
/// <summary>Personal presentation settings, kept server-side like the former LTD UI.</summary>
|
||||
public sealed record GatewayUserPreferences(
|
||||
string Theme,
|
||||
string CsvDelimiter,
|
||||
bool SidebarPinned,
|
||||
decimal TrendLineWidth,
|
||||
DateTimeOffset UpdatedAtUtc);
|
||||
|
||||
public static class GatewayPermissions
|
||||
{
|
||||
public const string ViewDashboard = "view_dashboard";
|
||||
public const string ViewTrends = "view_trends";
|
||||
public const string EditAliases = "edit_aliases";
|
||||
public const string ManageSources = "manage_sources";
|
||||
public const string ViewDebug = "view_debug";
|
||||
public const string ManageAlarms = "manage_alarms";
|
||||
public const string ManageUsers = "manage_users";
|
||||
public const string ManageRoles = "manage_roles";
|
||||
public const string ManageIntegrations = "manage_integrations";
|
||||
public const string ManageRunner = "manage_runner";
|
||||
public const string ManageGateway = "manage_gateway";
|
||||
|
||||
public static readonly IReadOnlyList<string> Catalog =
|
||||
[
|
||||
ViewDashboard, ViewTrends, EditAliases, ManageSources, ViewDebug,
|
||||
ManageAlarms, ManageUsers, ManageRoles, ManageIntegrations,
|
||||
ManageRunner, ManageGateway
|
||||
];
|
||||
}
|
||||
@@ -5,7 +5,8 @@ namespace Gateway.Api.Domain;
|
||||
public enum MqttMappingFormat
|
||||
{
|
||||
SeMonitoring,
|
||||
Json
|
||||
Json,
|
||||
SingleTopic
|
||||
}
|
||||
|
||||
public enum MqttDirection
|
||||
@@ -20,7 +21,8 @@ public enum SeMonitoringCategory
|
||||
Analog,
|
||||
Notify,
|
||||
Alarm,
|
||||
Setpoints
|
||||
Setpoints,
|
||||
Alarms
|
||||
}
|
||||
|
||||
public enum MqttQualityOfService
|
||||
@@ -67,6 +69,10 @@ public sealed record UpdateMqttConfigurationRequest(
|
||||
|
||||
public sealed record MqttConfigurationView(MqttConfiguration Configuration, bool HasPassword);
|
||||
|
||||
public sealed record MqttMonitoringSite(int? ProjectYear, string? ProjectNumber, string? IspNumber);
|
||||
public sealed record MqttPointDefaults(Guid PointId, SeMonitoringCategory? Category, string TopicName);
|
||||
public sealed record MqttMappingDefaults(MqttMonitoringSite Site, IReadOnlyList<MqttPointDefaults> Points);
|
||||
|
||||
public sealed record MqttInboundMessage(string Topic, JsonElement Payload, DateTimeOffset ReceivedAtUtc);
|
||||
|
||||
public sealed record MqttClientStatus(
|
||||
@@ -76,4 +82,6 @@ public sealed record MqttClientStatus(
|
||||
string? LastError,
|
||||
DateTimeOffset? ConnectedAtUtc,
|
||||
DateTimeOffset? LastReceivedAtUtc,
|
||||
DateTimeOffset? LastPublishedAtUtc);
|
||||
DateTimeOffset? LastPublishedAtUtc,
|
||||
string? LastFailure = null,
|
||||
DateTimeOffset? LastFailureAtUtc = null);
|
||||
@@ -67,12 +67,18 @@ public sealed record CreatePointRequest(
|
||||
BacnetObjectKind? BacnetObjectKind = null,
|
||||
uint? BacnetObjectInstance = null);
|
||||
|
||||
public sealed record PointDependencies(int Mappings, int MqttMappings, int Alarms, int TrendLogs)
|
||||
{
|
||||
public string Confirmation => $"{Mappings}-{MqttMappings}-{Alarms}-{TrendLogs}";
|
||||
}
|
||||
|
||||
public sealed record PointValue(
|
||||
Guid PointId,
|
||||
JsonElement Value,
|
||||
PointProtocol SourceProtocol,
|
||||
DateTimeOffset UpdatedAtUtc,
|
||||
string? Status);
|
||||
string? Status,
|
||||
Guid? OriginPointId = null);
|
||||
|
||||
public enum MappingDirection
|
||||
{
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public sealed record DisplayUnit(string Symbol, string Name, bool IsSystem = false);
|
||||
public sealed record PointPresentation(Guid PointId, string Alias, string Unit, double Factor, string Kind, string Color);
|
||||
public sealed record DashboardWidget(Guid Id, string Title, Guid SelectionId, int RangeHours, string Type);
|
||||
@@ -11,6 +11,7 @@ public sealed record GatewayTrendLog(
|
||||
int IntervalSeconds,
|
||||
int MaxRecords,
|
||||
bool Enabled,
|
||||
bool IsPublic,
|
||||
DateTimeOffset CreatedAtUtc);
|
||||
|
||||
public sealed record CreateTrendLogRequest(
|
||||
@@ -19,7 +20,8 @@ public sealed record CreateTrendLogRequest(
|
||||
uint BacnetObjectInstance,
|
||||
int IntervalSeconds,
|
||||
int MaxRecords,
|
||||
bool Enabled);
|
||||
bool Enabled,
|
||||
bool IsPublic = false);
|
||||
|
||||
public sealed record TrendRecord(
|
||||
Guid TrendLogId,
|
||||
|
||||
Reference in new issue
Block a user