From 36f97329ff52f878c64d85c3350d7b86ee7572b4 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Wed, 1 Jul 2015 01:41:58 -0700 Subject: [PATCH 1/2] Update the kickass url to https://kat.cr --- .../089_update_kickass_urlFixture.cs | 66 +++++++++++++++++++ .../NzbDrone.Core.Test.csproj | 1 + .../Migration/089_update_kickass_url.cs | 18 +++++ .../KickassTorrentsSettings.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/089_update_kickass_urlFixture.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/089_update_kickass_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/089_update_kickass_urlFixture.cs new file mode 100644 index 000000000..b3e97b6c9 --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/089_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 f83e9d7f8..d8571cf5f 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/089_update_kickass_url.cs b/src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs new file mode 100644 index 000000000..ebc64e835 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs @@ -0,0 +1,18 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(89)] + 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 @@ + From a143c0b75e483821ab2c5a10b12ddacdddbb55d9 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Wed, 1 Jul 2015 11:44:43 -0700 Subject: [PATCH 2/2] Updated migration number to 90 --- ...e_kickass_urlFixture.cs => 090_update_kickass_urlFixture.cs} | 0 .../{089_update_kickass_url.cs => 090_update_kickass_url.cs} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/NzbDrone.Core.Test/Datastore/Migration/{089_update_kickass_urlFixture.cs => 090_update_kickass_urlFixture.cs} (100%) rename src/NzbDrone.Core/Datastore/Migration/{089_update_kickass_url.cs => 090_update_kickass_url.cs} (97%) diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/089_update_kickass_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs similarity index 100% rename from src/NzbDrone.Core.Test/Datastore/Migration/089_update_kickass_urlFixture.cs rename to src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs diff --git a/src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs similarity index 97% rename from src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs rename to src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs index ebc64e835..aa8166803 100644 --- a/src/NzbDrone.Core/Datastore/Migration/089_update_kickass_url.cs +++ b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs @@ -3,7 +3,7 @@ using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration { - [Migration(89)] + [Migration(90)] public class update_kickass_url : NzbDroneMigrationBase { protected override void MainDbUpgrade()