Fix: Indexers that are enabled but aren't configured correctly will be skipped during rss/search

pull/2/head
kay.one 13 years ago
parent e0170a08e4
commit 2009693787

@ -30,8 +30,6 @@ namespace NzbDrone.Core.Test
[TestCase("nzbmatrix.xml", 2)]
public void parse_feed_xml(string fileName, int warns)
{
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
@ -58,10 +56,25 @@ namespace NzbDrone.Core.Test
ExceptionVerification.ExpectedWarns(warns);
}
private void WithConfiguredIndexers()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbMatrixApiKey).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbMatrixUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NewzbinUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NewzbinPassword).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
}
[Test]
public void newzbin_parses_languae()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
@ -169,7 +182,7 @@ namespace NzbDrone.Core.Test
[Test]
public void downloadFeed()
{
Mocker.SetConstant(new HttpProvider());
Mocker.Resolve<HttpProvider>();
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
Mocker.GetMock<IndexerProvider>()
@ -198,7 +211,7 @@ namespace NzbDrone.Core.Test
Mocker.Resolve<HttpProvider>();
var result = Mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode);
Mark500Inconclusive();
result.Should().NotBeEmpty();
@ -228,13 +241,8 @@ namespace NzbDrone.Core.Test
[Test]
public void nzbmatrix_search_returns_valid_results()
{
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixUsername)
.Returns("");
WithConfiguredIndexers();
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixApiKey)
.Returns("");
Mocker.Resolve<HttpProvider>();
@ -249,13 +257,7 @@ namespace NzbDrone.Core.Test
[Test]
public void nzbmatrix_multi_word_search_returns_valid_results()
{
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixUsername)
.Returns("");
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixApiKey)
.Returns("");
WithConfiguredIndexers();
Mocker.Resolve<HttpProvider>();
@ -280,6 +282,8 @@ namespace NzbDrone.Core.Test
[Test]
public void size_newzbin()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
@ -294,8 +298,7 @@ namespace NzbDrone.Core.Test
[Test]
public void size_nzbmatrix()
{
//Setup
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
@ -311,8 +314,7 @@ namespace NzbDrone.Core.Test
[Test]
public void size_nzbsorg()
{
//Setup
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
@ -328,8 +330,7 @@ namespace NzbDrone.Core.Test
[Test]
public void size_nzbsrus()
{
//Setup
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
@ -359,6 +360,8 @@ namespace NzbDrone.Core.Test
[Test]
public void none_503_server_error_should_still_log_error()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Throws(new WebException("some other server error"));
@ -369,6 +372,17 @@ namespace NzbDrone.Core.Test
ExceptionVerification.ExpectedWarns(0);
}
[Test]
public void indexer_that_isnt_configured_shouldnt_make_an_http_call()
{
Mocker.Resolve<NotConfiguredIndexer>().FetchRss();
Mocker.GetMock<HttpProvider>()
.Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
ExceptionVerification.ExpectedWarns(1);
}
private static void Mark500Inconclusive()
{
ExceptionVerification.MarkInconclusive(typeof(WebException));

@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Init_indexer_test()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
@ -45,8 +45,6 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Init_indexer_with_disabled_job()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
@ -75,6 +73,11 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "www.google.com" }; }
}
public override bool IsConfigured
{
get { return true; }
}
protected override NetworkCredential Credentials
{
get { return null; }
@ -129,6 +132,11 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
}
public override bool IsConfigured
{
get { return true; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
@ -172,6 +180,11 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "http://www.google.com" }; }
}
public override bool IsConfigured
{
get { return true; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
@ -205,4 +218,52 @@ namespace NzbDrone.Core.Test.ProviderTests
}
}
public class NotConfiguredIndexer : IndexerBase
{
public NotConfiguredIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{
}
public override string Name
{
get { return "NotConfiguredIndexer"; }
}
protected override string[] Urls
{
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
}
public override bool IsConfigured
{
get { return false; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
throw new NotImplementedException();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
throw new NotImplementedException();
}
protected override string NzbDownloadUrl(SyndicationItem item)
{
throw new NotImplementedException();
}
}
}

@ -44,6 +44,9 @@ namespace NzbDrone.Core.Providers.Indexer
protected abstract string[] Urls { get; }
public abstract bool IsConfigured { get; }
/// <summary>
/// Gets the credential.
/// </summary>
@ -147,6 +150,12 @@ namespace NzbDrone.Core.Providers.Indexer
{
var result = new List<EpisodeParseResult>();
if (!IsConfigured)
{
_logger.Warn("Indexer '{0}' isn't configured correctly. please reconfigure the indexer in settings page.", Name);
return result;
}
foreach (var url in urls)
{
try
@ -178,11 +187,11 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
catch(WebException webException)
catch (WebException webException)
{
if (webException.Message.Contains("503"))
{
_logger.Warn("{0} server is currently unbelievable. {1}", Name, webException.Message);
_logger.Warn("{0} server is currently unbelievable. {1}", Name, webException.Message);
}
else
{

@ -30,7 +30,14 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.NewzbinUsername) &&
!string.IsNullOrWhiteSpace(_configProvider.NewzbinPassword);
}
}
protected override NetworkCredential Credentials

@ -24,6 +24,11 @@ namespace NzbDrone.Core.Providers.Indexer
get { return GetUrls(); }
}
public override bool IsConfigured
{
get { return true; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<string>();

@ -30,6 +30,15 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.NzbMatrixUsername) &&
!string.IsNullOrWhiteSpace(_configProvider.NzbMatrixApiKey);
}
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<String>();

@ -28,6 +28,15 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.NzbsOrgUId) &&
!string.IsNullOrWhiteSpace(_configProvider.NzbsOrgHash);
}
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<String>();

@ -29,6 +29,15 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.NzbsrusUId) &&
!string.IsNullOrWhiteSpace(_configProvider.NzbsrusHash);
}
}
public override string Name
{
get { return "NzbsRUs"; }

@ -47,11 +47,8 @@ namespace NzbDrone.Core.Providers
return Convert.ToInt32(_database.Insert(definition));
}
else
{
Logger.Debug("Updating Newznab definitions for {0}", definition.Name);
return _database.Update(definition);
}
Logger.Debug("Updating Newznab definitions for {0}", definition.Name);
return _database.Update(definition);
}
public virtual void SaveAll(IEnumerable<NewznabDefinition> definitions)

@ -47,7 +47,7 @@ namespace NzbDrone.Providers
prioCheckTimer.Elapsed += EnsurePriority;
prioCheckTimer.Enabled = true;
_pingTimer = new Timer(120000) { AutoReset = true };
_pingTimer = new Timer(180000) { AutoReset = true };
_pingTimer.Elapsed += (PingServer);
_pingTimer.Start();
}
@ -94,9 +94,10 @@ namespace NzbDrone.Providers
{
_pingFailCounter++;
Logger.ErrorException("Application pool is not responding. Count " + _pingFailCounter, ex);
if (_pingFailCounter > 2)
if (_pingFailCounter > 4)
{
_iisProvider.RestartServer();
_pingFailCounter = 0;
//_iisProvider.RestartServer();
}
}
}

Loading…
Cancel
Save