public void UT_User_Authenticate_PasswordInvalid_2() { var repo = new mockUserRepositoryUserExists(); var service = new UserAuthenticateV1(repo); var ua = new AuthenticatedUser(); if (service.Exec(null, new LoginInformation { Login = "******", Passwd = "123" }, ref ua)) { Assert.Fail("Authenticate // Password invalid passed"); } }
public void UT_User_Authenticate_OK() { var repo = new mockUserRepositoryUserExists(); var service = new UserAuthenticateV1(repo); var ua = new AuthenticatedUser(); if (!service.Exec(null, new LoginInformation { Login = "******", Passwd = "123456" }, ref ua)) { Assert.Fail("Authenticate // Failed!"); } }
public void UT_User_Authenticate_LoginInvalid() { var repo = new mockUserRepositoryUserExists(); var service = new UserAuthenticateV1(repo); var ua = new AuthenticatedUser(); if (service.Exec(null, new LoginInformation { Login = "" }, ref ua)) { Assert.Fail("Authenticate // Login empty accepted"); } }
public ActionResult <string> Authenticate([FromBody] LoginInformation login) { try { using (var db = new SqlConnection(GetDBConnectionString())) { var service = new UserAuthenticateV1(userRepository); 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 })); } }