mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -07:00
Fixed the bug in #438 and added unit tests to make so we dont break it in the future
This commit is contained in:
parent
9d82add7ae
commit
4d85000753
5 changed files with 468 additions and 308 deletions
|
@ -1,365 +1,360 @@
|
||||||
//#region Copyright
|
#region Copyright
|
||||||
//// /************************************************************************
|
// /************************************************************************
|
||||||
//// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
//// File: UserLoginModuleTests.cs
|
// File: UserLoginModuleTests.cs
|
||||||
//// Created By: Jamie Rees
|
// Created By: Jamie Rees
|
||||||
////
|
//
|
||||||
//// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
//// a copy of this software and associated documentation files (the
|
// a copy of this software and associated documentation files (the
|
||||||
//// "Software"), to deal in the Software without restriction, including
|
// "Software"), to deal in the Software without restriction, including
|
||||||
//// without limitation the rights to use, copy, modify, merge, publish,
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
//// distribute, sublicense, and/or sell copies of the Software, and to
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
//// permit persons to whom the Software is furnished to do so, subject to
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
//// the following conditions:
|
// the following conditions:
|
||||||
////
|
//
|
||||||
//// The above copyright notice and this permission notice shall be
|
// The above copyright notice and this permission notice shall be
|
||||||
//// included in all copies or substantial portions of the Software.
|
// included in all copies or substantial portions of the Software.
|
||||||
////
|
//
|
||||||
//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
//// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
//// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
//// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
//// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
//// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
//// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
//// ************************************************************************/
|
// ************************************************************************/
|
||||||
//#endregion
|
#endregion
|
||||||
//using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
//using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
//using Moq;
|
using Moq;
|
||||||
|
|
||||||
//using Nancy;
|
using Nancy;
|
||||||
//using Nancy.Testing;
|
using Nancy.Testing;
|
||||||
|
|
||||||
//using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
//using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
//using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
//using PlexRequests.Api.Interfaces;
|
using PlexRequests.Api.Interfaces;
|
||||||
//using PlexRequests.Api.Models.Plex;
|
using PlexRequests.Api.Models.Plex;
|
||||||
//using PlexRequests.Core;
|
using PlexRequests.Core;
|
||||||
//using PlexRequests.Core.SettingModels;
|
using PlexRequests.Core.SettingModels;
|
||||||
//using PlexRequests.Services.Interfaces;
|
using PlexRequests.Services.Interfaces;
|
||||||
//using PlexRequests.Store.Models;
|
using PlexRequests.Store.Models;
|
||||||
//using PlexRequests.Store.Repository;
|
using PlexRequests.Store.Repository;
|
||||||
//using PlexRequests.UI.Models;
|
using PlexRequests.UI.Models;
|
||||||
//using PlexRequests.UI.Modules;
|
using PlexRequests.UI.Modules;
|
||||||
//using PlexRequests.Helpers;
|
using PlexRequests.Helpers;
|
||||||
//using PlexRequests.Helpers.Analytics;
|
using PlexRequests.Helpers.Analytics;
|
||||||
//using PlexRequests.UI.Helpers;
|
using PlexRequests.UI.Helpers;
|
||||||
|
|
||||||
//namespace PlexRequests.UI.Tests
|
namespace PlexRequests.UI.Tests
|
||||||
//{
|
{
|
||||||
// [TestFixture]
|
[TestFixture]
|
||||||
// public class AdminModuleTests
|
public class AdminModuleTests
|
||||||
// {
|
{
|
||||||
// private Mock<ISettingsService<PlexRequestSettings>> PlexRequestMock { get; set; }
|
private Mock<ISettingsService<PlexRequestSettings>> PlexRequestMock { get; set; }
|
||||||
// private Mock<ISettingsService<CouchPotatoSettings>> CpMock { get; set; }
|
private Mock<ISettingsService<CouchPotatoSettings>> CpMock { get; set; }
|
||||||
// private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
||||||
// private Mock<ISettingsService<PlexSettings>> PlexSettingsMock { get; set; }
|
private Mock<ISettingsService<PlexSettings>> PlexSettingsMock { get; set; }
|
||||||
// private Mock<ISettingsService<SonarrSettings>> SonarrSettingsMock { get; set; }
|
private Mock<ISettingsService<SonarrSettings>> SonarrSettingsMock { get; set; }
|
||||||
// private Mock<ISettingsService<SickRageSettings>> SickRageSettingsMock { get; set; }
|
private Mock<ISettingsService<SickRageSettings>> SickRageSettingsMock { get; set; }
|
||||||
// private Mock<ISettingsService<ScheduledJobsSettings>> ScheduledJobsSettingsMock { get; set; }
|
private Mock<ISettingsService<ScheduledJobsSettings>> ScheduledJobsSettingsMock { get; set; }
|
||||||
// private Mock<ISettingsService<EmailNotificationSettings>> EmailMock { get; set; }
|
private Mock<ISettingsService<EmailNotificationSettings>> EmailMock { get; set; }
|
||||||
// private Mock<ISettingsService<PushbulletNotificationSettings>> PushbulletSettings { get; set; }
|
private Mock<ISettingsService<PushbulletNotificationSettings>> PushbulletSettings { get; set; }
|
||||||
// private Mock<ISettingsService<PushoverNotificationSettings>> PushoverSettings { get; set; }
|
private Mock<ISettingsService<PushoverNotificationSettings>> PushoverSettings { get; set; }
|
||||||
// private Mock<ISettingsService<HeadphonesSettings>> HeadphonesSettings { get; set; }
|
private Mock<ISettingsService<HeadphonesSettings>> HeadphonesSettings { get; set; }
|
||||||
// private Mock<IPlexApi> PlexMock { get; set; }
|
private Mock<IPlexApi> PlexMock { get; set; }
|
||||||
// private Mock<ISonarrApi> SonarrApiMock { get; set; }
|
private Mock<ISonarrApi> SonarrApiMock { get; set; }
|
||||||
// private Mock<IPushbulletApi> PushbulletApi { get; set; }
|
private Mock<IPushbulletApi> PushbulletApi { get; set; }
|
||||||
// private Mock<IPushoverApi> PushoverApi { get; set; }
|
private Mock<IPushoverApi> PushoverApi { get; set; }
|
||||||
// private Mock<ICouchPotatoApi> CpApi { get; set; }
|
private Mock<ICouchPotatoApi> CpApi { get; set; }
|
||||||
// private Mock<IJobRecord> RecorderMock { get; set; }
|
private Mock<IJobRecord> RecorderMock { get; set; }
|
||||||
// private Mock<IRepository<LogEntity>> LogRepo { get; set; }
|
private Mock<IRepository<LogEntity>> LogRepo { get; set; }
|
||||||
// private Mock<INotificationService> NotificationService { get; set; }
|
private Mock<INotificationService> NotificationService { get; set; }
|
||||||
// private Mock<ICacheProvider> Cache { get; set; }
|
private Mock<ICacheProvider> Cache { get; set; }
|
||||||
// private Mock<ISettingsService<LogSettings>> Log { get; set; }
|
private Mock<ISettingsService<LogSettings>> Log { get; set; }
|
||||||
// private Mock<ISettingsService<SlackNotificationSettings>> SlackSettings { get; set; }
|
private Mock<ISettingsService<SlackNotificationSettings>> SlackSettings { get; set; }
|
||||||
// private Mock<ISettingsService<LandingPageSettings>> LandingPageSettings { get; set; }
|
private Mock<ISettingsService<LandingPageSettings>> LandingPageSettings { get; set; }
|
||||||
// private Mock<ISlackApi> SlackApi { get; set; }
|
private Mock<ISlackApi> SlackApi { get; set; }
|
||||||
// private Mock<IAnalytics> IAnalytics { get; set; }
|
private Mock<IAnalytics> Analytics { get; set; }
|
||||||
|
|
||||||
// private ConfigurableBootstrapper Bootstrapper { get; set; }
|
private ConfigurableBootstrapper Bootstrapper { get; set; }
|
||||||
|
|
||||||
// [SetUp]
|
[SetUp]
|
||||||
// public void Setup()
|
public void Setup()
|
||||||
// {
|
{
|
||||||
// AuthMock = new Mock<ISettingsService<AuthenticationSettings>>();
|
AuthMock = new Mock<ISettingsService<AuthenticationSettings>>();
|
||||||
// var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
|
var expectedSettings = new AuthenticationSettings { UserAuthentication = false };
|
||||||
// AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
||||||
|
PlexSettingsMock = new Mock<ISettingsService<PlexSettings>>();
|
||||||
|
PlexSettingsMock.Setup(x => x.GetSettings()).Returns(new PlexSettings {PlexAuthToken = "abc"});
|
||||||
|
|
||||||
// PlexMock = new Mock<IPlexApi>();
|
PlexMock = new Mock<IPlexApi>();
|
||||||
// PlexMock.Setup(x => x.SignIn("Username1", "Password1"))
|
PlexMock.Setup(x => x.SignIn("Username1", "Password1"))
|
||||||
// .Returns(new PlexAuthentication { user = new User { authentication_token = "abc", title = "Username1" } });
|
.Returns(new PlexAuthentication { user = new User { authentication_token = "abc", title = "Username1" } });
|
||||||
|
|
||||||
// PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
||||||
// PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
|
PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings() );
|
||||||
// CpMock = new Mock<ISettingsService<CouchPotatoSettings>>();
|
CpMock = new Mock<ISettingsService<CouchPotatoSettings>>();
|
||||||
// PlexSettingsMock = new Mock<ISettingsService<PlexSettings>>();
|
|
||||||
// SonarrApiMock = new Mock<ISonarrApi>();
|
SonarrApiMock = new Mock<ISonarrApi>();
|
||||||
// SonarrSettingsMock = new Mock<ISettingsService<SonarrSettings>>();
|
SonarrSettingsMock = new Mock<ISettingsService<SonarrSettings>>();
|
||||||
// EmailMock = new Mock<ISettingsService<EmailNotificationSettings>>();
|
EmailMock = new Mock<ISettingsService<EmailNotificationSettings>>();
|
||||||
// PushbulletApi = new Mock<IPushbulletApi>();
|
PushbulletApi = new Mock<IPushbulletApi>();
|
||||||
// PushbulletSettings = new Mock<ISettingsService<PushbulletNotificationSettings>>();
|
PushbulletSettings = new Mock<ISettingsService<PushbulletNotificationSettings>>();
|
||||||
// CpApi = new Mock<ICouchPotatoApi>();
|
CpApi = new Mock<ICouchPotatoApi>();
|
||||||
// SickRageSettingsMock = new Mock<ISettingsService<SickRageSettings>>();
|
SickRageSettingsMock = new Mock<ISettingsService<SickRageSettings>>();
|
||||||
// LogRepo = new Mock<IRepository<LogEntity>>();
|
LogRepo = new Mock<IRepository<LogEntity>>();
|
||||||
// PushoverSettings = new Mock<ISettingsService<PushoverNotificationSettings>>();
|
PushoverSettings = new Mock<ISettingsService<PushoverNotificationSettings>>();
|
||||||
// PushoverApi = new Mock<IPushoverApi>();
|
PushoverApi = new Mock<IPushoverApi>();
|
||||||
// NotificationService = new Mock<INotificationService>();
|
NotificationService = new Mock<INotificationService>();
|
||||||
// HeadphonesSettings = new Mock<ISettingsService<HeadphonesSettings>>();
|
HeadphonesSettings = new Mock<ISettingsService<HeadphonesSettings>>();
|
||||||
// Cache = new Mock<ICacheProvider>();
|
Cache = new Mock<ICacheProvider>();
|
||||||
// Log = new Mock<ISettingsService<LogSettings>>();
|
Log = new Mock<ISettingsService<LogSettings>>();
|
||||||
// SlackApi = new Mock<ISlackApi>();
|
SlackApi = new Mock<ISlackApi>();
|
||||||
// SlackSettings = new Mock<ISettingsService<SlackNotificationSettings>>();
|
SlackSettings = new Mock<ISettingsService<SlackNotificationSettings>>();
|
||||||
// LandingPageSettings = new Mock<ISettingsService<LandingPageSettings>>();
|
LandingPageSettings = new Mock<ISettingsService<LandingPageSettings>>();
|
||||||
// ScheduledJobsSettingsMock = new Mock<ISettingsService<ScheduledJobsSettings>>();
|
ScheduledJobsSettingsMock = new Mock<ISettingsService<ScheduledJobsSettings>>();
|
||||||
// RecorderMock = new Mock<IJobRecord>();
|
RecorderMock = new Mock<IJobRecord>();
|
||||||
// IAnalytics = new Mock<IAnalytics>();
|
Analytics = new Mock<IAnalytics>();
|
||||||
|
|
||||||
|
|
||||||
// Bootstrapper = new ConfigurableBootstrapper(with =>
|
Bootstrapper = new ConfigurableBootstrapper(with =>
|
||||||
// {
|
{
|
||||||
// with.Module<AdminModule>();
|
with.Module<AdminModule>();
|
||||||
// with.Dependency(AuthMock.Object);
|
with.Dependency(AuthMock.Object);
|
||||||
// with.Dependency(PlexRequestMock.Object);
|
with.Dependency(PlexRequestMock.Object);
|
||||||
// with.Dependency(CpMock.Object);
|
with.Dependency(CpMock.Object);
|
||||||
// with.Dependency(PlexSettingsMock.Object);
|
with.Dependency(PlexSettingsMock.Object);
|
||||||
// with.Dependency(SonarrApiMock.Object);
|
with.Dependency(SonarrApiMock.Object);
|
||||||
// with.Dependency(SonarrSettingsMock.Object);
|
with.Dependency(SonarrSettingsMock.Object);
|
||||||
// with.Dependency(PlexMock.Object);
|
with.Dependency(PlexMock.Object);
|
||||||
// with.Dependency(EmailMock.Object);
|
with.Dependency(EmailMock.Object);
|
||||||
// with.Dependency(PushbulletApi.Object);
|
with.Dependency(PushbulletApi.Object);
|
||||||
// with.Dependency(PushbulletSettings.Object);
|
with.Dependency(PushbulletSettings.Object);
|
||||||
// with.Dependency(CpApi.Object);
|
with.Dependency(CpApi.Object);
|
||||||
// with.Dependency(SickRageSettingsMock.Object);
|
with.Dependency(SickRageSettingsMock.Object);
|
||||||
// with.Dependency(LogRepo.Object);
|
with.Dependency(LogRepo.Object);
|
||||||
// with.Dependency(PushoverSettings.Object);
|
with.Dependency(PushoverSettings.Object);
|
||||||
// with.Dependency(PushoverApi.Object);
|
with.Dependency(PushoverApi.Object);
|
||||||
// with.Dependency(NotificationService.Object);
|
with.Dependency(NotificationService.Object);
|
||||||
// with.Dependency(IAnalytics.Object);
|
with.Dependency(Analytics.Object);
|
||||||
// with.Dependency(HeadphonesSettings.Object);
|
with.Dependency(HeadphonesSettings.Object);
|
||||||
// with.Dependency(Cache.Object);
|
with.Dependency(Cache.Object);
|
||||||
// with.Dependency(Log.Object);
|
with.Dependency(Log.Object);
|
||||||
// with.Dependency(SlackApi.Object);
|
with.Dependency(SlackApi.Object);
|
||||||
// with.Dependency(LandingPageSettings.Object);
|
with.Dependency(LandingPageSettings.Object);
|
||||||
// with.Dependency(SlackSettings.Object);
|
with.Dependency(SlackSettings.Object);
|
||||||
// with.Dependency(ScheduledJobsSettingsMock.Object);
|
with.Dependency(ScheduledJobsSettingsMock.Object);
|
||||||
// with.Dependency(RecorderMock.Object);
|
with.Dependency(RecorderMock.Object);
|
||||||
// with.RootPathProvider<TestRootPathProvider>();
|
with.RootPathProvider<TestRootPathProvider>();
|
||||||
// with.RequestStartup((container, pipelines, context) =>
|
with.RequestStartup((container, pipelines, context) =>
|
||||||
// {
|
{
|
||||||
// context.CurrentUser = new UserIdentity { UserName = "user", Claims = new List<string> {"Admin"} };
|
context.CurrentUser = new UserIdentity { UserName = "user", Claims = new List<string> { "Admin" } };
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Bootstrapper.WithSession(new Dictionary<string, object>());
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void RequestAuthTokenTestNewSettings()
|
public void RequestAuthTokenTestNewSettings()
|
||||||
// {
|
{
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Post("/admin/requestauth", with =>
|
var result = browser.Post("/admin/requestauth", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", "Username1");
|
with.FormValue("username", "Username1");
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
||||||
// Assert.That(body.Result, Is.EqualTo(true));
|
Assert.That(body.Result, Is.EqualTo(true));
|
||||||
// PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Once);
|
PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Once);
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
PlexSettingsMock.Verify(x => x.SaveSettings(It.IsAny<PlexSettings>()), Times.Once);
|
||||||
// AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Once);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void RequestAuthTokenTestEmptyCredentials()
|
public void RequestAuthTokenTestEmptyCredentials()
|
||||||
// {
|
{
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Post("/admin/requestauth", with =>
|
var result = browser.Post("/admin/requestauth", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", string.Empty);
|
with.FormValue("username", string.Empty);
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
||||||
// Assert.That(body.Result, Is.EqualTo(false));
|
Assert.That(body.Result, Is.EqualTo(false));
|
||||||
// Assert.That(body.Message, Is.Not.Empty);
|
Assert.That(body.Message, Is.Not.Empty);
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Never);
|
PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Never);
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Never);
|
AuthMock.Verify(x => x.GetSettings(), Times.Never);
|
||||||
// AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Never);
|
AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Never);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void RequestAuthTokenTesPlexSignInFail()
|
public void RequestAuthTokenTesPlexSignInFail()
|
||||||
// {
|
{
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Post("/admin/requestauth", with =>
|
var result = browser.Post("/admin/requestauth", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", "Badusername");
|
with.FormValue("username", "Badusername");
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
||||||
// Assert.That(body.Result, Is.EqualTo(false));
|
Assert.That(body.Result, Is.EqualTo(false));
|
||||||
// Assert.That(body.Message, Is.Not.Empty);
|
Assert.That(body.Message, Is.Not.Empty);
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.SignIn("Badusername", "Password1"), Times.Once);
|
PlexMock.Verify(x => x.SignIn("Badusername", "Password1"), Times.Once);
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Never);
|
AuthMock.Verify(x => x.GetSettings(), Times.Never);
|
||||||
// AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Never);
|
AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Never);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void RequestAuthTokenTestExistingSettings()
|
public void RequestAuthTokenTestExistingSettings()
|
||||||
// {
|
{
|
||||||
// AuthMock.Setup(x => x.GetSettings()).Returns(() => null);
|
AuthMock.Setup(x => x.GetSettings()).Returns(() => null);
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Post("/admin/requestauth", with =>
|
var result = browser.Post("/admin/requestauth", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", "Username1");
|
with.FormValue("username", "Username1");
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
var body = JsonConvert.DeserializeObject<JsonResponseModel>(result.Body.AsString());
|
||||||
// Assert.That(body.Result, Is.EqualTo(true));
|
Assert.That(body.Result, Is.EqualTo(true));
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Once);
|
PlexMock.Verify(x => x.SignIn("Username1", "Password1"), Times.Once);
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
}
|
||||||
// AuthMock.Verify(x => x.SaveSettings(It.IsAny<AuthenticationSettings>()), Times.Once);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void GetUsersSuccessfully()
|
public void GetUsersSuccessfully()
|
||||||
// {
|
{
|
||||||
// var users = new PlexFriends { User = new[] { new UserFriends { Title = "abc2" }, } };
|
var users = new PlexFriends { User = new[] { new UserFriends { Title = "abc2" }, } };
|
||||||
// PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(users);
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(users);
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Get("/admin/getusers", with =>
|
var result = browser.Get("/admin/getusers", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", "Username1");
|
with.FormValue("username", "Username1");
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
|
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JObject>(result.Body.AsString());
|
var body = JsonConvert.DeserializeObject<JObject>(result.Body.AsString());
|
||||||
// var user = body["users"];
|
var user = body["users"];
|
||||||
// Assert.That(body, Is.Not.Null);
|
Assert.That(body, Is.Not.Null);
|
||||||
// Assert.That(user.ToString().Contains("abc"), Is.True);
|
Assert.That(user.ToString().Contains("abc"), Is.True);
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void GetUsersReturnsNoUsers()
|
public void GetUsersReturnsNoUsers()
|
||||||
// {
|
{
|
||||||
// var users = new PlexFriends();
|
var users = new PlexFriends();
|
||||||
// PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(users);
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(users);
|
||||||
// var browser = new Browser(Bootstrapper);
|
var browser = new Browser(Bootstrapper);
|
||||||
|
|
||||||
// var result = browser.Get("/admin/getusers", with =>
|
var result = browser.Get("/admin/getusers", with =>
|
||||||
// {
|
{
|
||||||
// with.HttpRequest();
|
with.HttpRequest();
|
||||||
// with.Header("Accept", "application/json");
|
with.Header("Accept", "application/json");
|
||||||
// with.FormValue("username", "Username1");
|
with.FormValue("username", "Username1");
|
||||||
// with.FormValue("password", "Password1");
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
});
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<string>(result.Body.AsString());
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
// Assert.That(body, Is.Not.Null);
|
|
||||||
// Assert.That(string.IsNullOrWhiteSpace(body), Is.True);
|
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
var body = JsonConvert.DeserializeObject<string>(result.Body.AsString());
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
Assert.That(body, Is.Not.Null);
|
||||||
// }
|
Assert.That(string.IsNullOrWhiteSpace(body), Is.True);
|
||||||
|
|
||||||
// [Test]
|
PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
||||||
// public void GetUsersReturnsNull()
|
}
|
||||||
// {
|
|
||||||
// PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(() => null);
|
|
||||||
// var browser = new Browser(Bootstrapper);
|
|
||||||
|
|
||||||
// var result = browser.Get("/admin/getusers", with =>
|
[Test]
|
||||||
// {
|
public void GetUsersReturnsNull()
|
||||||
// with.HttpRequest();
|
{
|
||||||
// with.Header("Accept", "application/json");
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(() => null);
|
||||||
// with.FormValue("username", "Username1");
|
var browser = new Browser(Bootstrapper);
|
||||||
// with.FormValue("password", "Password1");
|
|
||||||
|
|
||||||
// });
|
var result = browser.Get("/admin/getusers", with =>
|
||||||
|
{
|
||||||
|
with.HttpRequest();
|
||||||
|
with.Header("Accept", "application/json");
|
||||||
|
with.FormValue("username", "Username1");
|
||||||
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
});
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<string>(result.Body.AsString());
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
// Assert.That(body, Is.Not.Null);
|
|
||||||
// Assert.That(string.IsNullOrWhiteSpace(body), Is.True);
|
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
var body = JsonConvert.DeserializeObject<string>(result.Body.AsString());
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
Assert.That(body, Is.Not.Null);
|
||||||
// }
|
Assert.That(string.IsNullOrWhiteSpace(body), Is.True);
|
||||||
|
|
||||||
// [Test]
|
PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
||||||
// public void GetUsersTokenIsNull()
|
}
|
||||||
// {
|
|
||||||
// AuthMock.Setup(x => x.GetSettings()).Returns(new AuthenticationSettings());
|
|
||||||
// var browser = new Browser(Bootstrapper);
|
|
||||||
|
|
||||||
// var result = browser.Get("/admin/getusers", with =>
|
[Test]
|
||||||
// {
|
public void GetUsersTokenIsNull()
|
||||||
// with.HttpRequest();
|
{
|
||||||
// with.Header("Accept", "application/json");
|
PlexSettingsMock.Setup(x => x.GetSettings()).Returns(new PlexSettings());
|
||||||
// with.FormValue("username", "Username1");
|
var browser = new Browser(Bootstrapper);
|
||||||
// with.FormValue("password", "Password1");
|
|
||||||
|
|
||||||
// });
|
var result = browser.Get("/admin/getusers", with =>
|
||||||
|
{
|
||||||
|
with.HttpRequest();
|
||||||
|
with.Header("Accept", "application/json");
|
||||||
|
with.FormValue("username", "Username1");
|
||||||
|
with.FormValue("password", "Password1");
|
||||||
|
|
||||||
// Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
});
|
||||||
|
|
||||||
// var body = JsonConvert.DeserializeObject<JObject>(result.Body.AsString());
|
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||||
// var user = (string)body["users"];
|
|
||||||
// Assert.That(body, Is.Not.Null);
|
|
||||||
// Assert.That(string.IsNullOrWhiteSpace(user), Is.True);
|
|
||||||
|
|
||||||
// PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Never);
|
var body = JsonConvert.DeserializeObject<JObject>(result.Body.AsString());
|
||||||
// AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
var user = (string)body["users"];
|
||||||
// }
|
Assert.That(body, Is.Not.Null);
|
||||||
// }
|
Assert.That(string.IsNullOrWhiteSpace(user), Is.True);
|
||||||
//}
|
|
||||||
|
PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Never);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,6 +107,7 @@
|
||||||
<Compile Include="BootstrapperExtensions.cs" />
|
<Compile Include="BootstrapperExtensions.cs" />
|
||||||
<Compile Include="LandingPageTests.cs" />
|
<Compile Include="LandingPageTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SearchModuleTests.cs" />
|
||||||
<Compile Include="StringHelperTests.cs" />
|
<Compile Include="StringHelperTests.cs" />
|
||||||
<Compile Include="TestRootPathProvider.cs" />
|
<Compile Include="TestRootPathProvider.cs" />
|
||||||
<Compile Include="UserLoginModuleTests.cs" />
|
<Compile Include="UserLoginModuleTests.cs" />
|
||||||
|
|
164
PlexRequests.UI.Tests/SearchModuleTests.cs
Normal file
164
PlexRequests.UI.Tests/SearchModuleTests.cs
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: SearchModuleTests.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 System.Linq;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using PlexRequests.Api.Interfaces;
|
||||||
|
using PlexRequests.Api.Models.Plex;
|
||||||
|
using PlexRequests.Core;
|
||||||
|
using PlexRequests.Core.SettingModels;
|
||||||
|
using PlexRequests.Helpers;
|
||||||
|
using PlexRequests.Helpers.Analytics;
|
||||||
|
using PlexRequests.Services.Interfaces;
|
||||||
|
using PlexRequests.Services.Jobs;
|
||||||
|
using PlexRequests.Store;
|
||||||
|
using PlexRequests.Store.Models;
|
||||||
|
using PlexRequests.Store.Repository;
|
||||||
|
using PlexRequests.UI.Modules;
|
||||||
|
using Ploeh.AutoFixture;
|
||||||
|
|
||||||
|
namespace PlexRequests.UI.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class SearchModuleTests
|
||||||
|
{
|
||||||
|
private Mock<ISettingsService<HeadphonesSettings>> _headphonesSettings;
|
||||||
|
private Mock<INotificationService> _notificationService;
|
||||||
|
private Mock<ISettingsService<SickRageSettings>> _sickRageSettingsMock;
|
||||||
|
private Mock<ICouchPotatoApi> _cpApi;
|
||||||
|
private Mock<ISettingsService<SonarrSettings>> _sonarrSettingsMock;
|
||||||
|
private Mock<ISonarrApi> _sonarrApiMock;
|
||||||
|
private Mock<ISettingsService<PlexSettings>> _plexSettingsMock;
|
||||||
|
private Mock<ISettingsService<CouchPotatoSettings>> _cpMock;
|
||||||
|
private Mock<ISettingsService<PlexRequestSettings>> _plexRequestMock;
|
||||||
|
private Mock<ISettingsService<AuthenticationSettings>> _authMock;
|
||||||
|
private Mock<IAnalytics> _analytics;
|
||||||
|
private Mock<IAvailabilityChecker> _availabilityMock;
|
||||||
|
private Mock<IRequestService> _rServiceMock;
|
||||||
|
private Mock<ISickRageApi> _srApi;
|
||||||
|
private Mock<IMusicBrainzApi> _music;
|
||||||
|
private Mock<IHeadphonesApi> _hpAPi;
|
||||||
|
private Mock<ICouchPotatoCacher> _cpCache;
|
||||||
|
private Mock<ISonarrCacher> _sonarrCache;
|
||||||
|
private Mock<ISickRageCacher> _srCache;
|
||||||
|
private Mock<IPlexApi> _plexApi;
|
||||||
|
private Mock<IRepository<UsersToNotify>> _userRepo;
|
||||||
|
private Mock<ISettingsService<EmailNotificationSettings>> _emailSettings;
|
||||||
|
private Mock<IIssueService> _issueService;
|
||||||
|
private Mock<ICacheProvider> _cache;
|
||||||
|
private Mock<IRepository<RequestLimit>> RequestLimitRepo { get; set; }
|
||||||
|
private SearchModule Search { get; set; }
|
||||||
|
private readonly Fixture F = new Fixture();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CheckNoRequestLimitTest()
|
||||||
|
{
|
||||||
|
var settings = new PlexRequestSettings { AlbumWeeklyRequestLimit = 0, MovieWeeklyRequestLimit = 2, TvWeeklyRequestLimit = 0 };
|
||||||
|
var result = Search.CheckRequestLimit(settings, RequestType.Movie).Result;
|
||||||
|
|
||||||
|
Assert.That(result, Is.True);
|
||||||
|
RequestLimitRepo.Verify(x => x.GetAllAsync(), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCaseSource(nameof(MovieLimitData))]
|
||||||
|
public bool CheckMovieLimitTest(int requestCount)
|
||||||
|
{
|
||||||
|
var users = F.CreateMany<RequestLimit>().ToList();
|
||||||
|
users.Add(new RequestLimit { Username = "", RequestCount = requestCount, RequestType = RequestType.Movie});
|
||||||
|
RequestLimitRepo.Setup(x => x.GetAllAsync()).ReturnsAsync(users);
|
||||||
|
var settings = new PlexRequestSettings { AlbumWeeklyRequestLimit = 0, MovieWeeklyRequestLimit = 5, TvWeeklyRequestLimit = 0 };
|
||||||
|
var result = Search.CheckRequestLimit(settings, RequestType.Movie).Result;
|
||||||
|
|
||||||
|
RequestLimitRepo.Verify(x => x.GetAllAsync(), Times.Once);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<TestCaseData> MovieLimitData
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return new TestCaseData(1).Returns(true).SetName("1 Request of 5");
|
||||||
|
yield return new TestCaseData(2).Returns(true).SetName("2 Request of 5");
|
||||||
|
yield return new TestCaseData(3).Returns(true).SetName("3 Request of 5");
|
||||||
|
yield return new TestCaseData(4).Returns(true).SetName("4 Request of 5");
|
||||||
|
yield return new TestCaseData(5).Returns(false).SetName("5 Request of 5");
|
||||||
|
yield return new TestCaseData(6).Returns(false).SetName("6 Request of 5");
|
||||||
|
yield return new TestCaseData(0).Returns(true).SetName("0 Request of 5");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_authMock = new Mock<Core.ISettingsService<AuthenticationSettings>>();
|
||||||
|
_plexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
||||||
|
_plexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
|
||||||
|
_cpMock = new Mock<Core.ISettingsService<CouchPotatoSettings>>();
|
||||||
|
_plexSettingsMock = new Mock<Core.ISettingsService<PlexSettings>>();
|
||||||
|
_sonarrApiMock = new Mock<ISonarrApi>();
|
||||||
|
_sonarrSettingsMock = new Mock<Core.ISettingsService<SonarrSettings>>();
|
||||||
|
_cpApi = new Mock<ICouchPotatoApi>();
|
||||||
|
_sickRageSettingsMock = new Mock<Core.ISettingsService<SickRageSettings>>();
|
||||||
|
_notificationService = new Mock<INotificationService>();
|
||||||
|
_headphonesSettings = new Mock<Core.ISettingsService<HeadphonesSettings>>();
|
||||||
|
_cache = new Mock<ICacheProvider>();
|
||||||
|
|
||||||
|
_analytics = new Mock<IAnalytics>();
|
||||||
|
_availabilityMock = new Mock<IAvailabilityChecker>();
|
||||||
|
_rServiceMock = new Mock<IRequestService>();
|
||||||
|
_srApi = new Mock<ISickRageApi>();
|
||||||
|
_music = new Mock<IMusicBrainzApi>();
|
||||||
|
_hpAPi = new Mock<IHeadphonesApi>();
|
||||||
|
_cpCache = new Mock<ICouchPotatoCacher>();
|
||||||
|
_sonarrCache = new Mock<ISonarrCacher>();
|
||||||
|
_srCache = new Mock<ISickRageCacher>();
|
||||||
|
_plexApi = new Mock<IPlexApi>();
|
||||||
|
_userRepo = new Mock<IRepository<UsersToNotify>>();
|
||||||
|
RequestLimitRepo = new Mock<IRepository<RequestLimit>>();
|
||||||
|
_emailSettings = new Mock<ISettingsService<EmailNotificationSettings>>();
|
||||||
|
_issueService = new Mock<IIssueService>();
|
||||||
|
CreateModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateModule()
|
||||||
|
{
|
||||||
|
Search = new SearchModule(_cache.Object, _cpMock.Object, _plexRequestMock.Object, _availabilityMock.Object,
|
||||||
|
_rServiceMock.Object, _sonarrApiMock.Object, _sonarrSettingsMock.Object,
|
||||||
|
_sickRageSettingsMock.Object, _cpApi.Object, _srApi.Object, _notificationService.Object,
|
||||||
|
_music.Object, _hpAPi.Object, _headphonesSettings.Object, _cpCache.Object, _sonarrCache.Object,
|
||||||
|
_srCache.Object, _plexApi.Object, _plexSettingsMock.Object, _authMock.Object,
|
||||||
|
_userRepo.Object, _emailSettings.Object, _issueService.Object, _analytics.Object, RequestLimitRepo.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -122,11 +122,11 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Context.CurrentUser == null)
|
if (Context?.CurrentUser == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var claims = Context.CurrentUser.Claims.ToList();
|
var claims = Context?.CurrentUser.Claims.ToList();
|
||||||
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -873,7 +873,7 @@ namespace PlexRequests.UI.Modules
|
||||||
return Response.AsJson(seasons);
|
return Response.AsJson(seasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> CheckRequestLimit(PlexRequestSettings s, RequestType type)
|
public async Task<bool> CheckRequestLimit(PlexRequestSettings s, RequestType type)
|
||||||
{
|
{
|
||||||
if (IsAdmin)
|
if (IsAdmin)
|
||||||
return true;
|
return true;
|
||||||
|
@ -895,7 +895,7 @@ namespace PlexRequests.UI.Modules
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestLimit >= usersLimit.RequestCount;
|
return requestLimit > usersLimit.RequestCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetRequestLimitForType(RequestType type, PlexRequestSettings s)
|
private int GetRequestLimitForType(RequestType type, PlexRequestSettings s)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue