- Introduced Telegram.Bot package for bot functionality. - Updated user management to include Telegram linking and blocking features. - Enhanced activation request handling with notifications via Telegram. - Added new database entities for Telegram link tokens and login requests. - Implemented traffic synchronization for client stats in the XuiPanelGateway. - Updated application structure to support new test projects and improved dependency injection for Telegram services.
65 lines
2.0 KiB
C#
65 lines
2.0 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_SetsDisplayNameRolesAndMaxClients()
|
|
{
|
|
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Germany", 443);
|
|
var roleId = Guid.NewGuid();
|
|
|
|
inbound.Publish("Germany (VLESS)", [roleId, roleId], 100);
|
|
|
|
Assert.True(inbound.IsPublished);
|
|
Assert.Equal("Germany (VLESS)", inbound.DisplayName);
|
|
Assert.Equal(100, inbound.MaxClients);
|
|
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], null);
|
|
|
|
inbound.Unpublish();
|
|
|
|
Assert.False(inbound.IsPublished);
|
|
Assert.Contains(roleId, inbound.AllowedRoleIds);
|
|
}
|
|
}
|