diff --git a/PlexRequests.Core/SettingModels/AuthenticationSettings.cs b/PlexRequests.Core/SettingModels/AuthenticationSettings.cs
index 6a86c9005..ae1469d4f 100644
--- a/PlexRequests.Core/SettingModels/AuthenticationSettings.cs
+++ b/PlexRequests.Core/SettingModels/AuthenticationSettings.cs
@@ -1,67 +1,69 @@
-#region Copyright
-// /************************************************************************
-// Copyright (c) 2016 Jamie Rees
-// File: AuthenticationSettings.cs
-// Created By: Jamie Rees
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ************************************************************************/
-#endregion
-using System;
-using System.Collections.Generic;
-
-using Newtonsoft.Json;
-
-namespace PlexRequests.Core.SettingModels
-{
- public class AuthenticationSettings : Settings
- {
- public bool UserAuthentication { get; set; }
- public bool UsePassword { get; set; }
- public string PlexAuthToken { get; set; }
-
-
- ///
- /// A comma separated list of users.
- ///
- public string DeniedUsers { get; set; }
-
- [JsonIgnore]
- public List DeniedUserList
- {
- get
- {
- var users = new List();
- if (string.IsNullOrEmpty(DeniedUsers))
- {
- return users;
- }
-
- var splitUsers = DeniedUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- foreach (var user in splitUsers)
- {
- if (!string.IsNullOrWhiteSpace(user))
- users.Add(user.Trim());
- }
- return users;
- }
- }
- }
-}
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: AuthenticationSettings.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+using System;
+using System.Collections.Generic;
+
+using Newtonsoft.Json;
+
+namespace PlexRequests.Core.SettingModels
+{
+ public class AuthenticationSettings : Settings
+ {
+ public bool UserAuthentication { get; set; }
+ public bool UsePassword { get; set; }
+ [JsonProperty("PlexAuthToken")]
+ [Obsolete("This should be migrated over into the Plex Settings and then removed in the next release")]
+ public string OldPlexAuthToken { get; set; }
+
+
+ ///
+ /// A comma separated list of users.
+ ///
+ public string DeniedUsers { get; set; }
+
+ [JsonIgnore]
+ public List DeniedUserList
+ {
+ get
+ {
+ var users = new List();
+ if (string.IsNullOrEmpty(DeniedUsers))
+ {
+ return users;
+ }
+
+ var splitUsers = DeniedUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+ foreach (var user in splitUsers)
+ {
+ if (!string.IsNullOrWhiteSpace(user))
+ users.Add(user.Trim());
+ }
+ return users;
+ }
+ }
+ }
+}
diff --git a/PlexRequests.Core/SettingModels/PlexSettings.cs b/PlexRequests.Core/SettingModels/PlexSettings.cs
index e56595c51..1b9d2ab54 100644
--- a/PlexRequests.Core/SettingModels/PlexSettings.cs
+++ b/PlexRequests.Core/SettingModels/PlexSettings.cs
@@ -1,57 +1,59 @@
-#region Copyright
-// /************************************************************************
-// Copyright (c) 2016 Jamie Rees
-// File: CouchPotatoSettings.cs
-// Created By: Jamie Rees
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ************************************************************************/
-#endregion
-
-using System;
-using Newtonsoft.Json;
-using PlexRequests.Helpers;
-
-namespace PlexRequests.Core.SettingModels
-{
- public class PlexSettings : Settings
- {
- public string Ip { get; set; }
- public int Port { get; set; }
- public bool Ssl { get; set; }
- public string SubDir { get; set; }
- public bool AdvancedSearch { get; set; }
-
- [JsonIgnore]
- public Uri FullUri
- {
- get
- {
- if (!string.IsNullOrEmpty(SubDir))
- {
- var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
- return formattedSubDir;
- }
- var formatted = Ip.ReturnUri(Port, Ssl);
- return formatted;
- }
- }
- }
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: CouchPotatoSettings.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+
+using System;
+using Newtonsoft.Json;
+using PlexRequests.Helpers;
+
+namespace PlexRequests.Core.SettingModels
+{
+ public class PlexSettings : Settings
+ {
+ public string Ip { get; set; }
+ public int Port { get; set; }
+ public bool Ssl { get; set; }
+ public string SubDir { get; set; }
+ public bool AdvancedSearch { get; set; }
+
+ public string PlexAuthToken { get; set; }
+
+ [JsonIgnore]
+ public Uri FullUri
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(SubDir))
+ {
+ var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
+ return formattedSubDir;
+ }
+ var formatted = Ip.ReturnUri(Port, Ssl);
+ return formatted;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/PlexRequests.Core/Setup.cs b/PlexRequests.Core/Setup.cs
index a3a407aa1..207745298 100644
--- a/PlexRequests.Core/Setup.cs
+++ b/PlexRequests.Core/Setup.cs
@@ -61,6 +61,10 @@ namespace PlexRequests.Core
{
MigrateToVersion1800();
}
+ if (version > 1899 && version <= 1900)
+ {
+ MigrateToVersion1900();
+ }
}
return Db.DbConnection().ConnectionString;
@@ -167,11 +171,23 @@ namespace PlexRequests.Core
Log.Error(ex, "Failed to cache CouchPotato quality profiles!");
}
}
- public void MigrateToVersion1700()
+ public void MigrateToVersion1900()
{
- // Drop old tables
- TableCreation.DropTable(Db.DbConnection(), "User");
- TableCreation.DropTable(Db.DbConnection(), "Log");
+ // Need to change the Plex Token location
+ var authSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider()));
+ var auth = authSettings.GetSettings();
+ var plexSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider()));
+
+ var currentSettings = plexSettings.GetSettings();
+ if (!string.IsNullOrEmpty(auth.OldPlexAuthToken))
+ {
+ currentSettings.PlexAuthToken = auth.OldPlexAuthToken;
+ plexSettings.SaveSettings(currentSettings);
+
+ // Clear out the old value
+ auth.OldPlexAuthToken = string.Empty;
+ authSettings.SaveSettings(auth);
+ }
}
///
diff --git a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
index 7235639af..da1e5935a 100644
--- a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
+++ b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
@@ -1,590 +1,590 @@
-#region Copyright
-// /************************************************************************
-// Copyright (c) 2016 Jamie Rees
-// File: PlexAvailabilityCheckerTests.cs
-// Created By: Jamie Rees
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-// ************************************************************************/
-#endregion
-using System;
-
-using Moq;
-
-using NUnit.Framework;
-
-using PlexRequests.Api.Interfaces;
-using PlexRequests.Core;
-using PlexRequests.Core.SettingModels;
-using PlexRequests.Services.Interfaces;
-using PlexRequests.Helpers;
-using PlexRequests.Services.Jobs;
-using PlexRequests.Store.Models;
-using PlexRequests.Store.Repository;
-
-namespace PlexRequests.Services.Tests
-{
- [TestFixture]
- public class PlexAvailabilityCheckerTests
- {
- public IAvailabilityChecker Checker { get; set; }
- private Mock> SettingsMock { get; set; }
- private Mock> AuthMock { get; set; }
- private Mock RequestMock { get; set; }
- private Mock PlexMock { get; set; }
- private Mock CacheMock { get; set; }
- private Mock NotificationMock { get; set; }
- private Mock JobRec { get; set; }
- private Mock> NotifyUsers { get; set; }
-
- [SetUp]
- public void Setup()
- {
- SettingsMock = new Mock>();
- AuthMock = new Mock>();
- RequestMock = new Mock();
- PlexMock = new Mock();
- NotificationMock = new Mock();
- CacheMock = new Mock();
- NotifyUsers = new Mock>();
- JobRec = new Mock();
- Checker = new PlexAvailabilityChecker(SettingsMock.Object, AuthMock.Object, RequestMock.Object, PlexMock.Object, CacheMock.Object, NotificationMock.Object, JobRec.Object, NotifyUsers.Object);
-
- }
-
- [Test]
- public void InvalidSettings()
- {
- Checker.CheckAndUpdateAll();
- PlexMock.Verify(x => x.GetLibrary(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never);
- PlexMock.Verify(x => x.GetAccount(It.IsAny()), Times.Never);
- PlexMock.Verify(x => x.GetLibrarySections(It.IsAny(), It.IsAny()), Times.Never);
- PlexMock.Verify(x => x.GetStatus(It.IsAny(), It.IsAny()), Times.Never);
- PlexMock.Verify(x => x.GetUsers(It.IsAny()), Times.Never);
- }
-
- //[Test]
- //public void IsAvailableTest()
- //{
- // var settingsMock = new Mock>();
- // var authMock = new Mock>();
- // var requestMock = new Mock();
- // var plexMock = new Mock();
- // var cacheMock = new Mock();
-
- // var searchResult = new PlexSearch { Video = new List