diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs new file mode 100644 index 000000000..b3e97b6c9 --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs @@ -0,0 +1,66 @@ +using System.Linq; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.Datastore.Migration; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.KickassTorrents; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore.Migration +{ + [TestFixture] + public class update_kickass_url_migration_fixture : MigrationTest + { + [TestCase("http://kickass.so")] + [TestCase("https://kickass.so")] + [TestCase("http://kickass.to")] + [TestCase("https://kickass.to")] + [TestCase("http://kat.cr")] + // [TestCase("HTTP://KICKASS.SO")] Not sure if there is an easy way to do this, not sure if worth it. + public void should_replace_old_url(string oldUrl) + { + WithTestDb(c => + { + c.Insert.IntoTable("Indexers").Row(new + { + Name = "Kickass_wrong_url", + Implementation = "KickassTorrents", + Settings = new KickassTorrentsSettings + { + BaseUrl = oldUrl + }.ToJson(), + ConfigContract = "KickassTorrentsSettings" + }); + }); + + var items = Mocker.Resolve().All().ToList(); + + items.Should().HaveCount(1); + items.First().Settings.As().BaseUrl.Should().Be("https://kat.cr"); + } + + [Test] + public void should_not_replace_other_indexers() + { + WithTestDb(c => + { + c.Insert.IntoTable("Indexers").Row(new + { + Name = "not_kickass", + Implementation = "NotKickassTorrents", + Settings = new KickassTorrentsSettings + { + BaseUrl = "kickass.so", + }.ToJson(), + ConfigContract = "KickassTorrentsSettings" + }); + }); + + var items = Mocker.Resolve().All().ToList(); + + items.Should().HaveCount(1); + items.First().Settings.As().BaseUrl.Should().Be("kickass.so"); + } + } +} diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index d7376ac81..12e11e476 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -127,6 +127,7 @@ + diff --git a/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs new file mode 100644 index 000000000..aa8166803 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs @@ -0,0 +1,18 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(90)] + public class update_kickass_url : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql( + "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.so', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + + "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.to', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + + "UPDATE Indexers SET Settings = Replace(Settings, 'http://', 'https://') WHERE Implementation = 'KickassTorrents';" + ); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/KickassTorrents/KickassTorrentsSettings.cs b/src/NzbDrone.Core/Indexers/KickassTorrents/KickassTorrentsSettings.cs index b623cac04..aac647d30 100644 --- a/src/NzbDrone.Core/Indexers/KickassTorrents/KickassTorrentsSettings.cs +++ b/src/NzbDrone.Core/Indexers/KickassTorrents/KickassTorrentsSettings.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.KickassTorrents public KickassTorrentsSettings() { - BaseUrl = "http://kat.cr"; + BaseUrl = "https://kat.cr"; VerifiedOnly = true; } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 3a7215a51..1e271063c 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -263,6 +263,7 @@ +