53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using System;
|
|
using System.Net;
|
|
using Paca.Mobile.Core;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.Core;
|
|
|
|
public class ProxyConfigurationManagerGateTests
|
|
{
|
|
[Fact]
|
|
public void Gate285_ProxyConfigurationManager_ParsesHttpProxy_WithCredentials()
|
|
{
|
|
var raw = "http://myuser:mypass123@192.168.1.50:8080";
|
|
var config = ProxyConfigurationManager.Parse(raw);
|
|
|
|
Assert.NotNull(config);
|
|
Assert.Equal("192.168.1.50", config!.Host);
|
|
Assert.Equal(8080, config.Port);
|
|
Assert.Equal("http", config.Scheme);
|
|
Assert.Equal("myuser", config.Username);
|
|
Assert.Equal("mypass123", config.Password);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate286_ProxyConfigurationManager_BuildsWebProxy_WithBypassList()
|
|
{
|
|
var raw = "http://127.0.0.1:8888";
|
|
var bypassList = new[] { "localhost", "127.0.0.1", "*.local" };
|
|
var proxy = ProxyConfigurationManager.CreateWebProxy(raw, bypassList);
|
|
|
|
Assert.NotNull(proxy);
|
|
Assert.True(proxy!.IsBypassed(new Uri("http://localhost:5000/api")));
|
|
Assert.False(proxy.IsBypassed(new Uri("https://youtube.com/watch?v=123")));
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate287_ProxyConfigurationManager_BuildsYtDlpArguments()
|
|
{
|
|
var raw = "http://127.0.0.1:8888";
|
|
var args = ProxyConfigurationManager.GetYtDlpProxyArg(raw);
|
|
|
|
Assert.Equal("--proxy \"http://127.0.0.1:8888\"", args);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate288_ProxyConfigurationManager_HandlesDisabledOrEmptyProxy()
|
|
{
|
|
Assert.Null(ProxyConfigurationManager.Parse(""));
|
|
Assert.Null(ProxyConfigurationManager.Parse(null));
|
|
Assert.Null(ProxyConfigurationManager.CreateWebProxy("", Array.Empty<string>()));
|
|
Assert.Equal(string.Empty, ProxyConfigurationManager.GetYtDlpProxyArg(""));
|
|
}
|
|
}
|