public async Task Reset() { var controller = new InternalController(Manager); //Reset development account password await controller.Reset("dev@localhost"); Assert.AreEqual(1, Smtp.SentEmailCount); Assert.AreEqual("WikiLibs API Server", Smtp.LastSendEmail.Subject); Assert.AreEqual(Shared.Modules.Smtp.Models.UserReset.Template, Smtp.LastSendEmail.Template); Assert.AreEqual("dev@localhost", Smtp.LastSendEmail.Recipients.First().Email); var data = Smtp.LastSendEmail.Model as Shared.Modules.Smtp.Models.UserReset; Assert.AreEqual(Context.Users.Last().Pass, data.NewPassword); //Check we can login var res = await controller.Login(new Models.Input.Auth.Login() { Email = "dev@localhost", Password = data.NewPassword }) as JsonResult; var token = res.Value as string; Assert.IsNotNull(token); }
public void Auth_Error_Invalid() { var controller = new InternalController(Manager); Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login() { Email = "dev@localhost123456789", Password = "******" })); //Check that bot login is not allowed using standard user systems Context.Users.Last().IsBot = true; Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login() { Email = "dev@localhost", Password = "******" })); }
public async Task Register() { var controller = new InternalController(Manager); //Creation await PostTestUser(controller); Assert.AreEqual(1, Smtp.SentEmailCount); Assert.AreEqual("WikiLibs API Server", Smtp.LastSendEmail.Subject); Assert.AreEqual(Shared.Modules.Smtp.Models.UserRegistration.Template, Smtp.LastSendEmail.Template); Assert.AreEqual("*****@*****.**", Smtp.LastSendEmail.Recipients.First().Email); Assert.AreEqual(Context.Users.Last().FirstName + " " + Context.Users.Last().LastName, Smtp.LastSendEmail.Recipients.First().Name); var data = Smtp.LastSendEmail.Model as Shared.Modules.Smtp.Models.UserRegistration; Assert.AreEqual(Context.Users.Last().FirstName + " " + Context.Users.Last().LastName, data.UserName); Assert.AreEqual(Context.Users.Last().Confirmation, data.ConfirmCode); Assert.AreEqual(2, Context.Users.Count()); Assert.IsNotNull(Context.Users.Last().Confirmation); //Check we can't login Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login() { Email = "*****@*****.**", Password = "******" })); //Confirmation await controller.Confirm(data.ConfirmCode); Assert.AreEqual(2, Context.Users.Count()); Assert.IsNull(Context.Users.Last().Confirmation); //Check we can login var res = await controller.Login(new Models.Input.Auth.Login() { Email = "*****@*****.**", Password = "******" }) as JsonResult; var token = res.Value as string; Assert.IsNotNull(token); }
public async Task Auth() { var controller = new InternalController(Manager); var res = await controller.Login(new Models.Input.Auth.Login() { Email = "dev@localhost", Password = "******" }) as JsonResult; var token = res.Value as string; Assert.IsNotNull(token); }