コード例 #1
0
        public void Reset_Error_NonExistant()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <Shared.Exceptions.ResourceNotFound>(() => controller.Reset("*****@*****.**"));
            Context.Users.First().IsBot = true;
            Assert.ThrowsAsync <Shared.Exceptions.ResourceNotFound>(() => controller.Reset("dev@localhost"));
        }
コード例 #2
0
        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);
        }