|
|
|
@ -47,11 +47,12 @@ using PlexRequests.UI.Modules;
|
|
|
|
|
namespace PlexRequests.UI.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[Ignore("Needs some work")]
|
|
|
|
|
//[Ignore("Needs some work")]
|
|
|
|
|
public class UserLoginModuleTests
|
|
|
|
|
{
|
|
|
|
|
private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
|
|
|
|
private Mock<ISettingsService<PlexRequestSettings>> PlexRequestMock { get; set; }
|
|
|
|
|
private ConfigurableBootstrapper Bootstrapper { get; set; }
|
|
|
|
|
private Mock<IPlexApi> PlexMock { get; set; }
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
@ -60,6 +61,15 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
AuthMock = new Mock<ISettingsService<AuthenticationSettings>>();
|
|
|
|
|
PlexMock = new Mock<IPlexApi>();
|
|
|
|
|
PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
|
|
|
|
PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
|
|
|
|
|
Bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(PlexRequestMock.Object);
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -68,21 +78,11 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
|
|
|
|
|
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.Dependency(PlexRequestMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var loc = ServiceLocator.Instance;
|
|
|
|
|
loc.SetContainer(TinyIoCContainer.Current);
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -106,17 +106,10 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
|
|
|
|
|
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -143,7 +136,7 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
{
|
|
|
|
|
new UserFriends
|
|
|
|
|
{
|
|
|
|
|
Username = "abc",
|
|
|
|
|
Title = "abc",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -152,17 +145,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
|
|
|
|
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -199,17 +184,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
|
|
|
|
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
@ -240,7 +217,7 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
{
|
|
|
|
|
new UserFriends
|
|
|
|
|
{
|
|
|
|
|
Username = "abc",
|
|
|
|
|
Title = "abc",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -257,17 +234,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
|
|
|
|
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -310,17 +279,10 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
|
|
|
|
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -347,17 +309,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, DeniedUsers = "abc", PlexAuthToken = "abc" };
|
|
|
|
|
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -379,17 +333,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
[Test]
|
|
|
|
|
public void Logout()
|
|
|
|
|
{
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object> { { SessionKeys.UsernameKey, "abc" } });
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object> { { SessionKeys.UsernameKey, "abc" } });
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Get("/userlogin/logout", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -418,17 +364,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(account);
|
|
|
|
|
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(new PlexAuthentication { user = new User { username = "Jamie" } });
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
@ -473,17 +411,9 @@ namespace PlexRequests.UI.Tests
|
|
|
|
|
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
|
|
|
|
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(account);
|
|
|
|
|
|
|
|
|
|
var bootstrapper = new ConfigurableBootstrapper(with =>
|
|
|
|
|
{
|
|
|
|
|
with.Module<UserLoginModule>();
|
|
|
|
|
with.Dependency(AuthMock.Object);
|
|
|
|
|
with.Dependency(PlexMock.Object);
|
|
|
|
|
with.RootPathProvider<TestRootPathProvider>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
Bootstrapper.WithSession(new Dictionary<string, object>());
|
|
|
|
|
|
|
|
|
|
var browser = new Browser(bootstrapper);
|
|
|
|
|
var browser = new Browser(Bootstrapper);
|
|
|
|
|
var result = browser.Post("/userlogin", with =>
|
|
|
|
|
{
|
|
|
|
|
with.HttpRequest();
|
|
|
|
|