public void TestObtenerEnlaceSeguroUnico() { DataIntegradorEntities db = new DataIntegradorEntities(); EnlaceSeguroController controller = new EnlaceSeguroController(db); CurrentUser.setCurrentUser("*****@*****.**", "Superusuario", "0000000001", "0000000001"); string url1 = controller.ObtenerEnlaceSeguro("https://localhost:44334/Home/About/"); string url2 = controller.ObtenerEnlaceSeguro("https://localhost:44334/Home/About/"); // Obtener el hash solamente, deshacerse de /EnlaceSeguro/RedireccionSegura?urlHash= string hash1 = url1.Substring(url1.LastIndexOf("=") + 1); string hash2 = url2.Substring(url2.LastIndexOf("=") + 1); // Eliminar las tuplas insertadas EnlaceSeguro es1 = db.EnlaceSeguro.Find(hash1); if (es1 != null) { db.EnlaceSeguro.Remove(es1); db.SaveChanges(); } EnlaceSeguro es2 = db.EnlaceSeguro.Find(hash2); if (es2 != null) { db.EnlaceSeguro.Remove(es2); db.SaveChanges(); } Assert.AreNotEqual(url1, url2); }
public void TestRedireccionEnlaceSeguroIncorrecto() { DataIntegradorEntities db = new DataIntegradorEntities(); EnlaceSeguroController controller = new EnlaceSeguroController(db); CurrentUser.setCurrentUser("*****@*****.**", "Superusuario", "0000000001", "0000000001"); // Permitir solamente a [email protected] string url = controller.ObtenerEnlaceSeguro("/Home/About/", "*****@*****.**"); // Obtener el hash solamente, deshacerse de /EnlaceSeguro/RedireccionSegura?urlHash= string hash = url.Substring(url.LastIndexOf("=") + 1); var result = controller.RedireccionSegura(hash) as RedirectToRouteResult; // Eliminar las tuplas insertadas EnlaceSeguro es = db.EnlaceSeguro.Find(hash); if (es != null) { db.EnlaceSeguro.Remove(es); db.SaveChanges(); } Assert.AreEqual("Index", result.RouteValues["action"]); }