- Cleaned up whitespace in Directory.Build.props and Directory.Packages.props for consistency. - Reformatted project file references in PnvPanel.Api.csproj for better clarity. - Enhanced code readability in various endpoint files by adjusting line breaks and indentation. - Standardized method signatures and improved formatting in ResultExtensions and multiple endpoint classes for better maintainability.
82 lines
2.7 KiB
C#
82 lines
2.7 KiB
C#
using PnvPanel.Application.Common.Interfaces;
|
|
using PnvPanel.Application.Common.Models;
|
|
using PnvPanel.Domain.Inbounds;
|
|
using PnvPanel.Domain.Nodes;
|
|
|
|
namespace PnvPanel.IntegrationTests.TestSupport;
|
|
|
|
/// <summary>
|
|
/// Заглушка 3x-ui для интеграционных тестов — реальной панели нет. Возвращает успех для проб/CRUD
|
|
/// клиентов, отдаёт один синтетический inbound на ноду для сценариев с SyncNode.
|
|
/// </summary>
|
|
public sealed class FakeXuiPanelGateway : IXuiPanelGateway
|
|
{
|
|
public Result ValidateBaseAddress(Uri baseAddress) => Result.Success();
|
|
|
|
public Task<NodeProbeResult> ProbeAsync(Node node, CancellationToken cancellationToken) =>
|
|
Task.FromResult(new NodeProbeResult(true, null));
|
|
|
|
public Task<Result<IReadOnlyList<RemoteInboundInfo>>> ListInboundsAsync(
|
|
Node node,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
IReadOnlyList<RemoteInboundInfo> inbounds =
|
|
[
|
|
new RemoteInboundInfo("1", VpnProtocol.Vless, "Test inbound", 443),
|
|
];
|
|
|
|
return Task.FromResult(Result.Success(inbounds));
|
|
}
|
|
|
|
public void InvalidateClient(Guid nodeId) { }
|
|
|
|
public Task<Result<string>> AddClientAsync(
|
|
Node node,
|
|
string inboundRemoteId,
|
|
VpnProtocol protocol,
|
|
string clientEmail,
|
|
string clientName,
|
|
int limitIp,
|
|
CancellationToken cancellationToken
|
|
) => Task.FromResult(Result.Success(Guid.NewGuid().ToString()));
|
|
|
|
public Task<Result> RemoveClientAsync(
|
|
Node node,
|
|
string inboundRemoteId,
|
|
string clientExternalId,
|
|
VpnProtocol protocol,
|
|
CancellationToken cancellationToken
|
|
) => Task.FromResult(Result.Success());
|
|
|
|
public Task<Result> UpdateClientAsync(
|
|
Node node,
|
|
string inboundRemoteId,
|
|
string clientExternalId,
|
|
VpnProtocol protocol,
|
|
string name,
|
|
bool enable,
|
|
CancellationToken cancellationToken
|
|
) => Task.FromResult(Result.Success());
|
|
|
|
public Task<Result<string>> BuildConnectionStringAsync(
|
|
Node node,
|
|
Inbound inbound,
|
|
string clientExternalId,
|
|
string clientName,
|
|
string publicHost,
|
|
CancellationToken cancellationToken
|
|
) => Task.FromResult(Result.Success("vless://fake-connection-string"));
|
|
|
|
public Task<Result<IReadOnlyDictionary<string, ClientTrafficInfo>>> GetClientTrafficAsync(
|
|
Node node,
|
|
string inboundRemoteId,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
IReadOnlyDictionary<string, ClientTrafficInfo> traffic =
|
|
new Dictionary<string, ClientTrafficInfo>();
|
|
return Task.FromResult(Result.Success(traffic));
|
|
}
|
|
}
|