Exemplo n.º 1
0
        public void Should_Login_User_With_Valid_Credentials()
        {
            var fixture           = new Fixture();
            var authenticatedUser = fixture.Create <AuthenticatedUser>();

            _service.Setup(x => x.Authenticate(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(authenticatedUser);

            var result = _controller.Login(fixture.Create <UserAuthenticationParameters>()).GetAwaiter().GetResult() as OkObjectResult;

            (result.Value as AuthenticatedUser)?.Should().BeEquivalentTo(authenticatedUser);
        }
Exemplo n.º 2
0
        public void LoginInvalidData()
        {
            Controllers.LoginController login = new Controllers.LoginController();
            Models.LoginUser            usr   = new Models.LoginUser();
            usr.Username = "******";
            usr.Password = "******";
            usr.Domain   = "example.com";

            var result = login.Login(usr) as ViewResult;

            Assert.AreEqual("AUTH FAILED", result.ViewData["Error"]);
        }
Exemplo n.º 3
0
        public void LoginData()
        {
            Controllers.LoginController login = new Controllers.LoginController();
            Models.LoginUser            usr   = new Models.LoginUser();
            usr.Username = "******";
            usr.Password = "******";
            usr.Domain   = "example.com";

            var result = login.Login(usr) as RedirectToRouteResult;

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Exemplo n.º 4
0
        public static Eventual.Model.User LoginValidator(Controllers.LoginController login, Eventual.Model.LoginCredentials loginCredential)
        {
            HttpResponseMessage response = login.Login(loginCredential);

            if (response.IsSuccessStatusCode)
            {
                var user = response.Content.ReadAsAsync <Eventual.Model.User>().Result;

                return(user);
            }

            return(null);
        }