Exemplo n.º 1
0
        public void UT_Admin_Authenticate_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (!service.Exec(null, new LoginInformation {
                Login = "******", Passwd = "123456"
            }, ref ua))
            {
                Assert.Fail("Authenticate // Failed!");
            }
        }
Exemplo n.º 2
0
        public void UT_Admin_Authenticate_LoginInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (service.Exec(null, new LoginInformation {
                Login = ""
            }, ref ua))
            {
                Assert.Fail("Authenticate // Login empty accepted");
            }
        }
Exemplo n.º 3
0
        public void UT_Admin_Authenticate_PasswordInvalid_2()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (service.Exec(null, new LoginInformation {
                Login = "******", Passwd = "123"
            }, ref ua))
            {
                Assert.Fail("Authenticate // Password invalid passed");
            }
        }
Exemplo n.º 4
0
        public ActionResult <string> Authenticate([FromBody] LoginInformation login)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminAuthenticateV1(repository);
                    var ua      = new AuthenticatedUser();

                    if (!service.Exec(db, login, ref ua))
                    {
                        return(BadRequest(service.Error));
                    }

                    return(Ok(ua));
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new ServiceError {
                    DebugInfo = ex.ToString(), Message = _defaultError
                }));
            }
        }