Fixed: Removing torcache url query params to avoid redirect.

fixes #799
Removing query param was cleaner coz it avoids spoofing the referrer.
This commit is contained in:
Taloth Saldono
2015-09-21 21:59:35 +02:00
parent d7eae958b7
commit 57afa668e1
9 changed files with 122 additions and 3 deletions
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Http;
using NzbDrone.Test.Common;
using FluentAssertions;
namespace NzbDrone.Core.Test.Http
{
[TestFixture]
public class TorCacheHttpRequestInterceptorFixture : TestBase<TorCacheHttpRequestInterceptor>
{
[Test]
public void should_remove_query_params_from_torcache_request()
{
var request = new HttpRequest("http://torcache.net/download/123.torrent?title=something");
var newRequest = Subject.PreRequest(request);
newRequest.Url.AbsoluteUri.Should().Be("http://torcache.net/download/123.torrent");
}
[TestCase("http://site.com/download?url=torcache.net&blaat=1")]
[TestCase("http://torcache.net.com/download?url=123")]
public void should_not_remove_query_params_from_other_requests(string url)
{
var request = new HttpRequest(url);
var newRequest = Subject.PreRequest(request);
newRequest.Url.AbsoluteUri.Should().Be(url);
}
}
}