public void Confirm_Error_Invalid() { var controller = new InternalController(Manager); Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm("abcd")); Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm("abcd.efgh")); }
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 void Confirm_Error_Null() { var controller = new InternalController(Manager); Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm(null)); }