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!"); } }
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"); } }
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"); } }
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 })); } }