public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string email = req.Query["email"]; string password = req.Query["password"]; Conexion conn = new Conexion(); string responseMessage = "Conexion Fallida"; if (conn.state()) { Login_function login = new Login_function(conn); if (login.valido(email, password)) { response respuesta = login.validar_credenciales(email, password); conn.close(); return(new OkObjectResult(JsonConvert.SerializeObject(respuesta))); } } conn.close(); return(new OkObjectResult(JsonConvert.SerializeObject(new response(false, responseMessage)))); }
public void TestLogin() { Conexion conn = new Conexion(); if (conn.state() == true) { Login_function login = new Login_function(conn); Assert.IsFalse(login.valido("", "")); Assert.IsFalse(login.valido("andreeavalos", "")); Assert.IsTrue(login.valido("andreeavalos", "122234")); Assert.IsFalse(login.validar_credenciales("*****@*****.**", "admff").result); conn.close(); conn = new Conexion(); login = new Login_function(conn); Assert.IsTrue(login.validar_credenciales("*****@*****.**", "admin1").result); conn.close(); return; } conn.close(); Assert.Fail(); }