|
|
|
@ -104,9 +104,9 @@ namespace NzbDrone.Common.Test.Http
|
|
|
|
|
Mocker.SetConstant<IHttpDispatcher>(Mocker.Resolve<TDispatcher>());
|
|
|
|
|
|
|
|
|
|
// Used for manual testing of socks proxies.
|
|
|
|
|
//Mocker.GetMock<IHttpProxySettingsProvider>()
|
|
|
|
|
// .Setup(v => v.GetProxySettings(It.IsAny<HttpRequest>()))
|
|
|
|
|
// .Returns(new HttpProxySettings(ProxyType.Socks5, "127.0.0.1", 5476, "", false));
|
|
|
|
|
// Mocker.GetMock<IHttpProxySettingsProvider>()
|
|
|
|
|
// .Setup(v => v.GetProxySettings(It.IsAny<HttpUri>()))
|
|
|
|
|
// .Returns(new HttpProxySettings(ProxyType.Socks5, "127.0.0.1", 5476, "", false));
|
|
|
|
|
|
|
|
|
|
// Roundrobin over the two servers, to reduce the chance of hitting the ratelimiter.
|
|
|
|
|
_httpBinHost2 = _httpBinHosts[_httpBinRandom++ % _httpBinHosts.Length];
|
|
|
|
@ -283,6 +283,38 @@ namespace NzbDrone.Common.Test.Http
|
|
|
|
|
response.Resource.Headers[header].ToString().Should().Be(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_download_file()
|
|
|
|
|
{
|
|
|
|
|
var file = GetTempFilePath();
|
|
|
|
|
|
|
|
|
|
var url = "https://radarr.video/img/slider/moviedetails.png";
|
|
|
|
|
|
|
|
|
|
Subject.DownloadFile(url, file);
|
|
|
|
|
|
|
|
|
|
var fileInfo = new FileInfo(file);
|
|
|
|
|
fileInfo.Exists.Should().BeTrue();
|
|
|
|
|
fileInfo.Length.Should().Be(251536);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_download_file_with_redirect()
|
|
|
|
|
{
|
|
|
|
|
var file = GetTempFilePath();
|
|
|
|
|
|
|
|
|
|
var request = new HttpRequestBuilder($"https://{_httpBinHost}/redirect-to")
|
|
|
|
|
.AddQueryParam("url", $"https://radarr.video/img/slider/moviedetails.png")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Subject.DownloadFile(request.Url.FullUri, file);
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExpectedErrors(0);
|
|
|
|
|
|
|
|
|
|
var fileInfo = new FileInfo(file);
|
|
|
|
|
fileInfo.Exists.Should().BeTrue();
|
|
|
|
|
fileInfo.Length.Should().Be(251536);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_download_file_with_error()
|
|
|
|
|
{
|
|
|
|
@ -320,7 +352,7 @@ namespace NzbDrone.Common.Test.Http
|
|
|
|
|
var oldRequest = new HttpRequest($"https://{_httpBinHost2}/get");
|
|
|
|
|
oldRequest.Cookies["my"] = "cookie";
|
|
|
|
|
|
|
|
|
|
var oldClient = new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve<ICacheManager>(), Mocker.Resolve<IRateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), Mocker.GetMock<IUserAgentBuilder>().Object, Mocker.Resolve<Logger>());
|
|
|
|
|
var oldClient = new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve<ICacheManager>(), Mocker.Resolve<IRateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), Mocker.Resolve<Logger>());
|
|
|
|
|
|
|
|
|
|
oldClient.Should().NotBeSameAs(Subject);
|
|
|
|
|
|
|
|
|
|