mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
parent
80304d8804
commit
ac387f208a
@ -1,4 +1,4 @@
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
@ -24,6 +24,64 @@ public void Setup()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GivenOldFeedFormat()
|
||||||
|
{
|
||||||
|
Subject.Definition = new IndexerDefinition()
|
||||||
|
{
|
||||||
|
Name = "IPTorrents",
|
||||||
|
Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/torrents/rss?u=snip;tp=snip;3;80;93;37;download" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenNewFeedFormat()
|
||||||
|
{
|
||||||
|
Subject.Definition = new IndexerDefinition()
|
||||||
|
{
|
||||||
|
Name = "IPTorrents",
|
||||||
|
Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/t.rss?u=USERID;tp=APIKEY;3;80;93;37;download" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenFeedNoDownloadFormat()
|
||||||
|
{
|
||||||
|
Subject.Definition = new IndexerDefinition()
|
||||||
|
{
|
||||||
|
Name = "IPTorrents",
|
||||||
|
Settings = new IPTorrentsSettings() { BaseUrl = "https://iptorrents.com/t.rss?u=USERID;tp=APIKEY;3;80;93;37" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_validate_old_feed_format()
|
||||||
|
{
|
||||||
|
GivenOldFeedFormat();
|
||||||
|
var validationResult = Subject.Definition.Settings.Validate();
|
||||||
|
validationResult.IsValid.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_validate_new_feed_format()
|
||||||
|
{
|
||||||
|
GivenNewFeedFormat();
|
||||||
|
var validationResult = Subject.Definition.Settings.Validate();
|
||||||
|
validationResult.IsValid.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_validate_bad_format()
|
||||||
|
{
|
||||||
|
var validationResult = Subject.Definition.Settings.Validate();
|
||||||
|
validationResult.IsValid.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_validate_no_download_format()
|
||||||
|
{
|
||||||
|
GivenFeedNoDownloadFormat();
|
||||||
|
var validationResult = Subject.Definition.Settings.Validate();
|
||||||
|
validationResult.IsValid.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_parse_recent_feed_from_IPTorrents()
|
public void should_parse_recent_feed_from_IPTorrents()
|
||||||
{
|
{
|
||||||
|
@ -16,11 +16,11 @@ public IPTorrentsSettingsValidator()
|
|||||||
{
|
{
|
||||||
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
|
|
||||||
RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+$");
|
RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+$");
|
||||||
|
|
||||||
RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+;download(?:;|$)")
|
RuleFor(c => c.BaseUrl).Matches(@"(?:/|t\.)rss\?.+;download(?:;|$)")
|
||||||
.WithMessage("Use Direct Download Url (;download)")
|
.WithMessage("Use Direct Download Url (;download)")
|
||||||
.When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"/rss\?.+$"));
|
.When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"(?:/|t\.)rss\?.+$"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user