Fixed: Use Proxy for MediaCovers and Metadata

This commit is contained in:
Qstick 2020-09-07 00:28:15 -04:00
parent 8c657ddb24
commit 3f96208c41
7 changed files with 103 additions and 47 deletions

View file

@ -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://lidarr.audio/img/slider/artistdetails.png";
Subject.DownloadFile(url, file);
var fileInfo = new FileInfo(file);
fileInfo.Exists.Should().BeTrue();
fileInfo.Length.Should().Be(146122);
}
[Test]
public void should_download_file_with_redirect()
{
var file = GetTempFilePath();
var request = new HttpRequestBuilder($"https://{_httpBinHost}/redirect-to")
.AddQueryParam("url", $"https://lidarr.audio/img/slider/artistdetails.png")
.Build();
Subject.DownloadFile(request.Url.FullUri, file);
ExceptionVerification.ExpectedErrors(0);
var fileInfo = new FileInfo(file);
fileInfo.Exists.Should().BeTrue();
fileInfo.Length.Should().Be(146122);
}
[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);