Files
PnvPanel/backend/tests/PnvPanel.Domain.Tests/Inbounds/InboundTests.cs
T
Leonid Pershin 8f6807a456
CI / Backend (build + test) (push) Successful in 1m23s
CI / Frontend (lint + typecheck + build) (push) Successful in 34s
Enhance inbound management by removing MaxClients property
- Removed the MaxClients property from Inbound-related data models, including InboundDto and PublishInboundCommand.
- Updated related methods and handlers to reflect the removal of MaxClients, ensuring consistent behavior across the application.
- Adjusted API documentation and frontend components to remove references to MaxClients, streamlining the inbound publishing process.
- Enhanced logging in command handlers to handle node unavailability scenarios during user actions.
- Improved database schema and migrations to align with the updated data model.
2026-07-14 23:11:50 +03:00

64 lines
1.9 KiB
C#

using PnvPanel.Domain.Inbounds;
using Xunit;
namespace PnvPanel.Domain.Tests.Inbounds;
public class InboundTests
{
[Fact]
public void FromRemote_CreatesUnpublishedInbound()
{
var nodeId = Guid.NewGuid();
var inbound = Inbound.FromRemote(nodeId, "12", VpnProtocol.Vless, "Germany", 443);
Assert.Equal(nodeId, inbound.NodeId);
Assert.Equal("12", inbound.RemoteInboundId);
Assert.Equal(VpnProtocol.Vless, inbound.Protocol);
Assert.Equal(443, inbound.Port);
Assert.False(inbound.IsPublished);
Assert.Empty(inbound.AllowedRoleIds);
}
[Fact]
public void UpdateFromRemote_UpdatesFieldsAndLastSyncAt()
{
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Old", 443);
var before = inbound.LastSyncAt;
inbound.UpdateFromRemote(VpnProtocol.Trojan, "New", 8443);
Assert.Equal(VpnProtocol.Trojan, inbound.Protocol);
Assert.Equal("New", inbound.Remark);
Assert.Equal(8443, inbound.Port);
Assert.NotNull(inbound.LastSyncAt);
}
[Fact]
public void Publish_SetsDisplayNameAndRoles()
{
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Germany", 443);
var roleId = Guid.NewGuid();
inbound.Publish("Germany (VLESS)", [roleId, roleId]);
Assert.True(inbound.IsPublished);
Assert.Equal("Germany (VLESS)", inbound.DisplayName);
Assert.Single(inbound.AllowedRoleIds);
Assert.Contains(roleId, inbound.AllowedRoleIds);
}
[Fact]
public void Unpublish_SetsIsPublishedFalseButKeepsRoles()
{
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Germany", 443);
var roleId = Guid.NewGuid();
inbound.Publish("Germany", [roleId]);
inbound.Unpublish();
Assert.False(inbound.IsPublished);
Assert.Contains(roleId, inbound.AllowedRoleIds);
}
}