2020-08-11 20:09:18 +00:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2021-11-13 21:10:42 +00:00
|
|
|
using System.Net.Http;
|
2023-07-16 18:07:31 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-08-11 20:09:18 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common.Http;
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
using NzbDrone.Core.Indexers.Redacted;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
2023-04-14 20:00:03 +00:00
|
|
|
namespace NzbDrone.Core.Test.IndexerTests.RedactedTests
|
2020-08-11 20:09:18 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class RedactedFixture : CoreTest<Redacted>
|
|
|
|
{
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2023-04-14 20:00:03 +00:00
|
|
|
Subject.Definition = new IndexerDefinition
|
2020-08-11 20:09:18 +00:00
|
|
|
{
|
|
|
|
Name = "Redacted",
|
|
|
|
Settings = new RedactedSettings
|
|
|
|
{
|
2023-04-30 13:37:04 +00:00
|
|
|
ApiKey = "secretkey"
|
2020-08-11 20:09:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2023-07-16 18:07:31 +00:00
|
|
|
public async Task should_parse_recent_feed_from_redacted()
|
2020-08-11 20:09:18 +00:00
|
|
|
{
|
|
|
|
var recentFeed = ReadAllText(@"Files/Indexers/Gazelle/Gazelle.json");
|
|
|
|
|
|
|
|
Mocker.GetMock<IHttpClient>()
|
2023-07-16 18:07:31 +00:00
|
|
|
.Setup(o => o.ExecuteAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get &&
|
2020-08-11 20:09:18 +00:00
|
|
|
v.Url.FullUri.Contains("ajax.php?action=browse") &&
|
|
|
|
v.Headers.Get("Authorization") == ((RedactedSettings)Subject.Definition.Settings).ApiKey)))
|
2023-07-16 18:07:31 +00:00
|
|
|
.Returns<HttpRequest>(r => Task.FromResult(new HttpResponse(r, new HttpHeader { ContentType = "application/json" }, recentFeed)));
|
2020-08-11 20:09:18 +00:00
|
|
|
|
2023-07-16 18:07:31 +00:00
|
|
|
var releases = await Subject.FetchRecent();
|
2020-08-11 20:09:18 +00:00
|
|
|
|
|
|
|
releases.Should().HaveCount(4);
|
|
|
|
|
|
|
|
var releaseInfo = releases.First();
|
|
|
|
|
2023-12-13 14:33:29 +00:00
|
|
|
releaseInfo.Title.Should().Be("Shania Twain - Shania Twain (1993) [Album] [FLAC 24bit Lossless / WEB]");
|
2022-07-19 20:08:53 +00:00
|
|
|
releaseInfo.DownloadProtocol.Should().Be(nameof(TorrentDownloadProtocol));
|
2023-12-13 14:33:29 +00:00
|
|
|
releaseInfo.DownloadUrl.Should().Be("https://redacted.ch/ajax.php?action=download&id=1541452");
|
2020-08-11 20:09:18 +00:00
|
|
|
releaseInfo.InfoUrl.Should().Be("https://redacted.ch/torrents.php?id=106951&torrentid=1541452");
|
|
|
|
releaseInfo.CommentUrl.Should().Be(null);
|
|
|
|
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
|
|
|
|
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2017-12-11 00:17:53"));
|
|
|
|
releaseInfo.Size.Should().Be(653734702);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|